mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-18 17:14:26 +03:00
get histogram in tracker instead of detect
This commit is contained in:
parent
9153ff605b
commit
cf3aa31432
@ -21,7 +21,11 @@ from frigate.camera import PTZMetrics
|
||||
from frigate.config import CameraConfig
|
||||
from frigate.ptz.autotrack import PtzMotionEstimator
|
||||
from frigate.track import ObjectTracker
|
||||
from frigate.util.image import intersection_over_union
|
||||
from frigate.util.image import (
|
||||
SharedMemoryFrameManager,
|
||||
get_histogram,
|
||||
intersection_over_union,
|
||||
)
|
||||
from frigate.util.object import average_boxes, median_of_boxes
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -105,6 +109,7 @@ class NorfairTracker(ObjectTracker):
|
||||
config: CameraConfig,
|
||||
ptz_metrics: PTZMetrics,
|
||||
):
|
||||
self.frame_manager = SharedMemoryFrameManager()
|
||||
self.tracked_objects = {}
|
||||
self.untracked_object_boxes: list[list[int]] = []
|
||||
self.disappeared = {}
|
||||
@ -457,11 +462,20 @@ class NorfairTracker(ObjectTracker):
|
||||
# track based on top,left and bottom,right corners instead of centroid
|
||||
points = np.array([[obj[2][0], obj[2][1]], [obj[2][2], obj[2][3]]])
|
||||
|
||||
embedding = None
|
||||
if self.ptz_metrics.autotracker_enabled.value:
|
||||
yuv_frame = self.frame_manager.get(
|
||||
frame_name, self.camera_config.frame_shape_yuv
|
||||
)
|
||||
embedding = get_histogram(
|
||||
yuv_frame, obj[2][0], obj[2][1], obj[2][2], obj[2][3]
|
||||
)
|
||||
|
||||
detection = Detection(
|
||||
points=points,
|
||||
label=label,
|
||||
# TODO: stationary objects won't have embeddings
|
||||
embedding=obj[6] if len(obj) > 6 else None,
|
||||
embedding=embedding,
|
||||
data={
|
||||
"label": label,
|
||||
"score": obj[1],
|
||||
|
||||
@ -33,7 +33,6 @@ from frigate.util.image import (
|
||||
FrameManager,
|
||||
SharedMemoryFrameManager,
|
||||
draw_box_with_label,
|
||||
get_histogram,
|
||||
)
|
||||
from frigate.util.object import (
|
||||
create_tensor_input,
|
||||
@ -511,16 +510,7 @@ def detect(
|
||||
height = y_max - y_min
|
||||
area = width * height
|
||||
ratio = width / max(1, height)
|
||||
hist = get_histogram(frame, x_min, y_min, x_max, y_max)
|
||||
det = (
|
||||
d[0],
|
||||
d[1],
|
||||
(x_min, y_min, x_max, y_max),
|
||||
area,
|
||||
ratio,
|
||||
region,
|
||||
hist,
|
||||
)
|
||||
det = (d[0], d[1], (x_min, y_min, x_max, y_max), area, ratio, region)
|
||||
# apply object filters
|
||||
if is_object_filtered(det, objects_to_track, object_filters):
|
||||
continue
|
||||
|
||||
Loading…
Reference in New Issue
Block a user