forked from mpatacchiola/deepgaze
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Umair0343/Umair0343-patch-1
Tests folder added including the test file for the class DiffMotionDetector in the motion_detection.py file
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
# Generated by CodiumAI | ||
from deepgaze.deepgaze.motion_detection import DiffMotionDetector | ||
import cv2 | ||
|
||
|
||
import pytest | ||
|
||
class TestDiffMotionDetector: | ||
|
||
# Tests that the background image is set successfully | ||
def test_set_background_successfully(self): | ||
detector = DiffMotionDetector() | ||
background_image = cv2.imread('background.jpg') | ||
detector.setBackground(background_image) | ||
assert detector.getBackground() is not None | ||
|
||
# Tests that a binary image is returned successfully after the detection process | ||
def test_return_binary_image_successfully(self): | ||
detector = DiffMotionDetector() | ||
background_image = cv2.imread('background.jpg') | ||
foreground_image = cv2.imread('foreground.jpg') | ||
detector.setBackground(background_image) | ||
binary_image = detector.returnMask(foreground_image) | ||
assert binary_image is not None | ||
|
||
# Tests that a background image is set and a binary image is returned successfully after the detection process | ||
def test_set_background_and_return_binary_image_successfully(self): | ||
detector = DiffMotionDetector() | ||
background_image = cv2.imread('background.jpg') | ||
foreground_image = cv2.imread('foreground.jpg') | ||
detector.setBackground(background_image) | ||
binary_image = detector.returnMask(foreground_image) | ||
assert detector.getBackground() is not None and binary_image is not None | ||
|
||
# Tests that setting a None background image returns None | ||
def test_set_none_background_image_and_return_none(self): | ||
detector = DiffMotionDetector() | ||
detector.setBackground(None) | ||
assert detector.getBackground() is None | ||
|
||
# Tests that setting a None foreground image returns None | ||
def test_set_none_foreground_image_and_return_none(self): | ||
detector = DiffMotionDetector() | ||
background_image = cv2.imread('background.jpg') | ||
detector.setBackground(background_image) | ||
binary_image = detector.returnMask(None) | ||
assert binary_image is None | ||
|
||
# Tests that setting a None background image returns None after the detection process | ||
def test_set_none_background_image_and_return_none_after_detection_process(self): | ||
detector = DiffMotionDetector() | ||
detector.setBackground(None) | ||
assert detector.getBackground() is None |