2013年2月27日 星期三

W2 課堂練習

第二周課堂練習
使用Visual Studio + OpenCV 讀圖片檔

程式碼
----------------------------------------------------

// 160025.cpp : 定義主控台應用程式的進入點。
//
#include "stdafx.h"
#include <opencv/highgui.h>
int _tmain(int argc, _TCHAR* argv[])
{
IplImage * img = cvLoadImage("c:/aaa.jpg");
cvShowImage("window",img);
cvWaitKey(0);

return 0;
}
-----------------------------------------------------
圖片擷取


第二題
開啟視訊並且拍照
程式碼
------------------------------------------
#include "stdafx.h"
#include <opencv/highgui.h>

int _tmain(int argc, _TCHAR* argv[])
{
CvCapture * cap = cvCreateCameraCapture(0);
IplImage * img = cvQueryFrame(cap);

while(1){
img=cvQueryFrame(cap);
cvShowImage("img",img);
int key=cvWaitKey(33);
if(key==27) break;
}

cvReleaseCapture(&cap);
return 0;
}
--------------------------------------------------------


沒有留言:

張貼留言