opencv 摄像头
1 //--------------------------------------【程序说明】------------------------------------------- 2 // 程序说明:《OpenCV3编程入门》OpenCV2版书本附赠示例程序13 3 // 程序描述:摄像头帧频检测 4 // 测试所用操作系统: Windows 7 64bit 5 // 测试所用IDE版本:Visual Studio 2010 6 // 测试所用OpenCV版本: 2.4.9 7 // 2014年11月 Revised by @浅墨_毛星云 8 //------------------------------------------------------------------------------------------------ 9 //Code to check the OpenCV installation on Raspberry Pi and mesaure frame rate 10 //Author: Samarth Manoj Brahmbhatt, University of Pennsyalvania 11 12 13 //---------------------------------【头文件、命名空间包含部分】---------------------------- 14 // 描述:包含程序所使用的头文件和命名空间 15 //------------------------------------------------------------------------------------------------ 16 #include <iostream> 17 #include <opencv2/opencv.hpp> 18 #include <opencv2/highgui/highgui.hpp> 19 #include <opencv2/core/core.hpp> 20 21 using namespace cv; 22 using namespace std; 23 24 //-----------------------------------【main( )函数】-------------------------------------------- 25 // 描述:控制台应用程序的入口函数,我们的程序从这里开始 26 //------------------------------------------------------------------------------------------------- 27 int main() 28 { 29 30 // VideoCapture cap("Video4.mp4"); 31 VideoCapture cap(0); 32 if (!cap.isOpened()) 33 cout << "fail to open!" << endl; 34 // cap.set(CV_CAP_PROP_FRAME_WIDTH, 800); 35 // cap.set(CV_CAP_PROP_FRAME_HEIGHT, 600); 36 37 Mat im, im_g; 38 double time = 0; 39 unsigned int frames = 0; 40 41 while (1) { 42 // double t0 = getTickCount(); 43 44 cap >> im; 45 cout << im.size() << endl; 46 cout << "that is ok!" << endl; 47 // cvtColor(im, im_g, CV_BGR2GRAY); 48 // frames++; 49 50 cv::imshow("cap1", im); 51 // cout << "that is ok!" << endl; 52 // Mat I; 53 // I=imread("sharp.png"); 54 // imshow("sharp.png", I); 55 // imshow("cap2", im_g); 56 // time += (getTickCount() - t0) / getTickFrequency(); 57 // cout << frames / time << " fps" << endl; 58 waitKey(30); 59 } 60 // cap.release(); 61 return 0; 62 }