#include using namespace cv; using namespace std; std::string get_tegra_pipeline(int width, int height, int fps) { return "v4l2src device=/dev/video0 ! \"video/x-raw,format=(string)UYVY, width=(int)1920, height=(int)1080\" ! nvvidconv ! \"video/x-raw(memory:NVMM),format=(string)I420\" ! nvvidconv ! \"video/x-raw, format=(string)BGRx\" ! videoconvert ! \"video/x-raw, format=(string)BGR\" ! appsink"; } int main() { // Options int WIDTH = 1920; int HEIGHT = 1080; int FPS = 30; // Define the gstream pipeline std::string pipeline = get_tegra_pipeline(WIDTH, HEIGHT, FPS); std::cout << "Using pipeline: \n\t" << pipeline << "\n"; // Create OpenCV capture object, ensure it works. cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER); if (!cap.isOpened()) { std::cout << "Connection failed"; return -1; } // View video cv::Mat frame; while (1) { cap >> frame; // Get a new frame from camera // Display frame imshow("Display window", frame); cv::waitKey(1); //needed to show frame } }