示例#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 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')