@@ -41,6 +41,7 @@ def preprocess_frame(frame: cv2.Mat) -> cv2.Mat:
4141 Convert to grayscale and apply Gaussian blur to suppress noise.
4242
4343 Doctest:
44+ >>> import numpy as np
4445 >>> dummy = np.zeros((10, 10, 3), dtype=np.uint8)
4546 >>> out = preprocess_frame(dummy)
4647 >>> out.shape == (10, 10) and out.dtype == np.uint8
@@ -57,6 +58,7 @@ def frame_difference(prev_gray: cv2.Mat, curr_gray: cv2.Mat) -> cv2.Mat:
5758 Returns a binary motion mask after thresholding and morphology.
5859
5960 Doctest:
61+ >>> import numpy as np
6062 >>> a = np.zeros((8, 8), dtype=np.uint8)
6163 >>> b = np.zeros((8, 8), dtype=np.uint8)
6264 >>> b[2:6, 2:6] = 255
@@ -82,6 +84,7 @@ def background_subtraction_mask(
8284
8385 Doctest:
8486 >>> subtractor = create_background_subtractor()
87+ >>> import numpy as np
8588 >>> frame = np.zeros((12, 12, 3), dtype=np.uint8)
8689 >>> mask = background_subtraction_mask(subtractor, frame)
8790 >>> mask.shape
@@ -103,6 +106,7 @@ def annotate_motion(frame: cv2.Mat, motion_mask: cv2.Mat) -> cv2.Mat:
103106 Find contours on the motion mask and draw bounding boxes on the frame.
104107
105108 Doctest:
109+ >>> import numpy as np
106110 >>> frame = np.zeros((60, 60, 3), dtype=np.uint8)
107111 >>> mask = np.zeros((60, 60), dtype=np.uint8)
108112 >>> mask[10:40, 10:40] = 255 # large enough to exceed MIN_CONTOUR_AREA
0 commit comments