capture.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:remho 作者: teamresistance 项目源码 文件源码
def picamera():
    # Picamera will raise an OSError when importing unless the code is run
    # on an RPI due to firmware dependencies. Make the imports local so we
    # won't have to deal with this nuance when not calling this method.
    import picamera
    import picamera.array

    with picamera.PiCamera() as camera:
        camera.resolution = (640, 480)
        time.sleep(0.1)  # allow the camera time to warm up

        with picamera.array.PiRGBArray(camera, size=(640, 480)) as stream:
            if camera.closed:
                raise CameraInitializationError('Camera failed to open.')

            for frame in camera.capture_continuous(stream, format='bgr', use_video_port=True):
                image = frame.array
                yield image

                # Clear the stream in preparation for the next frame
                stream.truncate(0)


# TODO documentation
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号