コード例 #1
0
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)
コード例 #2
0
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)])