Skip to content
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

picamera.array bytes_to_rgb(data, resolution) is broken when splitter is in use (typo) #321

reillyardstard opened this issue Sep 4, 2016 · 1 comment


Copy link

reillyardstard commented Sep 4, 2016

typo in the assignment when a splitter is in use (line 110):

    fwidth, fheith = raw_resolution(resolution, splitter=True)
def bytes_to_rgb(data, resolution):
    Converts a bytes objects containing RGB/BGR data to a `numpy`_ array.
    width, height = resolution
    fwidth, fheight = raw_resolution(resolution)
    # Workaround: output from the video splitter is rounded to 16x16 instead
    # of 32x16 (but only for RGB, and only when a resizer is not used)
    if len(data) != (fwidth * fheight * 3):
        fwidth, fheith = raw_resolution(resolution, splitter=True)
        if len(data) != (fwidth * fheight * 3):
            raise PiCameraValueError(
                'Incorrect buffer length for resolution %dx%d' % (width, height))
    # Crop to the actual resolution
    return np.frombuffer(data, dtype=np.uint8).\
            reshape((fheight, fwidth, 3))[:height, :width, :]
Copy link

Doh, yup - that's a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants