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


Python array.PiRGBArray方法代码示例

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


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

示例1: __init__

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

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

示例3: __init__

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

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

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

示例6: __init__

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

示例7: __init__

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

示例8: __init__

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def __init__(self):
        # Using OpenCV to capture from device 0. If you have trouble capturing
        # from a webcam, comment the line below out and use a video file
        # instead.
        #self.video = cv2.VideoCapture(0)
        self.camera = PiCamera()
        #self.rawCapture = PiRGBArray(self.camera)
        self.camera.resolution = (640, 480)
        self.camera.framerate = 32
        self.rawCapture = PiRGBArray(self.camera, size=(640, 480))
 
        
        # allow the camera to warmup
        time.sleep(0.1)

        # If you decide to use video.mp4, you must have this file in the folder
        # as the main.py.
        # self.video = cv2.VideoCapture('video.mp4') 
开发者ID:tobykurien,项目名称:pi-tracking-telescope,代码行数:20,代码来源:camera.py

示例9: capture_image

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def capture_image(self):
        # check camera is initialised
        self.init_camera()

        # use webcam
        if self.camera_type == 0:
            success_flag, image=self.camera.read()
            return image

        # use rpi camera
        if self.camera_type == 1:
            image_array = PiRGBArray(self.camera)
            self.camera.capture(image_array, format="bgr")
            image = image_array.array
            return image

    # open_video_writer - begin writing to video file 
开发者ID:rmackay9,项目名称:ardupilot-balloon-finder,代码行数:19,代码来源:balloon_video.py

示例10: CaptureContinous

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def CaptureContinous(self):
    detector = Detector()
    with PiCamera() as camera:
        camera.resolution = (1280, 960)  # twice height and widht
        camera.rotation = int(str(os.environ['CAMERA_ROTATION']))
        camera.framerate = 10
        with PiRGBArray(camera, size=(WIDTH, HEIGHT)) as output:
            camera.capture(output, 'bgr', resize=(WIDTH, HEIGHT))
            image = output.array
            result = detector.prediction(image)
            df = detector.filter_prediction(result, image)
            if len(df) > 0:
                if (df['class_name']
                        .str
                        .contains('person|bird|cat|wine glass|cup|sandwich')
                        .any()):
                    day = datetime.now().strftime("%Y%m%d")
                    directory = os.path.join(IMAGE_FOLDER, 'pi', day)
                    if not os.path.exists(directory):
                        os.makedirs(directory)
                    image = detector.draw_boxes(image, df)
                    classes = df['class_name'].unique().tolist()
                    hour = datetime.now().strftime("%H%M%S")
                    filename_output = os.path.join(
                            directory,
                            "{}_{}_.jpg".format(hour, "-".join(classes))
                            )
                    cv2.imwrite(filename_output, image) 
开发者ID:cristianpb,项目名称:object-detection,代码行数:30,代码来源:camera_pi.py

示例11: ObjectTracking

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def ObjectTracking(self):
    detector = Detector()
    myiter = glob.iglob(os.path.join(IMAGE_FOLDER, '**', '*.jpg'),
                        recursive=True)
    newdict = reduce(lambda a, b: reduce_tracking(a,b), myiter, dict())
    startID = max(map(int, newdict.keys()), default=0) + 1
    ct = CentroidTracker(startID=startID)
    with PiCamera() as camera:
        camera.resolution = (1280, 960)  # twice height and widht
        camera.rotation = int(str(os.environ['CAMERA_ROTATION']))
        camera.framerate = 10
        with PiRGBArray(camera, size=(WIDTH, HEIGHT)) as output:
            while True:
                camera.capture(output, 'bgr', resize=(WIDTH, HEIGHT))
                img = output.array
                result = detector.prediction(img)
                df = detector.filter_prediction(result, img)
                img = detector.draw_boxes(img, df)
                boxes = df[['x1', 'y1', 'x2', 'y2']].values
                previous_object_ID = ct.nextObjectID
                objects = ct.update(boxes)
                if len(boxes) > 0 and (df['class_name'].str.contains('person').any()) and previous_object_ID in list(objects.keys()):
                    for (objectID, centroid) in objects.items():
                        text = "ID {}".format(objectID)
                        cv2.putText(img, text, (centroid[0] - 10, centroid[1] - 10),
                                cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
                        cv2.circle(img, (centroid[0], centroid[1]), 4, (0, 255, 0), -1)

                    day = datetime.now().strftime("%Y%m%d")
                    directory = os.path.join(IMAGE_FOLDER, 'pi', day)
                    if not os.path.exists(directory):
                        os.makedirs(directory)
                    ids = "-".join(list([str(i) for i in objects.keys()]))
                    hour = datetime.now().strftime("%H%M%S")
                    filename_output = os.path.join(
                            directory, "{}_person_{}_.jpg".format(hour, ids)
                            )
                    cv2.imwrite(filename_output, img)
                time.sleep(0.300) 
开发者ID:cristianpb,项目名称:object-detection,代码行数:41,代码来源:camera_pi.py

示例12: __init__

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def __init__(self, resolution=(CAMERA_WIDTH, CAMERA_HEIGHT), framerate=CAMERA_FRAMERATE, rotation=0, hflip=False, vflip=False):
        # initialize the camera and stream
        self.camera = PiCamera()
        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,代码行数:17,代码来源:pi-timolo.py

示例13: capture_image

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def capture_image(self, usingPiCamera=IS_RASPBERRY_PI):
        if usingPiCamera:
            from picamera.array import PiRGBArray
            from picamera import PiCamera

            with PiCamera() as camera:
                rawCapture = PiRGBArray(camera)

                # allow the camera to warmup
                time.sleep(0.1)

                # grab an image from the camera
                camera.capture(rawCapture, format="rgb")
                image = rawCapture.array
                image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
                return image
        else:
            # Number of frames to throw away while the camera adjusts to light levels
            ramp_frames = 1

            self.camera = cv2.VideoCapture(CAMERA_PORT)
            _, im = self.camera.read()
            [self.camera.read() for _ in range(ramp_frames)]
            # print("Taking image...")
            _, camera_capture = self.camera.read()
            del self.camera
            return camera_capture 
开发者ID:CT83,项目名称:Facial-Recognition-Attendance-System,代码行数:29,代码来源:Camera.py

示例14: __init__

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def __init__(self, resolution=(320, 240), framerate=32):
        # initialize the camera and stream
        self.camera = PiCamera()
        self.camera.resolution = resolution
        self.camera.framerate = framerate
        self.camera.vflip = True
        self.camera.hflip = True
        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:tlkh,项目名称:SmartBin,代码行数:16,代码来源:camera.py

示例15: __init__

# 需要导入模块: from picamera import array [as 别名]
# 或者: from picamera.array import PiRGBArray [as 别名]
def __init__(self, resolution=(320, 240), framerate=32, rotation=0):
		# initialize the camera and stream
		self.camera = PiCamera()
		self.camera.resolution = resolution
		self.camera.framerate = framerate
		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:nischi,项目名称:MMM-Face-Reco-DNN,代码行数:16,代码来源:picam.py


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