forked from Github/frigate
expose frame time at each step of processing
This commit is contained in:
@@ -34,6 +34,7 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
'object_status': defaultdict(lambda: defaultdict(lambda: 'OFF')),
|
||||
'tracked_objects': {},
|
||||
'current_frame': np.zeros((720,1280,3), np.uint8),
|
||||
'current_frame_time': 0.0,
|
||||
'object_id': None
|
||||
})
|
||||
self.plasma_client = PlasmaManager()
|
||||
@@ -55,6 +56,7 @@ class TrackedObjectProcessor(threading.Thread):
|
||||
best_objects = self.camera_data[camera]['best_objects']
|
||||
current_object_status = self.camera_data[camera]['object_status']
|
||||
self.camera_data[camera]['tracked_objects'] = tracked_objects
|
||||
self.camera_data[camera]['current_frame_time'] = frame_time
|
||||
|
||||
###
|
||||
# Draw tracked objects on the frame
|
||||
|
||||
@@ -125,6 +125,7 @@ class CameraCapture(threading.Thread):
|
||||
self.fps = fps
|
||||
self.plasma_client = PlasmaManager()
|
||||
self.ffmpeg_process = ffmpeg_process
|
||||
self.current_frame = 0
|
||||
|
||||
def run(self):
|
||||
frame_num = 0
|
||||
@@ -134,7 +135,7 @@ class CameraCapture(threading.Thread):
|
||||
break
|
||||
|
||||
frame_bytes = self.ffmpeg_process.stdout.read(self.frame_size)
|
||||
frame_time = datetime.datetime.now().timestamp()
|
||||
self.current_frame = datetime.datetime.now().timestamp()
|
||||
|
||||
if len(frame_bytes) == 0:
|
||||
print(f"{self.name}: ffmpeg didnt return a frame. something is wrong.")
|
||||
@@ -145,17 +146,17 @@ class CameraCapture(threading.Thread):
|
||||
continue
|
||||
|
||||
# put the frame in the plasma store
|
||||
self.plasma_client.put(f"{self.name}{frame_time}",
|
||||
self.plasma_client.put(f"{self.name}{self.current_frame}",
|
||||
np
|
||||
.frombuffer(frame_bytes, np.uint8)
|
||||
.reshape(self.frame_shape)
|
||||
)
|
||||
# add to the queue
|
||||
self.frame_queue.put(frame_time)
|
||||
self.frame_queue.put(self.current_frame)
|
||||
|
||||
self.fps.update()
|
||||
|
||||
def track_camera(name, config, global_objects_config, frame_queue, frame_shape, detection_queue, detected_objects_queue, fps, skipped_fps, detection_fps, read_start):
|
||||
def track_camera(name, config, global_objects_config, frame_queue, frame_shape, detection_queue, detected_objects_queue, fps, skipped_fps, detection_fps, read_start, detection_frame):
|
||||
print(f"Starting process for {name}: {os.getpid()}")
|
||||
listen()
|
||||
|
||||
@@ -204,6 +205,7 @@ def track_camera(name, config, global_objects_config, frame_queue, frame_shape,
|
||||
duration = datetime.datetime.now().timestamp()-read_start.value
|
||||
read_start.value = 0.0
|
||||
avg_wait = (avg_wait*99+duration)/100
|
||||
detection_frame.value = frame_time
|
||||
|
||||
fps_tracker.update()
|
||||
fps.value = fps_tracker.eps()
|
||||
|
||||
Reference in New Issue
Block a user