opencv 摄像头
生活随笔
收集整理的這篇文章主要介紹了
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 }
?
轉載于:https://www.cnblogs.com/Wanggcong/p/5179924.html
總結
以上是生活随笔為你收集整理的opencv 摄像头的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CDOJ 1269 ZhangYu Sp
- 下一篇: 安装win7和centos6.7双系统