Last active
September 4, 2019 01:00
-
-
Save oliverjungen/06c7abe959486b9fbbb24d5838975c40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using an OV5645 CSI camera module connected to a Dragonboard 410c using OpenCV | |
#include <opencv2/opencv.hpp> | |
#include <opencv2/videoio.hpp> | |
#include <opencv2/highgui.hpp> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int main() | |
{ | |
std::string pipeline = | |
std::string("v4l2src device=/dev/video0 num-buffers=1 ! ") + | |
std::string("video/x-raw,format=UYVY,width=1920,height=1080 ! ") + | |
std::string("videoconvert ! ") + | |
std::string("appsink "); | |
std::cout << "Using pipeline: \n\t" << pipeline << "\n"; | |
cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER); | |
if(!cap.isOpened()) | |
{ | |
std::cout<<"Failed to open camera."<<std::endl; | |
return (-1); | |
} | |
cv::namedWindow("CSI Camera", cv::WINDOW_AUTOSIZE); | |
cv::Mat img; | |
std::cout << "Hit ESC to exit" << "\n" ; | |
while (true) | |
{ | |
if (!cap.read(img)) | |
{ | |
std::cout<<"Capture read error"<<std::endl; | |
break; | |
} | |
cv::imshow("CSI Camera", img); | |
int keycode = cv::waitKey(0) & 0xff; | |
if (keycode == 27) break; | |
} | |
cap.release(); | |
cv::destroyAllWindows(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment