mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Fix non detected objects being added
This commit is contained in:
parent
755477a84b
commit
a812ef8cf8
@ -65,7 +65,6 @@ class PendingReviewSegment:
|
|||||||
def update_frame(
|
def update_frame(
|
||||||
self, camera_config: CameraConfig, frame, objects: list[TrackedObject]
|
self, camera_config: CameraConfig, frame, objects: list[TrackedObject]
|
||||||
):
|
):
|
||||||
self.frame_active_count = len(objects)
|
|
||||||
min_x = camera_config.frame_shape[1]
|
min_x = camera_config.frame_shape[1]
|
||||||
min_y = camera_config.frame_shape[0]
|
min_y = camera_config.frame_shape[0]
|
||||||
max_x = 0
|
max_x = 0
|
||||||
@ -86,13 +85,13 @@ class PendingReviewSegment:
|
|||||||
if not region:
|
if not region:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
self.frame_active_count = len(objects)
|
||||||
color_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
color_frame = cv2.cvtColor(frame, cv2.COLOR_YUV2BGR_I420)
|
||||||
color_frame = color_frame[region[1] : region[3], region[0] : region[2]]
|
color_frame = color_frame[region[1] : region[3], region[0] : region[2]]
|
||||||
width = int(THUMB_HEIGHT * color_frame.shape[1] / color_frame.shape[0])
|
width = int(THUMB_HEIGHT * color_frame.shape[1] / color_frame.shape[0])
|
||||||
self.frame = cv2.resize(
|
self.frame = cv2.resize(
|
||||||
color_frame, dsize=(width, THUMB_HEIGHT), interpolation=cv2.INTER_AREA
|
color_frame, dsize=(width, THUMB_HEIGHT), interpolation=cv2.INTER_AREA
|
||||||
)
|
)
|
||||||
cv2.imwrite(f"/media/frigate/frames/thumb_{self.id}.jpg", self.frame)
|
|
||||||
|
|
||||||
def end(self) -> dict:
|
def end(self) -> dict:
|
||||||
path = os.path.join(CLIPS_DIR, f"thumb-{self.camera}-{self.id}.jpg")
|
path = os.path.join(CLIPS_DIR, f"thumb-{self.camera}-{self.id}.jpg")
|
||||||
@ -148,10 +147,13 @@ class ReviewSegmentMaintainer(threading.Thread):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Validate if existing review segment should continue."""
|
"""Validate if existing review segment should continue."""
|
||||||
camera_config = self.config.cameras[segment.camera]
|
camera_config = self.config.cameras[segment.camera]
|
||||||
|
|
||||||
|
# get objects that are not stationary and detected in this frame
|
||||||
active_objects = [
|
active_objects = [
|
||||||
o
|
o
|
||||||
for o in objects
|
for o in objects
|
||||||
if o["motionless_count"] < camera_config.detect.stationary.threshold
|
if o["motionless_count"] < camera_config.detect.stationary.threshold
|
||||||
|
and o["frame_time"] == frame_time
|
||||||
]
|
]
|
||||||
|
|
||||||
if len(active_objects) > 0:
|
if len(active_objects) > 0:
|
||||||
@ -163,13 +165,11 @@ class ReviewSegmentMaintainer(threading.Thread):
|
|||||||
|
|
||||||
if len(active_objects) > segment.frame_active_count:
|
if len(active_objects) > segment.frame_active_count:
|
||||||
frame_id = f"{camera_config.name}{frame_time}"
|
frame_id = f"{camera_config.name}{frame_time}"
|
||||||
logger.error(f"get frame {frame_id}")
|
|
||||||
yuv_frame = self.frame_manager.get(
|
yuv_frame = self.frame_manager.get(
|
||||||
frame_id, camera_config.frame_shape_yuv
|
frame_id, camera_config.frame_shape_yuv
|
||||||
)
|
)
|
||||||
segment.update_frame(camera_config, yuv_frame, active_objects)
|
segment.update_frame(camera_config, yuv_frame, active_objects)
|
||||||
self.frame_manager.close(frame_id)
|
self.frame_manager.close(frame_id)
|
||||||
logger.error(f"close frame {frame_id}")
|
|
||||||
|
|
||||||
for object in active_objects:
|
for object in active_objects:
|
||||||
segment.detections.add(object["id"])
|
segment.detections.add(object["id"])
|
||||||
@ -212,6 +212,7 @@ class ReviewSegmentMaintainer(threading.Thread):
|
|||||||
o
|
o
|
||||||
for o in objects
|
for o in objects
|
||||||
if o["motionless_count"] < camera_config.detect.stationary.threshold
|
if o["motionless_count"] < camera_config.detect.stationary.threshold
|
||||||
|
and o["frame_time"] == frame_time
|
||||||
]
|
]
|
||||||
|
|
||||||
if len(active_objects) > 0:
|
if len(active_objects) > 0:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user