My intension is to use raspberry Pi for tracking coloured object. I am using Python, OpenCV and Raspberry pi Camera Module.
Since OpenCV doesn’t work out of the Box with raspberryPi cam Module, I trying to use Mikerr’s PiVision Lib (https://github.com/mikerr/piVision/blob/master/colortrack.py)
In Mikerr’s lib he saves the image to disk and opens it with OpenCV to get the frame object which can be used for further processing i.e.
frame=cv.LoadImage(imagefile,cv.CV_LOAD_IMAGE_COLOR)
Dave Jones’ (author of python-picamera) has already written a lib to use the Picamera with Python and he has briefly explained it to use with OpenCV(http://picamera.readthedocs.org/en/release-1.6/recipes1.html#capturing-to-an-opencv-object).
So I want to retrieve the frame from Dave Jones’ lib and input it to Mikerr’s Lib like this
with picamera.Picamera() as camera:
camera.resolution = (640, 480)
camera.framerate = 24
stream = io.BytesIO()
while True:
camera.capture(stream, format="jpeg", use_video_port=True)
frame = np.fromstring(stream.getvalue(), dtype=np.uint8)
stream.seek(0)
frame = cv2.imdecode(frame, 1)
Do you this this is possible and will the frame I get both the code above be same (in terms of datatype)
Please can someone through some light on it? Also what type of Import we should use i.e. import cv2.cv as cv or import cv or import cv2