def test_initialize(): """Test Camera's initialize function.""" c = camera_fusion.Camera(0, 11) c.settings = [(0, 0), (1, 1), (3, 1280), (4, 720)] frame = np.load('./tests/test_Camera/real_captured_frame.npy') c.current_frame = frame with mock.patch('cv2.VideoCapture', return_value=Vc(c)): with mock.patch('camera_fusion.Camera.read', return_value=frame): c.initialize()
def test_draw_fps(): """Test draw_fps function.""" with mock.patch('time.time', return_value=0): c = camera_fusion.Camera(0, 11) c.width = 1280 c.height = 720 frame = np.load('./tests/test_Camera/real_captured_frame.npy') with mock.patch('time.time', return_value=0.03): frame = c.draw_fps(frame) # 33 fps np.testing.assert_array_equal(np.load( './tests/test_Camera/real_captured_frame_with_30fps.npy'), frame)
def test_draw_text(): """Test draw_text function.""" c = camera_fusion.Camera(0, 11) c.width = 1280 c.height = 720 frame = np.load('./tests/test_Camera/real_captured_frame.npy') frame = c.draw_text(frame, 'test') # 33 fps np.save('./tests/test_Camera/real_captured_frame_withText.npy', frame) np.testing.assert_array_equal( np.load('./tests/test_Camera/real_captured_frame_withText.npy'), frame)
def test__update_frame(): """Test the _update_frame function.""" c = camera_fusion.Camera(0, 11) c.stop = False shutil.copytree('./tests/test_Camera', 'data') # Testing camera frame read and update real_captured_frame = np.load('./data/real_captured_frame.npy') c.cap = Vc(c, real_captured_frame) c._update_frame() np.testing.assert_array_equal(c.current_frame, real_captured_frame) shutil.rmtree('data')
def test_test_camera(): """Test the basic camera test.""" shutil.copytree('./tests/test_Camera', 'data') c = camera_fusion.Camera(0, 11) c.settings = [(0, 0), (1, 1), (3, 1280), (4, 720)] frame = np.load('./tests/test_Camera/real_captured_frame.npy') c.current_frame = frame with mock.patch('cv2.VideoCapture', return_value=Vc(c)): # Testing camera setup with mock.patch('camera_fusion.Camera.read', return_value=np.load( './data/real_captured_frame.npy')): c.initialize() c.width = 1280 c.height = 720 c.test_camera() shutil.rmtree('data')