#include #include #include #include #include using namespace cv; using namespace std; int main(int argc, char** argv) { int count=100; string str = argv[1]; string gstformat = "NV12"; string gstfile = "v4l2src device=" + str + " ! video/x-raw,format=" + gstformat + ",width=3840,height=2160,framerate=30/1 ! videoconvert ! appsink"; VideoCapture capture(gstfile); while (count) { Mat frame; capture >> frame; if (frame.empty()) { break; } int h = frame.rows; int w = frame.cols; const char *name = "video"; namedWindow(name, 0); imshow(name, frame); waitKey(30); count--; } return 0; }