Jetson TX2板载相机opencv调用打开

来源:互联网 发布:js数组的length方法 编辑:程序博客网 时间:2024/05/17 02:20

Jetson TX2 打开板载相机



[cpp] view plain copy
  1. #include <stdio.h>  
  2. #include <opencv2/opencv.hpp>  
  3.   
  4. using namespace cv;  
  5. using namespace std;  
  6.   
  7. int main(int argc, char** argv)  
  8. {  
  9.   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");  
  10.   if (!cap.isOpened())  
  11.     {  
  12.       cout << "Failed to open camera." << endl;  
  13.       return -1;  
  14.     }  
  15.   
  16.   for(;;)  
  17.     {  
  18.       Mat frame;  
  19.       cap >> frame;  
  20.       imshow("original", frame);  
  21.       if(waitKey(30) >= 0)  
  22.       break;  
  23.     }  
  24.   return 0;  
  25. }  
[cpp] view pla
原创粉丝点击