def test_stop_stops_the_video_processor_first(self, mock_video_processor, mock_camera): global stop_time_camera global stop_time_video stop_time_camera = 0 stop_time_video = 0 def stop_camera(): global stop_time_camera stop_time_camera = time.time() time.sleep(0.01) def stop_video(): global stop_time_video stop_time_video = time.time() time.sleep(0.01) cam = mock_camera.return_value cam.shape = [300, 100] cam.stop.side_effect = stop_camera video = mock_video_processor.return_value video.stop.side_effect = stop_video api = ScannerAPI() api.start() api.stop() self.assertTrue(stop_time_video < stop_time_camera, '{} !< {}'.format(stop_time_video, stop_time_camera))
def test_stop_stops_the_camera_and_video_processor(self, mock_video_processor, mock_camera): cam = mock_camera.return_value cam.shape = [300, 100] video = mock_video_processor.return_value api = ScannerAPI() api.start() api.stop() cam.stop.assert_called_once_with() video.stop.assert_called_once_with()
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()
parser.add_argument('-l', '--log', dest='loglevel', action='store', required=False, default="WARNING", help="Enter the loglevel [DEBUG|INFO|WARNING|ERROR] default: WARNING") parser.add_argument('-t', '--console', dest='console', action='store_true', required=False, help="Logs to console not file") parser.add_argument('-m', '--module', dest='mod', action='store', required=False, help='Activate a module (use "list" to get a list of available modules).') args, unknown = parser.parse_known_args() path = os.path.dirname(os.path.realpath(__file__)) import config if not os.path.exists(config.PEACHY_PATH): os.makedirs(config.PEACHY_PATH) setup_logging(args) sys.argv = [sys.argv[0]] if args.mod: sys.argv.append("-m") sys.argv.append(args.mod) scanner = ScannerAPI() scanner.start() try: from gui import PeachyScannerApp PeachyScannerApp(scanner).run() except Exception as ex: import traceback traceback.print_exc() finally: print("Shutting Down Api") scanner.stop() exit()
required=False, help= 'Activate a module (use "list" to get a list of available modules).') args, unknown = parser.parse_known_args() path = os.path.dirname(os.path.realpath(__file__)) import config if not os.path.exists(config.PEACHY_PATH): os.makedirs(config.PEACHY_PATH) setup_logging(args) sys.argv = [sys.argv[0]] if args.mod: sys.argv.append("-m") sys.argv.append(args.mod) scanner = ScannerAPI() scanner.start() try: from gui import PeachyScannerApp PeachyScannerApp(scanner).run() except Exception as ex: import traceback traceback.print_exc() finally: print("Shutting Down Api") scanner.stop() exit()