mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-07 03:11:15 +03:00
Various fixes (#17342)
* Remove imutils * Ensure that state is maintained when setting search params * Change script for version of setuptools * Fix * Fix
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import cv2
|
||||
import imutils
|
||||
import numpy as np
|
||||
|
||||
from frigate.config import MotionConfig
|
||||
from frigate.motion import MotionDetector
|
||||
from frigate.util.image import grab_cv2_contours
|
||||
|
||||
|
||||
class 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 contours
|
||||
for c in contours:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import logging
|
||||
|
||||
import cv2
|
||||
import imutils
|
||||
import numpy as np
|
||||
from scipy.ndimage import gaussian_filter
|
||||
|
||||
@@ -9,6 +8,7 @@ from frigate.camera import PTZMetrics
|
||||
from frigate.comms.config_updater import ConfigSubscriber
|
||||
from frigate.config import MotionConfig
|
||||
from frigate.motion import MotionDetector
|
||||
from frigate.util.image import grab_cv2_contours
|
||||
|
||||
logger = 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 contours
|
||||
total_contour_area = 0
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user