Visual Studio 2010 安裝 OpenCV 2.3 ( WebCam)
Visual Studio 2010 安裝 OpenCV 2.3 ( WebCam)
[下午9:18
|
0
意見
]
http://iammic.pixnet.net/blog/post/34304039-visual-studio-2010%EF%BC%9Aopencv-2.3-%E4%BD%BF%E7%94%A8-webcamVisual Studio 2010:OpenCV 2.3 使用 WebCam
SETP1:下載 OpenCV-2.3.0-win-superpack.exe,解壓縮檔案到 C:OpenCV2.3
SETP2:設定 PATH 環境變數
C:OpenCV2.3buildbin;C:OpenCV2.3buildx86vc10bin;
SETP3:在 Visual Studio 2010 中建立 VC++ Win32 主控台應用程式
SETP4:點選 專案->屬性->VC++ 目錄 設定
Include 目錄:
C:OpenCV2.3buildincludeopencv;C:OpenCV2.3buildinclude;
程式庫目錄:
C:OpenCV2.3buildx86vc10lib;
SETP5:點選 專案->屬性->連結器->輸入 設定
其他相依性:
opencv_core230d.lib;opencv_highgui230d.lib;opencv_imgproc230d.lib;opencv_legacy230d.lib;opencv_ml230d.lib;opencv_video230d.lib;
程式碼:
#include "stdafx.h"
#include
#include
int _tmain(int argc, _TCHAR* argv)
{
int c;
CTime time;
IplImage *img;
CvCapture* capture = cvCaptureFromCAM(1);
cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE);
cvMoveWindow("mainWin", 5, 5);
while(1)
{
img=cvQueryFrame(capture);
cvShowImage("mainWin", img );
c=cvWaitKey(10);
//按鍵盤 s 鍵儲存成 jpg 檔
if(c=='s'){
time = CTime::GetCurrentTime();
CStringA filename(time.Format(CString("%Y%m%d%H%M%S"))+".jpg");
cvSaveImage(filename,img);
}
//按鍵盤 ESC 離開
if(c == 27)
break;
}
cvReleaseImage(&img);
cvDestroyWindow("mainWin");
return 0;
}
參考網站:
http://siddhantahuja.wordpress.com/2011/07/18/getting-started-with-opencv-2-3-in-microsoft-visual-studio-2010-in-windows-7-64-bit/
較新的文章
較舊的文章
首頁
0
意見
張貼留言