mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25:22 +03:00
Send clean image
This commit is contained in:
parent
47138e9237
commit
cc4d48a6ef
@ -355,27 +355,30 @@ def 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
|
png_bytes = None
|
||||||
if camera_name in current_app.frigate_config.cameras:
|
if camera_name in current_app.frigate_config.cameras:
|
||||||
|
|
||||||
|
if label == "any":
|
||||||
|
label = "*"
|
||||||
|
|
||||||
event = (
|
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 == 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()
|
.get()
|
||||||
)
|
)
|
||||||
|
|
||||||
#event = events.first()
|
|
||||||
# read snapshot from disk
|
# read snapshot from disk
|
||||||
with open(
|
with open(
|
||||||
os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}.jpg"), "rb"
|
os.path.join(CLIPS_DIR, f"{event.camera}-{event.id}-clean.png"), "rb"
|
||||||
) as image_file:
|
) as image_file:
|
||||||
jpg_bytes = image_file.read()
|
png_bytes = image_file.read()
|
||||||
|
|
||||||
response = make_response(jpg_bytes)
|
response = make_response(png_bytes)
|
||||||
response.headers["Content-Type"] = "image/jpeg"
|
response.headers["Content-Type"] = "image/png"
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return "Camera named {} not found".format(camera_name), 404
|
return "Camera named {} not found".format(camera_name), 404
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user