当前位置: 首页>>代码示例>>Python>>正文


Python picamera.PiCamera方法代码示例

本文整理汇总了Python中picamera.PiCamera方法的典型用法代码示例。如果您正苦于以下问题:Python picamera.PiCamera方法的具体用法?Python picamera.PiCamera怎么用?Python picamera.PiCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在picamera的用法示例。


在下文中一共展示了picamera.PiCamera方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, resolution=(320, 240), framerate=32, **kwargs):
		# initialize the camera
		self.camera = PiCamera()

		# set camera parameters
		self.camera.resolution = resolution
		self.camera.framerate = framerate

		# set optional camera parameters (refer to PiCamera docs)
		for (arg, value) in kwargs.items():
			setattr(self.camera, arg, value)

		# initialize the stream
		self.rawCapture = PiRGBArray(self.camera, size=resolution)
		self.stream = self.camera.capture_continuous(self.rawCapture,
			format="bgr", use_video_port=True)

		# initialize the frame and the variable used to indicate
		# if the thread should be stopped
		self.frame = None
		self.stopped = False 
开发者ID:jrosebr1,项目名称:imutils,代码行数:23,代码来源:pivideostream.py

示例2: frames

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def frames():
        with PiCamera() as camera:
            camera.rotation = int(str(os.environ['CAMERA_ROTATION']))
            stream = io.BytesIO()
            for _ in camera.capture_continuous(stream, 'jpeg',
                                               use_video_port=True):
                # return current frame
                stream.seek(0)
                _stream = stream.getvalue()
                data = np.fromstring(_stream, dtype=np.uint8)
                img = cv2.imdecode(data, 1)
                yield img

                # reset stream for next frame
                stream.seek(0)
                stream.truncate() 
开发者ID:cristianpb,项目名称:object-detection,代码行数:18,代码来源:camera_pi.py

示例3: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, resolution=(CAMERA_WIDTH, CAMERA_HEIGHT),
                 framerate=CAMERA_FRAMERATE,
                 rotation=0,
                 hflip=False, vflip=False):
        # initialize the camera and stream
        try:
            self.camera = PiCamera()
        except:
            logging.error("PiCamera Already in Use by Another Process")
            logging.error("Exiting %s Due to Error", progName)
            exit(1)
        self.camera.resolution = resolution
        self.camera.framerate = framerate
        self.camera.hflip = hflip
        self.camera.vflip = vflip
        self.camera.rotation = rotation
        self.rawCapture = PiRGBArray(self.camera, size=resolution)
        self.stream = self.camera.capture_continuous(self.rawCapture,
                                                     format="bgr",
                                                     use_video_port=True)
        # initialize the frame and the variable used to indicate
        # if the thread should be stopped
        self.thread = None   # Initialize thread
        self.frame = None
        self.stopped = False 
开发者ID:pageauc,项目名称:pi-timolo,代码行数:27,代码来源:pi-timolo.py

示例4: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, resolution=(CAMERA_WIDTH, CAMERA_HEIGHT), framerate=CAMERA_FRAMERATE, rotation=0, hflip=False, vflip=False):
        # initialize the camera and stream
        try:
           self.camera = PiCamera()
        except:
           print("ERROR - PiCamera Already in Use by Another Process")
           print("INFO  - Exit %s" % progName)
           quit()
        self.camera.resolution = resolution
        self.camera.framerate = framerate
        self.camera.hflip = hflip
        self.camera.vflip = vflip
        self.camera.rotation = rotation
        self.rawCapture = PiRGBArray(self.camera, size=resolution)
        self.stream = self.camera.capture_continuous(self.rawCapture,
            format="bgr", use_video_port=True)
        # initialize the frame and the variable used to indicate
        # if the thread should be stopped
        self.frame = None
        self.stopped = False 
开发者ID:pageauc,项目名称:pi-timolo,代码行数:22,代码来源:pi-timolo81.py

示例5: takeDayImage

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def takeDayImage(filename, cam_sleep_time):
    # Take a Day image using exp=auto and awb=auto
    with picamera.PiCamera() as camera:
        camera.resolution = (imageWidth, imageHeight)
        camera.framerate = 80
        camera.vflip = imageVFlip
        camera.hflip = imageHFlip
        camera.rotation = imageRotation # Valid values 0, 90, 180, 270
        # Day Automatic Mode
        camera.exposure_mode = 'auto'
        camera.awb_mode = 'auto'
        time.sleep(cam_sleep_time)   # use motion or TL camera sleep to get AWB
        if imagePreview:
            camera.start_preview()
        if imageFormat == ".jpg" :
            camera.capture(filename, use_video_port=useVideoPort, format='jpeg',quality=imageJpegQuality)
        else:
            camera.capture(filename, use_video_port=useVideoPort)
        camera.close()
    logging.info("camSleepSec=%.2f exp=auto awb=auto Size=%ix%i "
              % ( cam_sleep_time, imageWidth, imageHeight ))
    if not showDateOnImage:   # showDateOnImage displays FilePath so avoid showing twice
        logging.info("FilePath  %s" % (filename))

