- added
git-svn-id: http://moon:8086/svn/software/trunk/projects/opencv@310 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
Executable
+54
@@ -0,0 +1,54 @@
|
||||
# import the necessary packages
|
||||
from __future__ import print_function
|
||||
from imutils.video import FPS
|
||||
from picamera import PiCamera
|
||||
from picamera import CircularIO
|
||||
import imutils
|
||||
import time
|
||||
import cv2
|
||||
|
||||
class MyCameraIo(object):
|
||||
def __init__(self, frameSize):
|
||||
print("MyCameraIo")
|
||||
self.frameSize = frameSize[0]*frameSize[1]
|
||||
self.size = 0
|
||||
self.frames = 0
|
||||
self.fps = None
|
||||
|
||||
def writable(self):
|
||||
return True
|
||||
|
||||
def write(self, data):
|
||||
if self.size == 0:
|
||||
self.fps = FPS().start()
|
||||
|
||||
self.size += len(data)
|
||||
self.frames += len(data)/(3*self.frameSize)
|
||||
|
||||
def size(self):
|
||||
print("size")
|
||||
return self.size
|
||||
|
||||
def flush(self):
|
||||
if self.size > 0:
|
||||
self.fps.stop()
|
||||
print("Recorded " + str(self.frames) + " frames (" + str(self.size) + " bytes)")
|
||||
print("FPS = " + str(self.frames/self.fps.elapsed()))
|
||||
|
||||
|
||||
# initialize the camera and stream
|
||||
camera = PiCamera()
|
||||
camera.resolution = (320, 240)
|
||||
camera.framerate = 90
|
||||
|
||||
myCameraIo = MyCameraIo(camera.resolution)
|
||||
camera.start_recording(myCameraIo, format="bgr")
|
||||
|
||||
# allow the camera to warmup and start the FPS counter
|
||||
print("[INFO] sampling frames from `picamera` module...")
|
||||
time.sleep(10.0)
|
||||
|
||||
# do a bit of cleanup
|
||||
cv2.destroyAllWindows()
|
||||
camera.close()
|
||||
|
||||
Reference in New Issue
Block a user