mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 09:15:22 +03:00
downgrade to python3.6
This commit is contained in:
parent
ec47141c82
commit
ef5f69ecda
@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
|
import shared_memory
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
@ -41,7 +42,7 @@ class FrigateApp:
|
|||||||
self.detection_queue = mp.Queue()
|
self.detection_queue = mp.Queue()
|
||||||
self.detectors: Dict[str, EdgeTPUProcess] = {}
|
self.detectors: Dict[str, EdgeTPUProcess] = {}
|
||||||
self.detection_out_events: Dict[str, mp.Event] = {}
|
self.detection_out_events: Dict[str, mp.Event] = {}
|
||||||
self.detection_shms: List[mp.shared_memory.SharedMemory] = []
|
self.detection_shms: List[shared_memory.SharedMemory] = []
|
||||||
self.log_queue = mp.Queue()
|
self.log_queue = mp.Queue()
|
||||||
self.camera_metrics = {}
|
self.camera_metrics = {}
|
||||||
|
|
||||||
@ -154,20 +155,20 @@ class FrigateApp:
|
|||||||
self.detection_out_events[name] = mp.Event()
|
self.detection_out_events[name] = mp.Event()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shm_in = mp.shared_memory.SharedMemory(
|
shm_in = shared_memory.SharedMemory(
|
||||||
name=name,
|
name=name,
|
||||||
create=True,
|
create=True,
|
||||||
size=self.config.model.height * self.config.model.width * 3,
|
size=self.config.model.height * self.config.model.width * 3,
|
||||||
)
|
)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
shm_in = mp.shared_memory.SharedMemory(name=name)
|
shm_in = shared_memory.SharedMemory(name=name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shm_out = mp.shared_memory.SharedMemory(
|
shm_out = shared_memory.SharedMemory(
|
||||||
name=f"out-{name}", create=True, size=20 * 6 * 4
|
name=f"out-{name}", create=True, size=20 * 6 * 4
|
||||||
)
|
)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
shm_out = mp.shared_memory.SharedMemory(name=f"out-{name}")
|
shm_out = shared_memory.SharedMemory(name=f"out-{name}")
|
||||||
|
|
||||||
self.detection_shms.append(shm_in)
|
self.detection_shms.append(shm_in)
|
||||||
self.detection_shms.append(shm_out)
|
self.detection_shms.append(shm_out)
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
@ -761,7 +759,7 @@ class ModelConfig(FrigateBaseModel):
|
|||||||
return self._merged_labelmap
|
return self._merged_labelmap
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def colormap(self) -> Dict[int, tuple[int, int, int]]:
|
def colormap(self) -> Dict[int, Tuple[int, int, int]]:
|
||||||
return self._colormap
|
return self._colormap
|
||||||
|
|
||||||
def __init__(self, **config):
|
def __init__(self, **config):
|
||||||
@ -850,7 +848,7 @@ class FrigateConfig(FrigateBaseModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def runtime_config(self) -> FrigateConfig:
|
def runtime_config(self):
|
||||||
"""Merge camera config with globals."""
|
"""Merge camera config with globals."""
|
||||||
config = self.copy(deep=True)
|
config = self.copy(deep=True)
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,10 @@ import signal
|
|||||||
import threading
|
import threading
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
import shared_memory
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
# TensorRT https://github.com/NobuoTsukamoto/tensorrt-examples/blob/main/python/detection/README.md
|
||||||
import tflite_runtime.interpreter as tflite
|
import tflite_runtime.interpreter as tflite
|
||||||
from setproctitle import setproctitle
|
from setproctitle import setproctitle
|
||||||
from tflite_runtime.interpreter import load_delegate
|
from tflite_runtime.interpreter import load_delegate
|
||||||
@ -159,7 +161,7 @@ def run_detector(
|
|||||||
|
|
||||||
outputs = {}
|
outputs = {}
|
||||||
for name in out_events.keys():
|
for name in out_events.keys():
|
||||||
out_shm = mp.shared_memory.SharedMemory(name=f"out-{name}", create=False)
|
out_shm = shared_memory.SharedMemory(name=f"out-{name}", create=False)
|
||||||
out_np = np.ndarray((20, 6), dtype=np.float32, buffer=out_shm.buf)
|
out_np = np.ndarray((20, 6), dtype=np.float32, buffer=out_shm.buf)
|
||||||
outputs[name] = {"shm": out_shm, "np": out_np}
|
outputs[name] = {"shm": out_shm, "np": out_np}
|
||||||
|
|
||||||
@ -248,11 +250,11 @@ class RemoteObjectDetector:
|
|||||||
self.fps = EventsPerSecond()
|
self.fps = EventsPerSecond()
|
||||||
self.detection_queue = detection_queue
|
self.detection_queue = detection_queue
|
||||||
self.event = event
|
self.event = event
|
||||||
self.shm = mp.shared_memory.SharedMemory(name=self.name, create=False)
|
self.shm = shared_memory.SharedMemory(name=self.name, create=False)
|
||||||
self.np_shm = np.ndarray(
|
self.np_shm = np.ndarray(
|
||||||
(1, model_shape[0], model_shape[1], 3), dtype=np.uint8, buffer=self.shm.buf
|
(1, model_shape[0], model_shape[1], 3), dtype=np.uint8, buffer=self.shm.buf
|
||||||
)
|
)
|
||||||
self.out_shm = mp.shared_memory.SharedMemory(
|
self.out_shm = shared_memory.SharedMemory(
|
||||||
name=f"out-{self.name}", create=False
|
name=f"out-{self.name}", create=False
|
||||||
)
|
)
|
||||||
self.out_np_shm = np.ndarray((20, 6), dtype=np.float32, buffer=self.out_shm.buf)
|
self.out_np_shm = np.ndarray((20, 6), dtype=np.float32, buffer=self.out_shm.buf)
|
||||||
|
|||||||
@ -608,7 +608,8 @@ def recording_clip(camera, start_ts, end_ts):
|
|||||||
ffmpeg_cmd,
|
ffmpeg_cmd,
|
||||||
input="\n".join(playlist_lines),
|
input="\n".join(playlist_lines),
|
||||||
encoding="ascii",
|
encoding="ascii",
|
||||||
capture_output=True,
|
stdout=sp.PIPE,
|
||||||
|
stderr=sp.PIPE,
|
||||||
)
|
)
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
logger.error(p.stderr)
|
logger.error(p.stderr)
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import queue
|
|||||||
import signal
|
import signal
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
import threading
|
import threading
|
||||||
from multiprocessing import shared_memory
|
|
||||||
from wsgiref.simple_server import make_server
|
from wsgiref.simple_server import make_server
|
||||||
from frigate.log import LogPipe
|
from frigate.log import LogPipe
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ class FFMpegConverter:
|
|||||||
# ffmpeg_cmd = f"gst-launch-1.0 fdsrc ! video/x-raw, width={in_width}, height={in_height}, format=I420 ! nvvideoconvert ! omxh264enc ! h264parse ! mpegtsmux ! fdsink".split(
|
# ffmpeg_cmd = f"gst-launch-1.0 fdsrc ! video/x-raw, width={in_width}, height={in_height}, format=I420 ! nvvideoconvert ! omxh264enc ! h264parse ! mpegtsmux ! fdsink".split(
|
||||||
# " "
|
# " "
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
self.logpipe = LogPipe(
|
self.logpipe = LogPipe(
|
||||||
"ffmpeg.converter", logging.ERROR)
|
"ffmpeg.converter", logging.ERROR)
|
||||||
|
|||||||
@ -41,7 +41,7 @@ def get_frame_shape(source):
|
|||||||
"json",
|
"json",
|
||||||
source,
|
source,
|
||||||
]
|
]
|
||||||
p = sp.run(ffprobe_cmd, capture_output=True)
|
p = sp.run(ffprobe_cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||||
info = json.loads(p.stdout)
|
info = json.loads(p.stdout)
|
||||||
|
|
||||||
video_info = [s for s in info["streams"] if s["codec_type"] == "video"][0]
|
video_info = [s for s in info["streams"] if s["codec_type"] == "video"][0]
|
||||||
|
|||||||
@ -94,7 +94,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
"default=noprint_wrappers=1:nokey=1",
|
"default=noprint_wrappers=1:nokey=1",
|
||||||
f"{cache_path}",
|
f"{cache_path}",
|
||||||
]
|
]
|
||||||
p = sp.run(ffprobe_cmd, capture_output=True)
|
p = sp.run(ffprobe_cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
duration = float(p.stdout.decode().strip())
|
duration = float(p.stdout.decode().strip())
|
||||||
end_time = start_time + datetime.timedelta(seconds=duration)
|
end_time = start_time + datetime.timedelta(seconds=duration)
|
||||||
@ -284,7 +284,8 @@ class RecordingCleanup(threading.Thread):
|
|||||||
logger.debug(f"Oldest recording in the db: {oldest_timestamp}")
|
logger.debug(f"Oldest recording in the db: {oldest_timestamp}")
|
||||||
process = sp.run(
|
process = sp.run(
|
||||||
["find", RECORD_DIR, "-type", "f", "!", "-newermt", f"@{oldest_timestamp}"],
|
["find", RECORD_DIR, "-type", "f", "!", "-newermt", f"@{oldest_timestamp}"],
|
||||||
capture_output=True,
|
stdout=sp.PIPE,
|
||||||
|
stderr=sp.PIPE,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
files_to_check = process.stdout.splitlines()
|
files_to_check = process.stdout.splitlines()
|
||||||
|
|||||||
@ -11,7 +11,8 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from multiprocessing import shared_memory
|
#from multiprocessing import shared_memory
|
||||||
|
import shared_memory
|
||||||
from typing import AnyStr
|
from typing import AnyStr
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user