errors to enable TX1 on-board camera in opencv

I use Nsight Eclipse Edition with opencv to run target tracking programs.
The problem is that I cannot enable the on-board camera, while the pipeline example has been successful, like “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 flip-method=2 ! ‘video/x-raw(memory:NVMM),format=(string)I420’ ! nvoverlaysink -e”.
but the program get the error like:[b]GStreamer: Error opening bin: no element “nvcamerasrc”
The opencv proogram is :
int main()
VideoCapture cap(" nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480,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");
if (!cap.isOpened())
printf(“camera did not open\n”);
return -1;
Mat frame;
cap >> frame;
imshow(“original”, frame);
return 0;

BTW: I use opencv 3.1.0, and flash my TX1 with JetPack 2.3.1(without opencv)

You may check this post:

I resolved the problem! My problem is created by the gstreamer-1.0. I fix it ,then the program work well. No need to add the gstreamer in the “include path” or “library”.

Hello, I am experiencing the exact same issue and have been trying to fix it for a while now. Would you be able to explain how you fixed gstreamer-1.0? I can also run it perfectly from a terminal, but when I try to open the video stream in opencv it fails saying:

GStreamer: Error opening bin: no element "nvcamerasrc"

I figured out what was wrong. I built opencv using the following configuration (the green coloured text should just be normal):

cmake \
     -DCMAKE_BUILD_TYPE=Release \
     -DBUILD_opencv_java=OFF \
     -DBUILD_opencv_python2=ON \
     -DBUILD_opencv_python3=OFF \
     -DWITH_GTK=ON \
     -DWITH_TBB=ON \
     -DWITH_1394=OFF \
     -D WITH_LIBV4L=ON \
     -D WITH_V4L=OFF \
     -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \
     -DCUDA_ARCH_BIN=5.3 \
     -DCUDA_ARCH_PTX="" \
     -DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \

Then I built the library on the TX1 using

make -j4


make install

. I also had to apply a couple of cherry picks to my local git repo when I was getting the opencv source code version 3.1.0. I followed the installation process at for the most part (replace their cmake config command with the one above and it should work). Also, during the configuration step, make sure that all the libraries related to gstreamer are FOUND. Make sure you install the gstreamer-1.0 libraries. It doesn’t matter whether or not you have the -0.10 libraries installed.

Previously I was using


which I think caused issues when opencv tried to access the video. I am a beginner when it comes to gstreamer (and linux in general), so i might not be interpreting the results correctly. But it does work now using the following code:

#include <opencv2/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/videoio.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
	cout << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << endl;

	const char* gst =  "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)120/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink";

    	cv::VideoCapture cap(gst);
	//const char* env = "GST_DEBUG=*:3";

	if(!cap.isOpened()) { // check if we succeeded
		cerr << "Failed to open camera " << endl;
		return -1;

		Mat frame;
		cap >> frame; // get a new frame from camera
		imshow("original", frame);
	// the camera will be deinitialized automatically in VideoCapture destructor
	return 0;

I think the problem is something wrong with your gstreamer-1.0 library, I copy the gstreamer-1.0 library files in another TX1, then it works! If there’s nothing important you can flash the TX1,and it has the library already ,no need to install the gstreamer again.