mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-13 13:47:36 +02:00
Basic implementation for testing review processor
This commit is contained in:
parent
c169e766a5
commit
6b0f425cb0
25
frigate/data_processing/post/review_descriptions.py
Normal file
25
frigate/data_processing/post/review_descriptions.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
"""Post processor for review items to get descriptions."""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
from frigate.data_processing.types import PostProcessDataEnum
|
||||||
|
|
||||||
|
from ..post.api import PostProcessorApi
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ReviewDescriptionProcessor(PostProcessorApi):
|
||||||
|
def __init__(self, config, metrics):
|
||||||
|
super().__init__(config, metrics, None)
|
||||||
|
self.tracked_review_items: dict[str, list[Any]] = {}
|
||||||
|
|
||||||
|
def process_data(self, data, data_type):
|
||||||
|
if data_type != PostProcessDataEnum.review:
|
||||||
|
return
|
||||||
|
|
||||||
|
logger.info(f"processor is looking at {data}")
|
||||||
|
|
||||||
|
def handle_request(self, request_data):
|
||||||
|
pass
|
@ -50,6 +50,7 @@ from frigate.data_processing.post.audio_transcription import (
|
|||||||
from frigate.data_processing.post.license_plate import (
|
from frigate.data_processing.post.license_plate import (
|
||||||
LicensePlatePostProcessor,
|
LicensePlatePostProcessor,
|
||||||
)
|
)
|
||||||
|
from frigate.data_processing.post.review_descriptions import ReviewDescriptionProcessor
|
||||||
from frigate.data_processing.post.semantic_trigger import SemanticTriggerProcessor
|
from frigate.data_processing.post.semantic_trigger import SemanticTriggerProcessor
|
||||||
from frigate.data_processing.real_time.api import RealTimeProcessorApi
|
from frigate.data_processing.real_time.api import RealTimeProcessorApi
|
||||||
from frigate.data_processing.real_time.bird import BirdRealTimeProcessor
|
from frigate.data_processing.real_time.bird import BirdRealTimeProcessor
|
||||||
@ -534,7 +535,9 @@ class EmbeddingMaintainer(threading.Thread):
|
|||||||
if review_updates == None:
|
if review_updates == None:
|
||||||
break
|
break
|
||||||
|
|
||||||
logger.info(f"revieved review update {review_updates}")
|
for processor in self.post_processors:
|
||||||
|
if isinstance(processor, ReviewDescriptionProcessor):
|
||||||
|
processor.process_data(review_updates, PostProcessDataEnum.review)
|
||||||
|
|
||||||
def _process_event_metadata(self):
|
def _process_event_metadata(self):
|
||||||
# Check for regenerate description requests
|
# Check for regenerate description requests
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Maintain review segments in db."""
|
"""Maintain review segments in db."""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import datetime
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -64,6 +65,7 @@ class PendingReviewSegment:
|
|||||||
self.zones = zones
|
self.zones = zones
|
||||||
self.audio = audio
|
self.audio = audio
|
||||||
self.last_update = frame_time
|
self.last_update = frame_time
|
||||||
|
self.thumb_time: float | None = None
|
||||||
|
|
||||||
# thumbnail
|
# thumbnail
|
||||||
self._frame = np.zeros((THUMB_HEIGHT * 3 // 2, THUMB_WIDTH), np.uint8)
|
self._frame = np.zeros((THUMB_HEIGHT * 3 // 2, THUMB_WIDTH), np.uint8)
|
||||||
@ -105,6 +107,7 @@ class PendingReviewSegment:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if self._frame is not None:
|
if self._frame is not None:
|
||||||
|
self.thumb_time = datetime.datetime.now().timestamp()
|
||||||
self.has_frame = True
|
self.has_frame = True
|
||||||
cv2.imwrite(
|
cv2.imwrite(
|
||||||
self.frame_path, self._frame, [int(cv2.IMWRITE_WEBP_QUALITY), 60]
|
self.frame_path, self._frame, [int(cv2.IMWRITE_WEBP_QUALITY), 60]
|
||||||
@ -138,6 +141,7 @@ class PendingReviewSegment:
|
|||||||
"sub_labels": list(self.sub_labels.values()),
|
"sub_labels": list(self.sub_labels.values()),
|
||||||
"zones": self.zones,
|
"zones": self.zones,
|
||||||
"audio": list(self.audio),
|
"audio": list(self.audio),
|
||||||
|
"thumb_time": self.thumb_time,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user