Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Raw capture with resizer is broken #46
I'm attempting to write a program that captures a raw stream from the video port and passes it to OpenCV, but the program fails when trying to capture the stream. I know it's possible, because before I switched to using Python, I was using a C++ class that could do this. At least, I think that's what it does.
It's definitely not an OpenCV error, as the program dies before any OpenCV functions are called.
Here's the error:
And the code:
That's weird - raw capture over the video port is included in the test suite, and passes (more or less) happily (there's some issue with 100x100 captures that I don't understand yet). Unfortunately, my camera's currently busy chewing through yet another test for #40 (which is unsurprisingly taking some time to debug and fix - given the random nature of it showing up). Could you possibly test your code without the resizer? Something like the following:
from __future__ import division import picamera import cv2 import numpy as np import io import time class PiCam: def __init__(self): self.cam = picamera.PiCamera() self.cam.resolution = (320, 240) def read(self): stream = open('image.data', 'wb') self.cam.capture(stream, 'bgra', use_video_port=True) stream.seek(0) image = np.fromfile(stream, dtype = np.uint8) return image cam = PiCam() cv2.namedWindow("Camera Image", cv2.WINDOW_AUTOSIZE) while True: cv2.imshow("Camera Image", cam.read()) cv2.waitKey(1) return
In theory it shouldn't make any difference as the raw encoder was changed in 1.0 to use the resizer to handle the conversion from YUV to RGBA/BGRA/etc. (so that we don't have to manipulate the camera's own ports and break video recording, and because the video-splitter doesn't seem to like doing the conversion itself). In other words, all raw captures invoke the resizer but if no resize resolution is given, the resizer is set to the same resolution as the camera itself.
Still, the test suite doesn't actually include a test for raw captures over the video port including a resizer with a different resolution to the camera, so I'm wondering if that's the cause.
Doh! Found the cause of this issue - a stupid error on my part. It's a trivial fix so it'll make it into tonight's release after all. Amended the title as the bug would actually cause any raw capture with a resize parameter (set to something other than the parent's resolution) to fail.