NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Autotracking fixes (#7096)
Josh Hawkins691e9d26d2d6
diff --git a/frigate/ptz/autotrack.py b/frigate/ptz/autotrack.pyindex 0417af38fb..f52193287f 100644--- a/frigate/ptz/autotrack.py+++ b/frigate/ptz/autotrack.py@@ -98,13 +98,12 @@ class PtzAutoTrackerThread(threading.Thread):for camera_name, cam in self.config.cameras.items():if cam.onvif.autotracking.enabled:self.ptz_autotracker.camera_maintenance(camera_name)- time.sleep(1)else:# disabled dynamically by mqttif self.ptz_autotracker.tracked_object.get(camera_name):self.ptz_autotracker.tracked_object[camera_name] = Noneself.ptz_autotracker.tracked_object_previous[camera_name] = None- time.sleep(0.1)+ time.sleep(1)logger.info("Exiting autotracker...")@@ -199,11 +198,20 @@ class PtzAutoTracker:move_data = self.move_queues[camera].get()pan, tilt = move_data- self.onvif._move_relative(camera, pan, tilt, 1)+ # check if ptz is moving+ self.onvif.get_camera_status(camera)# Wait until the camera finishes movingself.camera_metrics[camera]["ptz_stopped"].wait()+ self.onvif._move_relative(camera, pan, tilt, 1)++ # Wait until the camera finishes moving+ while not self.camera_metrics[camera]["ptz_stopped"].is_set():+ # check if ptz is moving+ self.onvif.get_camera_status(camera)+ time.sleep(1 / (self.config.cameras[camera].detect.fps / 2))+except queue.Empty:time.sleep(0.1)@@ -229,10 +237,10 @@ class PtzAutoTracker:def autotrack_object(self, camera, obj):camera_config = self.config.cameras[camera]- # check if ptz is moving- self.onvif.get_camera_status(camera)-- if camera_config.onvif.autotracking.enabled:+ if (+ camera_config.onvif.autotracking.enabled+ and self.camera_metrics[camera]["ptz_stopped"].is_set()+ ):# either this is a brand new object that's on our camera, has our label, entered the zone, is not a false positive,# and is not initially motionless - or one we're already tracking, which assumes all those things are already trueif (diff --git a/frigate/ptz/onvif.py b/frigate/ptz/onvif.pyindex 253d76ef65..5bbe7a873e 100644--- a/frigate/ptz/onvif.py+++ b/frigate/ptz/onvif.py@@ -247,14 +247,7 @@ class OnvifController:"Zoom": 0,}- # move pan and tilt separatelymove_request.Translation.PanTilt.x = pan- move_request.Translation.PanTilt.y = 0- move_request.Translation.Zoom.x = 0-- onvif.get_service("ptz").RelativeMove(move_request)-- move_request.Translation.PanTilt.x = 0move_request.Translation.PanTilt.y = tiltmove_request.Translation.Zoom.x = 0@@ -350,7 +343,7 @@ class OnvifController:status_request = self.cams[camera_name]["status_request"]status = onvif.get_service("ptz").GetStatus(status_request)- if status.MoveStatus.PanTilt == "IDLE" or status.MoveStatus.Zoom == "IDLE":+ if status.MoveStatus.PanTilt == "IDLE" and status.MoveStatus.Zoom == "IDLE":self.cams[camera_name]["active"] = Falseself.camera_metrics[camera_name]["ptz_stopped"].set()else: