NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Fix API latest image quality and API MIME types (#15964)
tpjanssen9983bd8d9285
diff --git a/frigate/api/media.py b/frigate/api/media.pyindex e19fe547f4..b5f3ba7034 100644--- a/frigate/api/media.py+++ b/frigate/api/media.py@@ -133,6 +133,15 @@ def latest_frame("regions": params.regions,}quality = params.quality+ mime_type = extension++ if extension == "png":+ quality_params = None+ elif extension == "webp":+ quality_params = [int(cv2.IMWRITE_WEBP_QUALITY), quality]+ else:+ quality_params = [int(cv2.IMWRITE_JPEG_QUALITY), quality]+ mime_type = "jpeg"if camera_name in request.app.frigate_config.cameras:frame = frame_processor.get_current_frame(camera_name, draw_options)@@ -173,13 +182,11 @@ def latest_frame(frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)- ret, img = cv2.imencode(- f".{extension}", frame, [int(cv2.IMWRITE_WEBP_QUALITY), quality]- )+ ret, img = cv2.imencode(f".{extension}", frame, quality_params)return Response(content=img.tobytes(),- media_type=f"image/{extension}",- headers={"Content-Type": f"image/{extension}", "Cache-Control": "no-store"},+ media_type=f"image/{mime_type}",+ headers={"Content-Type": f"image/{mime_type}", "Cache-Control": "no-store"},)elif camera_name == "birdseye" and request.app.frigate_config.birdseye.restream:frame = cv2.cvtColor(@@ -192,13 +199,11 @@ def latest_frame(frame = cv2.resize(frame, dsize=(width, height), interpolation=cv2.INTER_AREA)- ret, img = cv2.imencode(- f".{extension}", frame, [int(cv2.IMWRITE_WEBP_QUALITY), quality]- )+ ret, img = cv2.imencode(f".{extension}", frame, quality_params)return Response(content=img.tobytes(),- media_type=f"image/{extension}",- headers={"Content-Type": f"image/{extension}", "Cache-Control": "no-store"},+ media_type=f"image/{mime_type}",+ headers={"Content-Type": f"image/{mime_type}", "Cache-Control": "no-store"},)else:return JSONResponse(@@ -241,6 +246,7 @@ def get_snapshot_from_recording(recording: Recordings = recording_query.get()time_in_segment = frame_time - recording.start_timecodec = "png" if format == "png" else "mjpeg"+ mime_type = "png" if format == "png" else "jpeg"config: FrigateConfig = request.app.frigate_configimage_data = get_image_from_recording(@@ -257,7 +263,7 @@ def get_snapshot_from_recording(),status_code=404,)- return Response(image_data, headers={"Content-Type": f"image/{format}"})+ return Response(image_data, headers={"Content-Type": f"image/{mime_type}"})except DoesNotExist:return JSONResponse(content={