Kinect v1.0:VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV

Hi All:
I am testing YOLOv3 with live video feed from Kinect v1.0. I know YOLO get the video stream by ‘cap = cvCaptureFromCAM(cam_index)’.
When I opened the libfreenect driver, and then run ./darknet detector demo cfg/voc.data cfg/tiny-yolo-voc.cfg tiny-yolo-voc.weights
the error is :VIDEOIO ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV
Couldn’t connect to webcam: No such file or directory

Then I tried the method which is mentioned in ‘https://github.com/opencv/opencv/issues/7974’ and and recompiled opencv. But, it doesn’t work!

It seems I need to convert it to a cv::Mat. Can you help me solve it? Thank you very much!

Assuming you are on a Jetson carrier board with onboard camera as /dev/video0, do you see /dev/video1 appear when you plug the kinect in ? If no, you would have to install a driver for it.

If yes (or once you’ll have installed driver), check which formats are available:

v4l2-ctl -d /dev/video1 --list-formats

Old versions of opencv only expected gray8 or BGR. More recent versions may be able to receive frames in other formats, but you may have to convert for feeding darknet (IIRC, yolo v2 expected 4:3 aspect ratio).

So, if your camera can provide BGR, configure this mode, and cvCaptureFromCam(1) should be ok.

If you camera doesn’t provide BGR, you would have to convert, either in opencv, or you can use a gstreamer pipeline capture if your opencv version has support for it.

Last solution (easy but probably not the most efficient) could also be to make gstreamer conversion pipeline into v42loopback sink with gst-launch, and use the virtual v4l2 source in opencv (https://devtalk.nvidia.com/default/topic/1023416/jetson-tx1/error-building-v4l2loopback/post/5228430/#5228430).