#----------------------------------------------------------------------------------------------- 
开发者ID:pageauc,项目名称:pi-timolo,代码行数:27,代码来源:pi-timolo81.py

示例6: getStreamImage

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def getStreamImage(isDay):
    # Capture an image stream to memory based on daymode
    with picamera.PiCamera() as camera:
        camera.resolution = (testWidth, testHeight)
        with picamera.array.PiRGBArray(camera) as stream:
            if isDay:
                camera.exposure_mode = 'auto'
                camera.awb_mode = 'auto'
                time.sleep(motionCamSleep)   # sleep so camera can get AWB
            else:
                # use variable framerate_range for Low Light motion image stream
                camera.framerate_range = (Fraction(1, 6), Fraction(30, 1))
                time.sleep(2) # Give camera time to measure AWB
                camera.iso = nightMaxISO
            camera.capture(stream, format='rgb', use_video_port=useVideoPort)
            camera.close()
            return stream.array

#----------------------------------------------------------------------------------------------- 
开发者ID:pageauc,项目名称:pi-timolo,代码行数:21,代码来源:pi-timolo81.py

示例7: start

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def start(self):
        with picamera.PiCamera() as camera:
            camera.resolution = (1280, 960)
            camera.framerate = 10

            handler = CaptureHandler(camera, self.post_capture_callback)

            self.__print('Waiting 2 seconds for the camera to warm up')
            time.sleep(2)

            try:
                self.__print('Started recording')
                camera.start_recording(
                    '/dev/null', format='h264',
                    motion_output=MyMotionDetector(camera, handler)
                )

                while True:
                    handler.tick()
                    time.sleep(1)
            finally:
                camera.stop_recording()
                self.__print('Stopped recording') 
开发者ID:citrusbyte,项目名称:pimotion,代码行数:25,代码来源:pimotion.py

示例8: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, resolution=(640, 480), framerate=32, save_image_interval=1):
        '''
        @param save_image_interval, interval in sec to save imave
        '''
        # initialize the camera and stream
        self.camera = PiCamera()
        self.camera.resolution = resolution
        self.camera.framerate = framerate
        self.rawCapture = PiRGBArray(self.camera, size=resolution)
        self.stream = self.camera.capture_continuous(self.rawCapture,
            format="bgr", use_video_port=True)

        # initialize the frame and the variable used to indicate
        # if the thread should be stopped
        self.frame = None
        self.rects = [] # list of matching faces
        self.stopped = False 
开发者ID:llSourcell,项目名称:hardware_demo,代码行数:19,代码来源:mypivideostream.py

示例9: create_capture_device

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def create_capture_device(self):
        if self.data.settings['capture']['TYPE']['value'] != 'usb':
            if self.use_capture:
                if self.piCapture_with_no_source():
                    return False
                self.update_capture_settings()
                
                try:
                    self.device = picamera.PiCamera(resolution=self.resolution, framerate=self.framerate, sensor_mode = self.sensor_mode)
                    return True
                except picamera.exc.PiCameraError as e:
                    self.use_capture = False
                    self.data.settings['capture']['DEVICE']['value'] = 'disabled'
                    print('camera exception is {}'.format(e))
                    self.message_handler.set_message('INFO', 'no capture device attached')
                    return False 
开发者ID:langolierz,项目名称:r_e_c_u_r,代码行数:18,代码来源:capture.py

示例10: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, photo_size, gif_size, motion_size, camera_vflip,
            camera_hflip, camera_capture_length, motion_detection_threshold,
            camera_mode):
        self.photo_size = photo_size
        self.gif_size = gif_size
        self.camera_vflip = camera_vflip
        self.camera_hflip = camera_hflip
        self.lock = Lock()
        self.queue = Queue()
        self.motion_framerate = 5
        self.motion_size = motion_size
        self.motion_detection_threshold = motion_detection_threshold
        self.temp_directory = '/var/tmp'
        self.camera_save_path = '/var/tmp'
        self.camera_capture_length = camera_capture_length
        self.camera_mode = camera_mode
        self.motion_detection_running = False
        self.too_dark_message_printed = False

        try:
            self.camera = PiCamera()
            self.camera.vflip = self.camera_vflip
            self.camera.hflip = self.camera_hflip
        except Exception as e:
            exit_error('Camera module failed to intialise with error {0}'.format(repr(e))) 
