Skip to content

Instantly share code, notes, and snippets.

@qingswu
Created May 9, 2019 04:12
Show Gist options
  • Save qingswu/1df746a275ecc2a439715ffe567a72b9 to your computer and use it in GitHub Desktop.
Save qingswu/1df746a275ecc2a439715ffe567a72b9 to your computer and use it in GitHub Desktop.
Basic video capture template
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>
int main(int argc, char** argv) {
cv::VideoCapture cap(0);
// cap.set(cv::CAP_PROP_FRAME_WIDTH, 1280);
// cap.set(cv::CAP_PROP_FRAME_HEIGHT, 720);
cv::Mat im;
while (true) {
cap >> im;
if (im.empty()) break;
cv::imshow("image", im);
int key = cv::waitKey(1);
if (key == 27) {
break;
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment