NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Various fixes (#17342)
Nicolas Moweneabc316c7b5b
diff --git a/.cspell/frigate-dictionary.txt b/.cspell/frigate-dictionary.txtindex dbab9600ef..77e4ede622 100644--- a/.cspell/frigate-dictionary.txt+++ b/.cspell/frigate-dictionary.txt@@ -108,7 +108,6 @@ imagestreamimdecodeimencodeimread-imutilsimwriteinterpiostatdiff --git a/docker/main/Dockerfile b/docker/main/Dockerfileindex fb23940f80..a712508136 100644--- a/docker/main/Dockerfile+++ b/docker/main/Dockerfile@@ -78,8 +78,9 @@ COPY docker/main/requirements-ov.txt /requirements-ov.txtRUN apt-get -qq update \&& apt-get -qq install -y wget python3 python3-dev python3-distutils gcc pkg-config libhdf5-dev \&& wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \+ && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \&& python3 get-pip.py "pip" \- && pip install -r /requirements-ov.txt+ && pip3 install -r /requirements-ov.txt# Get OpenVino ModelRUN --mount=type=bind,source=docker/main/build_ov_model.py,target=/build_ov_model.py \@@ -172,6 +173,7 @@ RUN apt-get -qq update \RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \+ && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \&& python3 get-pip.py "pip"COPY docker/main/requirements.txt /requirements.txt@@ -235,6 +237,7 @@ ENV DEFAULT_FFMPEG_VERSION="7.0"ENV INCLUDED_FFMPEG_VERSIONS="${DEFAULT_FFMPEG_VERSION}:5.0"RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \+ && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \&& python3 get-pip.py "pip"RUN --mount=type=bind,from=wheels,source=/wheels,target=/deps/wheels \diff --git a/docker/main/requirements-wheels.txt b/docker/main/requirements-wheels.txtindex 9368cabcd7..4ab7e03e64 100644--- a/docker/main/requirements-wheels.txt+++ b/docker/main/requirements-wheels.txt@@ -7,7 +7,6 @@ starlette-context == 0.3.6fastapi == 0.115.*uvicorn == 0.30.*slowapi == 0.1.*-imutils == 0.5.*joserfc == 1.0.*pathvalidate == 3.2.*markupsafe == 3.0.*diff --git a/docker/rocm/Dockerfile b/docker/rocm/Dockerfileindex 78f91b96f8..d04e93df3e 100644--- a/docker/rocm/Dockerfile+++ b/docker/rocm/Dockerfile@@ -39,6 +39,7 @@ WORKDIR /opt/frigateCOPY --from=rootfs / /RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \+ && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \&& python3 get-pip.py "pip" --break-system-packagesRUN python3 -m pip config set global.break-system-packages truediff --git a/docker/tensorrt/Dockerfile.arm64 b/docker/tensorrt/Dockerfile.arm64index 5d5d5d9390..6e2e0280f5 100644--- a/docker/tensorrt/Dockerfile.arm64+++ b/docker/tensorrt/Dockerfile.arm64@@ -9,9 +9,9 @@ ARG DEBIAN_FRONTEND# Add deadsnakes PPA for python3.11RUN apt-get -qq update && \- apt-get -qq install -y --no-install-recommends \- software-properties-common \- && add-apt-repository ppa:deadsnakes/ppa+ apt-get -qq install -y --no-install-recommends \+ software-properties-common \+ && add-apt-repository ppa:deadsnakes/ppa# Use a separate container to build wheels to prevent build dependencies in final imageRUN apt-get -qq update \@@ -24,6 +24,7 @@ RUN apt-get -qq update \RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1RUN wget -q https://bootstrap.pypa.io/get-pip.py -O get-pip.py \+ && sed -i 's/args.append("setuptools")/args.append("setuptools==77.0.3")/' get-pip.py \&& python3 get-pip.py "pip"FROM build-wheels AS trt-wheelsdiff --git a/frigate/motion/frigate_motion.py b/frigate/motion/frigate_motion.pyindex 72097667b4..fd362de346 100644--- a/frigate/motion/frigate_motion.py+++ b/frigate/motion/frigate_motion.py@@ -1,9 +1,9 @@import cv2-import imutilsimport numpy as npfrom frigate.config import MotionConfigfrom frigate.motion import MotionDetector+from frigate.util.image import grab_cv2_contoursclass FrigateMotionDetector(MotionDetector):@@ -103,7 +103,7 @@ class FrigateMotionDetector(MotionDetector):contours = cv2.findContours(thresh_dilated, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)- contours = imutils.grab_contours(contours)+ contours = grab_cv2_contours(contours)# loop over the contoursfor c in contours:diff --git a/frigate/motion/improved_motion.py b/frigate/motion/improved_motion.pyindex aae5167a45..69de6d0155 100644--- a/frigate/motion/improved_motion.py+++ b/frigate/motion/improved_motion.py@@ -1,7 +1,6 @@import loggingimport cv2-import imutilsimport numpy as npfrom scipy.ndimage import gaussian_filter@@ -9,6 +8,7 @@ from frigate.camera import PTZMetricsfrom frigate.comms.config_updater import ConfigSubscriberfrom frigate.config import MotionConfigfrom frigate.motion import MotionDetector+from frigate.util.image import grab_cv2_contourslogger = logging.getLogger(__name__)@@ -147,7 +147,7 @@ class ImprovedMotionDetector(MotionDetector):contours = cv2.findContours(thresh_dilated, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)- contours = imutils.grab_contours(contours)+ contours = grab_cv2_contours(contours)# loop over the contourstotal_contour_area = 0diff --git a/frigate/util/image.py b/frigate/util/image.pyindex 0b80efe880..93827747c3 100644--- a/frigate/util/image.py+++ b/frigate/util/image.py@@ -265,6 +265,19 @@ def draw_box_with_label()+def grab_cv2_contours(cnts):+ # if the length the contours tuple returned by cv2.findContours+ # is '2' then we are using either OpenCV v2.4, v4-beta, or+ # v4-official+ if len(cnts) == 2:+ return cnts[0]++ # if the length of the contours tuple is '3' then we are using+ # either OpenCV v3, v4-pre, or v4-alpha+ elif len(cnts) == 3:+ return cnts[1]++def is_label_printable(label) -> bool:"""Check if label is printable."""return not bool(set(label) - set(printable))diff --git a/web/src/hooks/use-overlay-state.tsx b/web/src/hooks/use-overlay-state.tsxindex 7a43383d47..5b41ca3027 100644--- a/web/src/hooks/use-overlay-state.tsx+++ b/web/src/hooks/use-overlay-state.tsx@@ -109,6 +109,7 @@ export function useSearchEffect(key: string,callback: (value: string) => boolean,) {+ const location = useLocation();const [searchParams, setSearchParams] = useSearchParams();const param = useMemo(() => {@@ -129,7 +130,7 @@ export function useSearchEffect(const remove = callback(param[1]);if (remove) {- setSearchParams(undefined, { replace: true });+ setSearchParams(undefined, { state: location.state, replace: true });}- }, [param, callback, setSearchParams]);+ }, [param, location.state, callback, setSearchParams]);}