mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 11:07:41 +03:00
Adjust debug image saving
This commit is contained in:
parent
35693e73f4
commit
e881c8d743
@ -1,11 +1,14 @@
|
|||||||
"""Post processor for review items to get descriptions."""
|
"""Post processor for review items to get descriptions."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
|
||||||
from frigate.config import FrigateConfig
|
from frigate.config import FrigateConfig
|
||||||
|
from frigate.const import CLIPS_DIR
|
||||||
from frigate.data_processing.types import PostProcessDataEnum
|
from frigate.data_processing.types import PostProcessDataEnum
|
||||||
from frigate.genai import GenAIClient
|
from frigate.genai import GenAIClient
|
||||||
|
|
||||||
@ -43,7 +46,6 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
|||||||
# we have already processed this thumbnail
|
# we have already processed this thumbnail
|
||||||
return
|
return
|
||||||
|
|
||||||
shutil.copy(thumb_path, f"/media/frigate/frames/{thumb_time}.webp")
|
|
||||||
thumb_data = cv2.imread(thumb_path)
|
thumb_data = cv2.imread(thumb_path)
|
||||||
ret, jpg = cv2.imencode(
|
ret, jpg = cv2.imencode(
|
||||||
".jpg", thumb_data, [int(cv2.IMWRITE_JPEG_QUALITY), 100]
|
".jpg", thumb_data, [int(cv2.IMWRITE_JPEG_QUALITY), 100]
|
||||||
@ -51,6 +53,22 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
|||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
self.tracked_review_items[id].append((thumb_time, jpg.tobytes()))
|
self.tracked_review_items[id].append((thumb_time, jpg.tobytes()))
|
||||||
|
|
||||||
|
if self.config.cameras[""].review.genai.debug_save_thumbnails:
|
||||||
|
id = data["after"]["id"]
|
||||||
|
Path(os.path.join(CLIPS_DIR, f"genai-requests/{id}")).mkdir(
|
||||||
|
parents=True, exist_ok=True
|
||||||
|
)
|
||||||
|
|
||||||
|
for idx, data in enumerate(self.tracked_review_items[id], 1):
|
||||||
|
shutil.copy(
|
||||||
|
thumb_path,
|
||||||
|
os.path.join(
|
||||||
|
CLIPS_DIR,
|
||||||
|
f"genai-requests/{id}/{idx}.webp",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if id not in self.tracked_review_items:
|
if id not in self.tracked_review_items:
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user