学OpenCV
================================================
简单的看下效果。
当前我使用的4.10.0。这个版本需要参数2,否则在我的windows10上加载不了摄像头。
================================================
1 #include <iostream> 2 #include <opencv2/opencv.hpp> 3 #include <opencv2/core/utils/logger.hpp> 4 5 int main() 6 { 7 cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_ERROR); 8 9 double fps = 1; 10 11 cv::VideoCapture video(0,cv::CAP_DSHOW); 12 if (video.isOpened() == true) 13 { 14 std::cout << "width: " << video.get(cv::CAP_PROP_FRAME_WIDTH) << std::endl; 15 std::cout << "height:" << video.get(cv::CAP_PROP_FRAME_HEIGHT) << std::endl; 16 std::cout << "fps:" << video.get(cv::CAP_PROP_FPS) << std::endl; 17 std::cout << "frames:" << video.get(cv::CAP_PROP_FRAME_COUNT) << std::endl; 18 19 fps = video.get(cv::CAP_PROP_FPS); 20 } 21 else 22 { 23 std::cout << "please check the file name and path." << std::endl; 24 return -1; 25 } 26 27 cv::Mat frame;//放在外面可以吗? 28 for (;;) 29 { 30 video >> frame; 31 if (frame.empty()) 32 { 33 break; 34 } 35 36 cv::imshow("camera", frame); 37 cv::waitKey(1); 38 } 39 40 cv::waitKey(); 41 42 return 0; 43 }
标签:utils,cv,include,frame,摄像头,加载 From: https://www.cnblogs.com/wlsandwho/p/18367115