My opencv version is 2.4.11, and when I was followed by the instructions to run a test using opencv to capture the video
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
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");
//VideoCapture cap("fakesrc ! videoconvert ! appsink");
if (!cap.isOpened())
{
cout << "Failed to open camera." << endl;
return -1;
}
for(;;)
{
Mat frame;
cap >> frame;
imshow("original", frame);
//waitKey(1);
if(waitKey(30) >= 0)
break;
}
return 0;
//cap.release();
}
The result was “Failed to open the camera”. My camera was the onboard camera and I assume that the driver was installed because I could get the video by the instruction “nvgstcapture-1.0”. My storage is not enough to install opencv3.1 so I’m wondering whether I should uninstall the opencv 2.4. Any help is greatly appreciated.