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 test_posargs_deprecated(): with warnings.catch_warnings(record=True) as w: camera = PiCamera(0, 'none', False, '720p') assert len(w) == 4 for warning in w: assert issubclass(warning.category, PiCameraDeprecated) assert 'non-keyword argument is deprecated' in str(warning.message)
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]
self.sock.shutdown(1) self.sock.close() def stop(self): self.streaming = False class WebsocketStreamer(Thread): # TODO pass class ByteStreamer(Thread): # TODO pass if __name__=="__main__": from time import sleep from picamerax import PiCamera with PiCamera(resolution='VGA', framerate=30) as camera: sleep(2) streamer = SocketStreamer(camera) streamer.start() try: while True: continue finally: streamer.stop() streamer.join()
from time import sleep from picamerax import PiCamera camera = PiCamera() camera.start_preview() sleep(2) for filename in camera.capture_continuous('img{counter:03d}.jpg'): print('Captured %s' % filename) sleep(300) # wait 5 minutes
from time import sleep from picamerax import PiCamera from datetime import datetime, timedelta def wait(): # Calculate the delay to the start of the next hour next_hour = (datetime.now() + timedelta(hours=1)).replace(minute=0, second=0, microsecond=0) delay = (next_hour - datetime.now()).seconds sleep(delay) camera = PiCamera() camera.start_preview() wait() for filename in camera.capture_continuous('img{timestamp:%Y-%m-%d-%H-%M}.jpg'): print('Captured %s' % filename) wait()
from io import BytesIO from time import sleep from picamerax import PiCamera from PIL import Image # Create the in-memory stream stream = BytesIO() camera = PiCamera() camera.start_preview() sleep(2) camera.capture(stream, format='jpeg') # "Rewind" the stream to the beginning so we can read its content stream.seek(0) image = Image.open(stream)
from time import sleep from picamerax import PiCamera camera = PiCamera() camera.resolution = (1024, 768) camera.start_preview() # Camera warm-up time sleep(2) camera.capture('foo.jpg')
from picamerax import PiCamera from time import sleep from fractions import Fraction # Force sensor mode 3 (the long exposure mode), set # the framerate to 1/6fps, the shutter speed to 6s, # and ISO to 800 (for maximum gain) camera = PiCamera(resolution=(1280, 720), framerate=Fraction(1, 6), sensor_mode=3) camera.shutter_speed = 6000000 camera.iso = 800 # Give the camera a good long time to set gains and # measure AWB (you may wish to use fixed AWB instead) sleep(30) camera.exposure_mode = 'off' # Finally, capture an image with a 6s exposure. Due # to mode switching on the still port, this will take # longer than 6 seconds camera.capture('dark.jpg')
from io import BytesIO from time import sleep from picamerax import PiCamera # Create an in-memory stream my_stream = BytesIO() camera = PiCamera() camera.start_preview() # Camera warm-up time sleep(2) camera.capture(my_stream, 'jpeg')
from time import sleep from picamerax import PiCamera # Explicitly open a new file called my_image.jpg my_file = open('my_image.jpg', 'wb') camera = PiCamera() camera.start_preview() sleep(2) camera.capture(my_file) # At this point my_file.flush() has been called, but the file has # not yet been closed my_file.close()
from time import sleep from picamerax import PiCamera camera = PiCamera() camera.resolution = (1024, 768) camera.start_preview() # Camera warm-up time sleep(2) camera.capture('foo.jpg', resize=(320, 240))
from time import sleep from picamerax import PiCamera camera = PiCamera(resolution=(1280, 720), framerate=30) # Set ISO to the desired value camera.iso = 100 # Wait for the automatic gain control to settle sleep(2) # Now fix the values camera.shutter_speed = camera.exposure_speed camera.exposure_mode = 'off' g = camera.awb_gains camera.awb_mode = 'off' camera.awb_gains = g # Finally, take several photos with the fixed settings camera.capture_sequence(['image%02d.jpg' % i for i in range(10)])
from io import BytesIO from picamerax import PiCamera stream = BytesIO() camera = PiCamera() camera.resolution = (640, 480) camera.start_recording(stream, format='h264', quality=23) camera.wait_recording(15) camera.stop_recording()