def run_birbcam(): setproctitle("birbcam") config = BirbConfig() if not config.logFile is None: logging.basicConfig(level=logging.INFO, filename=config.logFile, format='%(levelname)s: %(message)s') else: logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') logging.info(f"Saving output to: {config.saveTo}") if config.noCaptureMode: logging.info("Using No Capture Mode") if config.debugMode: logging.info("Using Debug Mode") camera = PiCamera() camera.resolution = previewResolution camera.framerate = 30; camera.iso = 200 rawCapture = PiRGBArray(camera, size=previewResolution) """ shading = lensshading.get_lens_shading(args.get("lensshading")) if shading != None: shading = shading.astype("uint8") print(np.shape(shading)) camera.lens_shading_table = shading """ camera.exposure_mode = 'auto' camera.awb_mode = 'auto' camera.meter_mode = 'spot' sleep(2) camera.shutter_speed = camera.exposure_speed # ************************************** # Focus assist # ************************************** focusAssist = FocusAssist() if focusAssist.run(camera) == False: sys.exit() # ************************************** # Set mask # ************************************** imageMask = ImageMask() if imageMask.run(camera) == False: sys.exit() mask = imageMask.mask # ************************************** # Capture loop # ************************************** watcher = BirbWatcher(config) watcher.run(camera, mask)
def start_camera(original_config, skip_auto=False, skip_button_listen=False): global camera global overlay global config # Force variables to be blanked camera = None overlay = None config = original_config # Config Variables screen_fps = config["screen_fps"] capture_timeout = config["capture_timeout"] screen_w = config["screen_w"] screen_h = config["screen_h"] width = config["width"] height = config["height"] # Init # https://github.com/waveform80/picamera/issues/329 PiCamera.CAPTURE_TIMEOUT = capture_timeout print(f'Camera Timeout: {PiCamera.CAPTURE_TIMEOUT}') camera = PiCamera( ) # framerate=fps is bugged - rather set camera.framerate if skip_auto == False: auto_mode(camera, overlay, config) overlay = None camera.resolution = (screen_w, screen_h) camera.framerate = screen_fps # fps overlay = overlay_handler.add_overlay(camera, overlay, config) overlay_handler.display_text(camera, '', config) print(f'screen: ({screen_w}, {screen_h}), res: ({width}, {height})') if skip_button_listen == False: start_button_listen(config) start_preview(camera, config) return [camera, overlay]