Opencv3.3 CSI camera Gstreamer: Can't open device.

Hello,

I’m trying to just open a CSI camera in opencv3.3.

As I can’t manage to get anything I tried from shell with:

gst-launch-1.0 nvcamerasrc fpsRange="30.0 30.0" ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! nvtee ! nvvidconv flip-method=2 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! nvoverlaysink -e

This gave me an image.

I tried to open with:

std::string gst = "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink ";

cv::VideoCapture cap(gst);

I also tried:

std::string gst = "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink ";

cv::VideoCapture cap(gst, CV_CAP_GSTREAMER);

All those fail to open the device.

If I do:
(./test_camera)

cv::VideoCapture cap(0);

This does open the capture but just give me a black frame…
But if I do :

sudo ./test_camera //code is cv::VideoCapture cap(0);

I get :

VIDEOIO ERROR: V4L2:Pixel format of incoming image is unsupported by OpenCV
Unable to stop the stream: Invalid argument

Which is normal as I’m not supposed to be able to open a canera with 0 (or 1) in opencv on my TX1 .

I’m currently out of idea after a day trying nearly everything I can find, if anyone have any idea.

(Note: the camera is a Leopard camera )
(Note2: I can nearly remove all parameters of the command line & still be able to get the camera output on the terminal)

hello Elleryn,

which sensor module you’re working with?
had you saw any failure message while launching the camera sensor?
please also try with nvgstcapture-1.0, is simply camera preview works for you?
thanks

Hello,

Camera module: https://www.leopardimaging.com/uploads/LI-TX1-CB-IMX274M12-T_datasheet.pdf

No failure message, the preview from shell command works smoothly, and opening all the 3 CSI cameras at once also works.

I’ll try with nvgstcapture-1.0 too, can you give me a default pipeline for opencv? to use nvgst instead of gst for the Opencv’s pipeline?

Ok made it work.

Gstreamer-plugins-base1.0-dev was acting strange (i.e. working and then not working).

I had to remove it, remove its dependencies, reinstall everything via .deb files, delete my previous opencv files , re-cmake, rebuild etc.

It finally works