Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV_3.4.3 hangs on VideoCapture. How to resolve?

Built OpenCV-3.4.3 with java bindings. Running on raspberry Pi 3B+ with Stretch and v4l2. OpenCV works fine with a USB camera but not with the onboard MIPI camera. I can capture images and video with raspistill and raspivid using the onboard MIPI camera.

When I try to open the mipi camera with OpenCV using VideoCapture camera = new VideoCapture(0); it hangs on this line. If I replace the 0 with a 1 for the USB camera, it works fine. I suspect that the default pixel format of YUV12 is not compatible so I try to change it to other formats with v4l2-ctl but creating the VideoCapture objects seems to reset the pixel format to YUV12. This is verified with v4l2-ctl -V

Setting the pixel format can't be done in the program with camera.set(CAP_PROP_... because the VideoCapture object needs to exist to do that. Setting before running the program with v4l2-ctl does not work either.

I would try an older version of Rasbien but apparently the Pi ver 3B+ is not compatible with older versions. I posted a similar question to the raspberry pi forum but not much help with this specific issue.

Any suggestions debug or resolve is greatly appreciated. Thanks, Russ

OpenCV_3.4.3 hangs on VideoCapture. How to resolve?

Built OpenCV-3.4.3 with java bindings. Running on raspberry Pi 3B+ with Stretch and v4l2. OpenCV works fine with a USB camera but not with the onboard MIPI camera. I can capture images and video with raspistill and raspivid using the onboard MIPI camera.

When I try to open the mipi camera with OpenCV using VideoCapture camera = new VideoCapture(0); it hangs on this line. If I replace the 0 with a 1 for the USB camera, it works fine. I suspect that the default pixel format of YUV12 is not compatible so I try to change it to other formats with v4l2-ctl but creating the VideoCapture objects seems to reset the pixel format to YUV12. This is verified with v4l2-ctl -V

Setting the pixel format can't be done in the program with camera.set(CAP_PROP_... because the VideoCapture object needs to exist to do that. Setting before running the program with v4l2-ctl does not work either.

I would try an older version of Rasbien but apparently the Pi ver 3B+ is not compatible with older versions. I posted a similar question to the raspberry pi forum but not much help with this specific issue.

Any suggestions debug or resolve is greatly appreciated. Thanks, Russ