-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raw capture with resizer is broken #46
Comments
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. |
That seems to work. The size of the output stream is correct, according to your RGB recipe math (320 * 240 * 4=307200.) |
Glad you got something working in the end - I'll try and find some time to look into this, but I doubt it'll be in time to make the release I'm planning for later today |
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. |
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:
The text was updated successfully, but these errors were encountered: