Jetson TX2板載相機opencv呼叫開啟
阿新 • • 發佈:2019-01-25
[cpp] view plain copy print?
- #include <stdio.h>
- #include <opencv2/opencv.hpp>
- usingnamespace cv;
- usingnamespace 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();
- } 編譯命令: g++ -o tx2opencv tx2opencv.cpp `pkg-config opencv –cflags –libs `