onboard camera issue on TX2

if I change define

VideoCapture cap(“nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink”);

to

VideoCapture cap(0);

the camera can open, but can’t see anything(blackscreen).

I also try cheese, It’s blackscreen too.

python2.7 opencv3.2

VideoCapture cap(0) uses V4L interface with video device in /dev/video0.

The problem is that onboard camera only works with 10 bits modes, and this would give bayer frames, while opencv expects 8 bits BGR. You may check: [url]https://devtalk.nvidia.com/default/topic/1028611/jetson-tx2/is-there-a-parameter-for-enable-disable-the-tx2-on-board-camera-/post/5232247/#5232247[/url].
With nvcamerasrc, debayering (and more) is done with the ISP.

If you have USB camera, it should be /dev/video1 and you may be able to use VideoCapture cap(1) for it.

the camera can be converted to the type of USB camera via the video loopback module

Hi Andrey,

May you please give more details ? I’ve installed v4l2loopback, I’m able to create a virtual /dev/video1, but I’m not able to use it with gstreamer v4l2src plugin.

Thanks for sharing the steps you use.

Hi Honey_Patouceul
Thank you for your question.

1.$ sudo su
2.$ cd /usr/src/linux-headers-4.4.38-tegra
3.$ make modules_prepare
4.$ mkdir v4l2loopback
5.$ cd v4l2loopback
6.$ git clone https://github.com/umlaeute/v4l2loopback.git
7.$ cd v4l2loopback
8.$ make
9.$ make install
10.$ modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1
11.$ echo options v4l2loopback devices=1 video_nr=2 exclusive_caps=1 > /etc/modprobe.d/v4l2loopback.conf
12.$ echo v4l2loopback > /etc/modules
13.$ update-initramfs -u
14.$ gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvvidconv ! 'video/x-raw, format=(string)I420, framerate=(fraction)30/1' ! tee ! v4l2sink device=/dev/video2

Steps 11,12,13 apply the module load permanently while the step 10 loads the module until next reboot.
However, now it mpi camera stream is rolling under /dev/video2 as if generated by a usb camera. In my case I am able to use Internet browser web video chat with executing in a new terminal:

1. $ export DISPLAY=:0
2. $ chromium-browser

May be if you apply the step 14 you will be able to access the stream somehow.
However, my experience is bounded with “in-browser use for web-video-chat purpose”.

But I assume that video is streamed under /dev/video2 as a normal usb camera generated stream and can be accessed using “VideoCapture cap(2);” , and unless “gstreamer v4l2src plugin” conflicts with “gst-launch-1.0” being running simultaneously, it possibly can be used, somehow.

Could you define how do you call /dev/video1 with the gstreamer v4l2src plugin ?

Hi Andrey,

I am unable to use v4l2src plugin, but indeed I made this pipeline

gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvvidconv ! 'video/x-raw, format=(string)BGRx, framerate=(fraction)30/1' ! videoconvert ! 'video/x-raw,format=BGR' ! v4l2sink device=/dev/video2

and then Opencv works with cv::VideoCapture cap(2);

Thanks a lot for sharing.

you may find some other useful tricks at jetson use cases