开发者ID:FutureSharks,项目名称:rpi-security,代码行数:27,代码来源:rpis_camera.py

示例11: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, res_width=96, res_height=96):
        self.camera = picamera.PiCamera(resolution=(res_width, res_height))
        # TODO propagate configurable resolution through '96' logic below

        self.camera.hflip = True
        self.camera.vflip = True
        self.res_width = res_width
        self.res_height = res_height
        self.stream = picamera.array.PiYUVArray(self.camera)
        self.pixelObjList = []
        self.object_id_center = 0
        self.pixelObjList.append(PixelObject(self.next_obj_id()))
        self.max_pixel_count = 0
        self.largest_object_id = 0
        self.largest_X = 0
        self.largest_Y = 0
        self.filename = '' 
开发者ID:aws-samples,项目名称:aws-greengrass-mini-fulfillment,代码行数:19,代码来源:image_processor.py

示例12: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, cam_type):
        self.cam_width = res_width
        self.cam_height = res_height
        self.camera_type = cam_type
        self.camera = None
        self.rawCapture = None

        if cam_type == "camerapi":
            log.info("Loading Camera Pi")
            self.camera = PiCamera()
            self.camera.resolution = (self.cam_width, self.cam_height)

        elif cam_type == "usb":
            camera_id = 0
            log.info("Loading USB Camera id {}".format(camera_id))
            self.camera = cv2.VideoCapture(camera_id)
            self.camera.set(cv2.CAP_PROP_FPS, 30)
            self.camera.set(cv2.CAP_PROP_FRAME_WIDTH, self.cam_width)
            self.camera.set(cv2.CAP_PROP_FRAME_HEIGHT, self.cam_height)

        log.info("Camera size {}x{}".format(self.cam_width, self.cam_height)) 
开发者ID:movidius,项目名称:ncappzoo,代码行数:23,代码来源:video_cam.py

示例13: serve_forever

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def serve_forever(self):
        # seed the random number generator from the system clock
        random.seed()
        logging.info('Initializing camera')
        self.server.seqno = 0
        self.server.client_address = None
        self.server.client_timestamp = None
        self.server.responders = {}
        self.server.files = []
        self.server.camera = picamera.PiCamera()
        try:
            logging.info('Starting server thread')
            thread = threading.Thread(target=self.server.serve_forever)
            thread.start()
            while thread.is_alive():
                thread.join(1)
            logging.info('Server thread ended')
        finally:
            logging.info('Closing camera')
            self.server.camera.close() 
开发者ID:waveform-computing,项目名称:compoundpi,代码行数:22,代码来源:server.py

示例14: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def __init__(self, resolution=(320, 240), framerate=24, vflip=True, hflip=True):
        self.camera = PiCamera()
        self.camera.resolution = resolution
        self.camera.framerate = framerate
        self.camera.vflip = vflip
        self.camera.hflip = hflip
        self.camera.rotation = 270

        self.data_container = PiRGBArray(self.camera, size=resolution)

        self.stream = self.camera.capture_continuous(
            self.data_container, format="bgr", use_video_port=True
        )

        self.frame = None
        self.stopped = False
        print('starting camera preview')
        self.camera.start_preview() 
开发者ID:leigh-johnson,项目名称:rpi-vision,代码行数:20,代码来源:capture.py

示例15: setupRpiCam

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import PiCamera [as 别名]
def setupRpiCam(self):
        # import the necessary packages
        from picamera.array import PiRGBArray
        from picamera import PiCamera
        
        # initialize the camera and grab a reference to the raw camera capture
        camera = PiCamera()
        camera.resolution = (self.width, self.height)
        camera.framerate = self.fps
        camera.crop = (0.0, 0.0, 1.0, 1.0)
        self.camera = camera
        self.rawCapture = PiRGBArray(camera, size=(self.width, self.height))
        self.rgb = bytearray(self.width * self.height * 3)
        self.yuv = bytearray(self.width * self.height * 3 / 2)
        
        # wait for camera to warm up
        time.sleep(0.1) 
开发者ID:tobykurien,项目名称:pi-tracking-telescope,代码行数:19,代码来源:camera.py


注:本文中的picamera.PiCamera方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。