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


Python picamera.array方法代码示例

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


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

示例1: getStreamImage

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [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

示例2: take_bracket_pictures

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def take_bracket_pictures(self):
	""" 
	Returns two images in a list
	One with normal exposure, and one with 2 stop longer exposure 
	The aim to to get detail out of shadows/underexposed film
	Resulting images can be combined on a PC with Hugin's enfuse utility
	"""
	old_shutter = self.shutter_speed
	imgs = []
	with picamera.array.PiRGBArray(self) as output:
	    self.capture(output, format='bgr')
	    imgs.append( output.array )
	    self.shutter_speed = old_shutter*4
	    output.truncate(0)
	    self.capture(output, format='bgr')
	    imgs.append( output.array )
	self.shutter_speed = old_shutter
	return imgs 
开发者ID:Alexamder,项目名称:rpitelecine,代码行数:20,代码来源:camera.py

示例3: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [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

示例4: __iter__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def __iter__(self):
        """
        Iterate thought consecutive frames of this camera.

        :return: the time (in ms) and a frame (numpy array).
        :rtype: (int, :class:`~numpy.ndarray`)
        """
        at_least_one_frame = False
        while True:
            if self.is_last_frame() or not self.is_opened():
                if not at_least_one_frame:
                    raise EthoscopeException("Camera could not read the first frame")
                break
            t,out = self._next_time_image()
            if out is None:
                break
            t_ms = int(1000*t)
            at_least_one_frame = True

            if (self._frame_idx % self._drop_each) == 0:
                yield t_ms,out

            if self._max_duration is not None and t > self._max_duration:
                break 
开发者ID:gilestrolab,项目名称:ethoscope,代码行数:26,代码来源:cameras.py

示例5: colorFindSet

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def colorFindSet(self,invarH, invarS, invarV):#1
		global colorUpper, colorLower
		HUE_1 = invarH+11
		HUE_2 = invarH-11
		if HUE_1>255:HUE_1=255
		if HUE_2<0:HUE_2=0

		SAT_1 = invarS+170
		SAT_2 = invarS-20
		if SAT_1>255:SAT_1=255
		if SAT_2<0:SAT_2=0

		VAL_1 = invarV+170
		VAL_2 = invarV-20
		if VAL_1>255:VAL_1=255
		if VAL_2<0:VAL_2=0

		colorUpper = np.array([HUE_1, SAT_1, VAL_1])
		colorLower = np.array([HUE_2, SAT_2, VAL_2])
		print('HSV_1:%d %d %d'%(HUE_1, SAT_1, VAL_1))
		print('HSV_2:%d %d %d'%(HUE_2, SAT_2, VAL_2)) 
开发者ID:adeept,项目名称:Adeept_RaspTank,代码行数:23,代码来源:FPVtest.py

示例6: save_image

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def save_image(self, image, timestamp):
        """
        Save image to disk
        :param image: numpy array image
        :param timestamp: formatted timestamp string
        :return: filename
        """
        if self.checkStorage() < 99:
            filename = timestamp
            filename = filename + ".jpg"
            self.logger.debug('FileSaver: saving file')
            try:
                cv2.imwrite(os.path.join(self.config["photos_path"], filename), image)
                self.logger.info("FileSaver: saved file to " + os.path.join(self.config["photos_path"], filename))
                return filename
            except Exception as e:
                self.logger.error('FileSaver: save_photo() error: ')
                self.logger.exception(e)
                pass
        else:
            self.logger.error('FileSaver: not enough space to save image')
            return None 
开发者ID:interactionresearchstudio,项目名称:NaturewatchCameraServer,代码行数:24,代码来源:FileSaver.py

示例7: __init__

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def __init__(self):
        self.camera = picamera.PiCamera()
        self.camera.vflip = True
        self.camera.hflip = True
        #self.camera.resolution = (320, 160)
        self.camera.start_preview()
        sleep(5)
        self.stream = picamera.array.PiYUVArray(self.camera) 
开发者ID:yazeedalrubyli,项目名称:SDRC,代码行数:10,代码来源:drive.py

示例8: capture

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def capture(self):
        self.camera.capture(self.stream, format='yuv')
        img = self.stream.array[270:,:,0]
        self.stream.seek(0)
        self.stream.truncate()
        return img 
开发者ID:yazeedalrubyli,项目名称:SDRC,代码行数:8,代码来源:drive.py

示例9: update

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def update(self):
        # keep looping infinitely until the thread is stopped
        for f in self.stream:
            # grab the frame from the stream and clear the stream in
            # preparation for the next frame
            self.frame = f.array
            self.rawCapture.truncate(0)

            # if the thread indicator variable is set, stop the thread
            # and resource camera resources
            if self.stopped:
                self.stream.close()
                self.rawCapture.close()
                self.camera.close()
                return 
开发者ID:pageauc,项目名称:pi-timolo,代码行数:17,代码来源:pi-timolo81.py

示例10: read

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def read(self):
        """
        Extracts frames synchronously from monitored deque, while maintaining a fixed-length frame buffer in the memory, 
        and blocks the thread if the deque is full.

        **Returns:** A n-dimensional numpy array. 
        """
        # check if there are any thread exceptions
        if not (self.__exceptions is None):
            if isinstance(self.__exceptions, bool):
                # clear frame
                self.frame = None
                # notify user about hardware failure
                raise SystemError(
                    "[PiGear:ERROR] :: Hardware failure occurred, Kindly reconnect Camera Module and restart your Pi!"
                )
            else:
                # clear frame
                self.frame = None
                # re-raise error for debugging
                error_msg = "[PiGear:ERROR] :: Camera Module API failure occured: {}".format(
                    self.__exceptions[1]
                )
                raise RuntimeError(error_msg).with_traceback(self.__exceptions[2])

        # return the frame
        return self.frame 
开发者ID:abhiTronix,项目名称:vidgear,代码行数:29,代码来源:pigear.py

示例11: take_picture

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def take_picture(self):
        """ 
        Returns an openCV compatible colour image 
        """
        with picamera.array.PiRGBArray(self) as output:
            self.capture(output, format='bgr')
            return output.array 
开发者ID:Alexamder,项目名称:rpitelecine,代码行数:9,代码来源:camera.py

示例12: capture_frame

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def capture_frame(self):
        self.stream = picamera.array.PiYUVArray(self.camera)
        self.camera.capture(self.stream, 'yuv')
        self.camera._set_led(True)

        self.pixelObjList = []
        self.object_id_center = 0
        self.pixelObjList.append(PixelObject(self.next_obj_id()))

        rows = []
        for _ in range(self.res_height):
            rows.append(range(self.res_width))

        # flip image horizontally
        for j, j_ in enumerate(range(self.res_width-1, -1, -1)):
            # now flip vertically
            for i, i_ in enumerate(range(self.res_height-1, -1, -1)):
                rows[j][i] = self.stream.array[j_][i_][0]

        self.filename = self.save_PNG('raw.png', rows)
        self.spread_white_pixels(
            self.make_black_and_white(
                self.fuse_horizontal_and_vertical(
                    self.get_horizontal_edges(rows),
                    self.get_vertical_edges(rows)))
        ) 
开发者ID:aws-samples,项目名称:aws-greengrass-mini-fulfillment,代码行数:28,代码来源:image_processor.py

示例13: flush

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def flush(self):
        # looping until self.stopped flag is flipped
        # for now, grab the first frame in buffer, then empty buffer
        for f in self.stream:
            self.frame = f.array
            self.data_container.truncate(0)

            if self.stopped:
                self.stream.close()
                self.data_container.close()
                self.camera.close()
                return 
开发者ID:leigh-johnson,项目名称:rpi-deep-pantilt,代码行数:14,代码来源:camera.py

示例14: run

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def run(self):
        while not self.is_stopped():
            try:
                if picamera_exists:
                    try:
                        # Get image from Pi camera
                        self.picamera_md_output.truncate(0)
                        self.picamera_md_output.seek(0)
                        self.picamera_md_stream.__next__()
                        self.image = self.picamera_md_output.array
                        if self.image is None:
                            self.logger.warning("CameraController: got empty image.")
                        time.sleep(0.01)
                    except Exception as e:
                        self.logger.error("CameraController: picamera update error.")
                        self.logger.exception(e)
                        self.initialise_picamera()
                        time.sleep(0.02)

                else:
                    # Get image from webcam
                    if self.use_splitter_port:
                        ret, self.splitter_image = self.capture.read()
                        if self.splitter_image is not None:
                            self.image = imutils.resize(self.splitter_image, width=self.width, height=self.height)
                    else:
                        ret, self.image = self.capture.read()

                    if self.image is None:
                        self.logger.warning("CameraController: got empty image.")

            except KeyboardInterrupt:
                self.logger.info("CameraController: received KeyboardInterrupt,  shutting down ...")
                self.stop()

    # Stop thread 
开发者ID:interactionresearchstudio,项目名称:NaturewatchCameraServer,代码行数:38,代码来源:CameraController.py

示例15: decimate_to

# 需要导入模块: import picamera [as 别名]
# 或者: from picamera import array [as 别名]
def decimate_to(shape, image):
    """Decimate an image to reduce its size if it's too big."""
    decimation = np.max(np.ceil(np.array(image.shape, dtype=np.float)[:len(shape)]/np.array(shape)))
    return image[::int(decimation), ::int(decimation), ...] 
开发者ID:rwb27,项目名称:openflexure_microscope_software,代码行数:6,代码来源:microscope.py


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