mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Update query to get image
This commit is contained in:
parent
e9b935e597
commit
47138e9237
@ -352,22 +352,25 @@ def stats():
|
|||||||
stats = stats_snapshot(current_app.stats_tracking)
|
stats = stats_snapshot(current_app.stats_tracking)
|
||||||
return jsonify(stats)
|
return jsonify(stats)
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/<camera_name>/<label>/latest.jpg")
|
@bp.route("/<camera_name>/<label>/latest.jpg")
|
||||||
def latest(camera_name, label):
|
def latest(camera_name, label):
|
||||||
jpg_bytes = None
|
jpg_bytes = None
|
||||||
if camera_name in current_app.frigate_config.cameras:
|
if camera_name in current_app.frigate_config.cameras:
|
||||||
events = (
|
event = (
|
||||||
Event.select()
|
Event.select()
|
||||||
.where(Event.camera == camera_name)
|
.where(Event.camera == camera_name)
|
||||||
.where(Event.label == "*" if label is "any" else label)
|
.where(Event.label == "*" if label is "any" else label)
|
||||||
.where(Event.has_snapshot == True)
|
.where(Event.has_snapshot == True)
|
||||||
.where(Event.end_time != None)
|
.where(Event.end_time != None)
|
||||||
.order_by(Event.start_time.desc())
|
.order_by(Event.start_time.desc())
|
||||||
|
.get()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#event = events.first()
|
||||||
# read snapshot from disk
|
# read snapshot from disk
|
||||||
with open(
|
with open(
|
||||||
os.path.join(CLIPS_DIR, f"{event.camera}-{id}.jpg"), "rb"
|
os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}.jpg"), "rb"
|
||||||
) as image_file:
|
) as image_file:
|
||||||
jpg_bytes = image_file.read()
|
jpg_bytes = image_file.read()
|
||||||
|
|
||||||
@ -377,6 +380,7 @@ def latest(camera_name, label):
|
|||||||
else:
|
else:
|
||||||
return "Camera named {} not found".format(camera_name), 404
|
return "Camera named {} not found".format(camera_name), 404
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/<camera_name>/<label>/best.jpg")
|
@bp.route("/<camera_name>/<label>/best.jpg")
|
||||||
def best(camera_name, label):
|
def best(camera_name, label):
|
||||||
if camera_name in current_app.frigate_config.cameras:
|
if camera_name in current_app.frigate_config.cameras:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user