mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-19 01:17:06 +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.config import CameraConfig
|
||||||
from frigate.ptz.autotrack import PtzMotionEstimator
|
from frigate.ptz.autotrack import PtzMotionEstimator
|
||||||
from frigate.track import ObjectTracker
|
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
|
from frigate.util.object import average_boxes, median_of_boxes
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -105,6 +109,7 @@ class NorfairTracker(ObjectTracker):
|
|||||||
config: CameraConfig,
|
config: CameraConfig,
|
||||||
ptz_metrics: PTZMetrics,
|
ptz_metrics: PTZMetrics,
|
||||||
):
|
):
|
||||||
|
self.frame_manager = SharedMemoryFrameManager()
|
||||||
self.tracked_objects = {}
|
self.tracked_objects = {}
|
||||||
self.untracked_object_boxes: list[list[int]] = []
|
self.untracked_object_boxes: list[list[int]] = []
|
||||||
self.disappeared = {}
|
self.disappeared = {}
|
||||||
@ -457,11 +462,20 @@ class NorfairTracker(ObjectTracker):
|
|||||||
# track based on top,left and bottom,right corners instead of centroid
|
# 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]]])
|
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(
|
detection = Detection(
|
||||||
points=points,
|
points=points,
|
||||||
label=label,
|
label=label,
|
||||||
# TODO: stationary objects won't have embeddings
|
# TODO: stationary objects won't have embeddings
|
||||||
embedding=obj[6] if len(obj) > 6 else None,
|
embedding=embedding,
|
||||||
data={
|
data={
|
||||||
"label": label,
|
"label": label,
|
||||||
"score": obj[1],
|
"score": obj[1],
|
||||||
|
|||||||
@ -33,7 +33,6 @@ from frigate.util.image import (
|
|||||||
FrameManager,
|
FrameManager,
|
||||||
SharedMemoryFrameManager,
|
SharedMemoryFrameManager,
|
||||||
draw_box_with_label,
|
draw_box_with_label,
|
||||||
get_histogram,
|
|
||||||
)
|
)
|
||||||
from frigate.util.object import (
|
from frigate.util.object import (
|
||||||
create_tensor_input,
|
create_tensor_input,
|
||||||
@ -511,16 +510,7 @@ def detect(
|
|||||||
height = y_max - y_min
|
height = y_max - y_min
|
||||||
area = width * height
|
area = width * height
|
||||||
ratio = width / max(1, 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)
|
||||||
det = (
|
|
||||||
d[0],
|
|
||||||
d[1],
|
|
||||||
(x_min, y_min, x_max, y_max),
|
|
||||||
area,
|
|
||||||
ratio,
|
|
||||||
region,
|
|
||||||
hist,
|
|
||||||
)
|
|
||||||
# apply object filters
|
# apply object filters
|
||||||
if is_object_filtered(det, objects_to_track, object_filters):
|
if is_object_filtered(det, objects_to_track, object_filters):
|
||||||
continue
|
continue
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user