代码拉取完成,页面将自动刷新
// Example 2-10. The same object can load videos from a camera or a file
//
#include <opencv2/opencv.hpp>
#include <iostream>
void help(char** argv ) {
std::cout << "\n"
<< "\nxample 2-10. The same object can load videos from a camera or a file"
<< "\nCall:\n"
<< argv[0] <<" [path/image]\n"
<< "\nor, read from camera:\n"
<< argv[0]
<< "\nFor example:\n"
<< argv[0] << " ../tree.avi\n"
<< std::endl;
}
int main( int argc, char** argv ) {
help(argv);
cv::namedWindow( "Example 2-10", cv::WINDOW_AUTOSIZE );
cv::VideoCapture cap;
if (argc==1) {
cap.open(0); // open the first camera
} else {
cap.open(argv[1]);
}
if( !cap.isOpened() ) { // check if we succeeded
std::cerr << "Couldn't open capture." << std::endl;
return -1;
}
cv::Mat frame;
for(;;) {
cap >> frame;
if( frame.empty() ) break; // Ran out of film
cv::imshow( "Example 2-10", frame );
if( (char) cv::waitKey(33) >= 0 ) break;
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。