def test_capture_image_should_create_an_image_handler_and_subscribe_it_to_video_processor(self, mock_camera): cam = mock_camera.return_value cam.shape = [300, 100] api = ScannerAPI() api.capture_image() self.assertTrue(len(api.video_processor.handlers) > 0) self.assertEquals(ImageCapture, type(api.video_processor.handlers[0][0])) self.assertTrue(hasattr(api.video_processor.handlers[0][0], 'handle'))
def test_capture_image_should_subscribe_with_expected_callback(self, mock_camera): cam = mock_camera.return_value cam.shape = [300, 100] api = ScannerAPI() callback = Mock() api.capture_image(callback) self.assertTrue(len(api.video_processor.handlers) > 0) self.assertEquals(ImageCapture, type(api.video_processor.handlers[0][0])) self.assertEqual(api.video_processor.handlers[0][1], callback)
def test_capture_image_should_create_an_image_handler_and_subscribe_it_to_video_processor( self, mock_camera): cam = mock_camera.return_value cam.shape = [300, 100] api = ScannerAPI() api.capture_image() self.assertTrue(len(api.video_processor.handlers) > 0) self.assertEquals(ImageCapture, type(api.video_processor.handlers[0][0])) self.assertTrue(hasattr(api.video_processor.handlers[0][0], 'handle'))
def test_capture_image_should_subscribe_with_expected_callback( self, mock_camera): cam = mock_camera.return_value cam.shape = [300, 100] api = ScannerAPI() callback = Mock() api.capture_image(callback) self.assertTrue(len(api.video_processor.handlers) > 0) self.assertEquals(ImageCapture, type(api.video_processor.handlers[0][0])) self.assertEqual(api.video_processor.handlers[0][1], callback)
class Goer(object): def __init__(self): self.api = ScannerAPI() self.image = None self.api.capture_image(self.callback) def callback(self, image): self.image = image.image def run(self): try: self.api.start() key = 'a' while(key != 'q'): if self.image is not None: print('running') cv2.imshow('frame', self.image) key = chr(cv2.waitKey(1) & 0xFF) finally: cv2.destroyAllWindows() self.api.stop()
class Goer(object): def __init__(self): self.api = ScannerAPI() self.image = None self.api.capture_image(self.callback) def callback(self, image): self.image = image.image def run(self): try: self.api.start() key = 'a' while (key != 'q'): if self.image is not None: print('running') cv2.imshow('frame', self.image) key = chr(cv2.waitKey(1) & 0xFF) finally: cv2.destroyAllWindows() self.api.stop()