mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-01 19:17:41 +03:00
Get camera correctly created
This commit is contained in:
parent
301c01dbf2
commit
1d0e9829f6
@ -1,7 +1,6 @@
|
|||||||
"""Create and maintain camera processes / management."""
|
"""Create and maintain camera processes / management."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing as mp
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
@ -125,7 +124,6 @@ class CameraMaintainer(threading.Thread):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if runtime:
|
if runtime:
|
||||||
self.detection_out_events[name] = mp.Event()
|
|
||||||
self.camera_metrics[name] = CameraMetrics()
|
self.camera_metrics[name] = CameraMetrics()
|
||||||
self.ptz_metrics[name] = PTZMetrics(autotracker_enabled=False)
|
self.ptz_metrics[name] = PTZMetrics(autotracker_enabled=False)
|
||||||
self.region_grids[name] = get_camera_regions_grid(
|
self.region_grids[name] = get_camera_regions_grid(
|
||||||
@ -135,7 +133,20 @@ class CameraMaintainer(threading.Thread):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
largest_frame = max(
|
||||||
|
[
|
||||||
|
det.model.height * det.model.width * 3
|
||||||
|
if det.model is not None
|
||||||
|
else 320
|
||||||
|
for det in self.config.detectors.values()
|
||||||
|
]
|
||||||
|
)
|
||||||
UntrackedSharedMemory(name=f"out-{name}", create=True, size=20 * 6 * 4)
|
UntrackedSharedMemory(name=f"out-{name}", create=True, size=20 * 6 * 4)
|
||||||
|
UntrackedSharedMemory(
|
||||||
|
name=name,
|
||||||
|
create=True,
|
||||||
|
size=largest_frame,
|
||||||
|
)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -112,15 +112,18 @@ def run_detector(
|
|||||||
signal.signal(signal.SIGTERM, receiveSignal)
|
signal.signal(signal.SIGTERM, receiveSignal)
|
||||||
signal.signal(signal.SIGINT, receiveSignal)
|
signal.signal(signal.SIGINT, receiveSignal)
|
||||||
|
|
||||||
|
def create_output_shm(name: str):
|
||||||
|
out_shm = UntrackedSharedMemory(name=f"out-{name}", create=False)
|
||||||
|
out_np = np.ndarray((20, 6), dtype=np.float32, buffer=out_shm.buf)
|
||||||
|
outputs[name] = {"shm": out_shm, "np": out_np}
|
||||||
|
|
||||||
frame_manager = SharedMemoryFrameManager()
|
frame_manager = SharedMemoryFrameManager()
|
||||||
object_detector = LocalObjectDetector(detector_config=detector_config)
|
object_detector = LocalObjectDetector(detector_config=detector_config)
|
||||||
detector_publisher = ObjectDetectorPublisher()
|
detector_publisher = ObjectDetectorPublisher()
|
||||||
|
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for name in cameras:
|
for name in cameras:
|
||||||
out_shm = UntrackedSharedMemory(name=f"out-{name}", create=False)
|
create_output_shm(name)
|
||||||
out_np = np.ndarray((20, 6), dtype=np.float32, buffer=out_shm.buf)
|
|
||||||
outputs[name] = {"shm": out_shm, "np": out_np}
|
|
||||||
|
|
||||||
while not stop_event.is_set():
|
while not stop_event.is_set():
|
||||||
try:
|
try:
|
||||||
@ -141,6 +144,10 @@ def run_detector(
|
|||||||
detections = object_detector.detect_raw(input_frame)
|
detections = object_detector.detect_raw(input_frame)
|
||||||
duration = datetime.datetime.now().timestamp() - start.value
|
duration = datetime.datetime.now().timestamp() - start.value
|
||||||
frame_manager.close(connection_id)
|
frame_manager.close(connection_id)
|
||||||
|
|
||||||
|
if connection_id not in outputs:
|
||||||
|
create_output_shm(connection_id)
|
||||||
|
|
||||||
outputs[connection_id]["np"][:] = detections[:]
|
outputs[connection_id]["np"][:] = detections[:]
|
||||||
detector_publisher.publish(connection_id, connection_id)
|
detector_publisher.publish(connection_id, connection_id)
|
||||||
start.value = 0.0
|
start.value = 0.0
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user