Basic PTZ object autotracking functionality (#6913)

* Basic functionality

* Threaded motion estimator

* Revert "Threaded motion estimator"

This reverts commit 3171801607.

* Don't detect motion when ptz is moving

* fix motion logic

* fix mypy error

* Add threaded queue for movement for slower ptzs

* Move queues per camera

* Move autotracker start to app.py

* iou value for tracked object

* mqtt callback

* tracked object should be initially motionless

* only draw thicker box if autotracking is enabled

* Init if enabled when initially disabled in config

* Fix init

* Thread names

* Always use motion estimator

* docs

* clarify fov support

* remove size ratio

* use mp event instead of value for ptz status

* update autotrack at half fps

* fix merge conflict

* fix event type for mypy

* clean up

* Clean up

* remove unused code

* merge conflict fix

* docs: update link to object_detectors page

* Update docs/docs/configuration/autotracking.md

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* clarify wording

* pass actual instances directly

* default return preset

* fix type

* Error message when onvif init fails

* disable autotracking if onvif init fails

* disable autotracking if onvif init fails

* ptz module

* verify required_zones in config

* update util after dev merge

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
This commit is contained in:
Josh Hawkins
2023-07-08 07:04:47 -05:00
committed by GitHub
parent d6f82f9edc
commit 88fc0fac8f
15 changed files with 770 additions and 17 deletions

View File

@@ -478,6 +478,8 @@ def track_camera(
detection_enabled = process_info["detection_enabled"]
motion_enabled = process_info["motion_enabled"]
improve_contrast_enabled = process_info["improve_contrast_enabled"]
ptz_autotracker_enabled = process_info["ptz_autotracker_enabled"]
ptz_stopped = process_info["ptz_stopped"]
motion_threshold = process_info["motion_threshold"]
motion_contour_area = process_info["motion_contour_area"]
@@ -497,7 +499,7 @@ def track_camera(
name, labelmap, detection_queue, result_connection, model_config, stop_event
)
object_tracker = NorfairTracker(config.detect)
object_tracker = NorfairTracker(config, ptz_autotracker_enabled, ptz_stopped)
frame_manager = SharedMemoryFrameManager()
@@ -518,6 +520,7 @@ def track_camera(
detection_enabled,
motion_enabled,
stop_event,
ptz_stopped,
)
logger.info(f"{name}: exiting subprocess")
@@ -742,6 +745,7 @@ def process_frames(
detection_enabled: mp.Value,
motion_enabled: mp.Value,
stop_event,
ptz_stopped: mp.Event,
exit_on_empty: bool = False,
):
fps = process_info["process_fps"]
@@ -778,7 +782,11 @@ def process_frames(
continue
# look for motion if enabled
motion_boxes = motion_detector.detect(frame) if motion_enabled.value else []
motion_boxes = (
motion_detector.detect(frame)
if motion_enabled.value and ptz_stopped.is_set()
else []
)
regions = []
consolidated_detections = []