1+
2+ # Generated by CodiumAI
3+ from deepgaze .deepgaze .motion_detection import DiffMotionDetector
4+ import cv2
5+
6+
7+ import pytest
8+
9+ class TestDiffMotionDetector :
10+
11+ # Tests that the background image is set successfully
12+ def test_set_background_successfully (self ):
13+ detector = DiffMotionDetector ()
14+ background_image = cv2 .imread ('background.jpg' )
15+ detector .setBackground (background_image )
16+ assert detector .getBackground () is not None
17+
18+ # Tests that a binary image is returned successfully after the detection process
19+ def test_return_binary_image_successfully (self ):
20+ detector = DiffMotionDetector ()
21+ background_image = cv2 .imread ('background.jpg' )
22+ foreground_image = cv2 .imread ('foreground.jpg' )
23+ detector .setBackground (background_image )
24+ binary_image = detector .returnMask (foreground_image )
25+ assert binary_image is not None
26+
27+ # Tests that a background image is set and a binary image is returned successfully after the detection process
28+ def test_set_background_and_return_binary_image_successfully (self ):
29+ detector = DiffMotionDetector ()
30+ background_image = cv2 .imread ('background.jpg' )
31+ foreground_image = cv2 .imread ('foreground.jpg' )
32+ detector .setBackground (background_image )
33+ binary_image = detector .returnMask (foreground_image )
34+ assert detector .getBackground () is not None and binary_image is not None
35+
36+ # Tests that setting a None background image returns None
37+ def test_set_none_background_image_and_return_none (self ):
38+ detector = DiffMotionDetector ()
39+ detector .setBackground (None )
40+ assert detector .getBackground () is None
41+
42+ # Tests that setting a None foreground image returns None
43+ def test_set_none_foreground_image_and_return_none (self ):
44+ detector = DiffMotionDetector ()
45+ background_image = cv2 .imread ('background.jpg' )
46+ detector .setBackground (background_image )
47+ binary_image = detector .returnMask (None )
48+ assert binary_image is None
49+
50+ # Tests that setting a None background image returns None after the detection process
51+ def test_set_none_background_image_and_return_none_after_detection_process (self ):
52+ detector = DiffMotionDetector ()
53+ detector .setBackground (None )
54+ assert detector .getBackground () is None
0 commit comments