Skip to content

16-bit images captured by UVC cameras + V4L are returned as a flattened array #27166

@jveitchmichaelis

Description

@jveitchmichaelis

System Information

An example system is Raspberry Pi OS (64-bit) Bookworm 2024-11-19 running on a raspberry pi 4 with OpenCV 4.11. I don't have a detailed package list from the user at this point.

As far as we are aware, the issue is limited to code that uses the V4L backend for image capture.

Detailed description

I support an open source library for thermal cameras. We use OpenCV for the capture backend and have done for many years. Recently some users have reported issues where cameras recording 16-bit images (so far only reported using the V4L backend) are returning flattened arrays rather than 2D "image" arrays. We're not sure exactly where this regression has entered.

One user suggested this PR, but I'm not sure I see why that would cause the error we're seeing (where does the reshape stage happen?): https://github.com/opencv/opencv/pull/18498/files

For example 4.11 seems to fail for some people, while 4.9 reportedly works.

Downgrading from opencv-python 4.11 to 4.9.0.80 and downgrading numpy 1.26.4 seems to have done the trick!

Capturing from the camera in 8-bit modes is also reported to be fine, and the 16-bit data is clearly being returned as it can be reshaped into a usable image. For whatever reason the shape is getting lost.

Unfortunately I don't have a camera available to bisect, but my guess is the 16-bit branch of the code doesn't change particularly often so we can probably figure it out. I actually contributed some 16-bit support a long time ago, but I'm less familiar with the current state.

Steps to reproduce

If there's any more info I can provide, please let me know. For example specific function calls we can ask users to test, but the library code is a very standard VideoCapture + read.

The setup code is here, where we set the FOURCC etc. https://github.com/LJMUAstroecology/flirpy/blob/49179b31ed36e83821de18f3f56e0c1e84b01477/src/flirpy/camera/boson.py#L442

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions