Skip to content

Commit 084345c

Browse files
committed
remove unused import
1 parent 64f93ab commit 084345c

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

computer_vision/motion_detection.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import cv2
2-
import numpy as np
32

43
"""
54
Basic Motion Detection using frame differencing and background subtraction (MOG2).
@@ -32,9 +31,7 @@ def create_background_subtractor() -> cv2.BackgroundSubtractor:
3231
True
3332
"""
3433
# history=500, varThreshold=16 are common defaults; detectShadows adds robustness
35-
return cv2.createBackgroundSubtractorMOG2(
36-
history=500, varThreshold=16, detectShadows=True
37-
)
34+
return cv2.createBackgroundSubtractorMOG2(history=500, varThreshold=16, detectShadows=True)
3835

3936

4037
def preprocess_frame(frame: cv2.Mat) -> cv2.Mat:
@@ -75,9 +72,7 @@ def frame_difference(prev_gray: cv2.Mat, curr_gray: cv2.Mat) -> cv2.Mat:
7572
return closed
7673

7774

78-
def background_subtraction_mask(
79-
subtractor: cv2.BackgroundSubtractor, frame: cv2.Mat
80-
) -> cv2.Mat:
75+
def background_subtraction_mask(subtractor: cv2.BackgroundSubtractor, frame: cv2.Mat) -> cv2.Mat:
8176
"""
8277
Apply background subtraction to obtain a motion mask. Includes morphology.
8378
@@ -111,9 +106,7 @@ def annotate_motion(frame: cv2.Mat, motion_mask: cv2.Mat) -> cv2.Mat:
111106
>>> np.any(annotated[..., 1] == 255) # green channel from rectangle
112107
True
113108
"""
114-
contours, _ = cv2.findContours(
115-
motion_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
116-
)
109+
contours, _ = cv2.findContours(motion_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
117110
annotated = frame.copy()
118111
for contour in contours:
119112
if cv2.contourArea(contour) < MIN_CONTOUR_AREA:
@@ -188,3 +181,5 @@ def main() -> None:
188181
if __name__ == "__main__":
189182
main()
190183
print("DONE ✅")
184+
185+

0 commit comments

Comments
 (0)