2013年2月27日 星期三

第一個OpenCV程式

1. 利用OpenCV加上Mircosoft Visual C++進行讀圖:
Demo:

Source Code:

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <opencv\highgui.h>
#include <opencv\cv.h>

int _tmain(int argc, _TCHAR* argv[])
{
IplImage *img = cvLoadImage("C:\\ccc.jpg");
cvShowImage("window",img);
cvWaitKey(0);

return 0;
}

2. 利用OpenCV加上Mircosoft Visual C++進行讀視訊:
Demo:

Source Code:

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <opencv\highgui.h>
#include <opencv\cv.h>

int _tmain(int argc, _TCHAR* argv[])
{
while(1){
CvCapture * cap=cvCreateCameraCapture(0);
IplImage *img = cvQueryFrame(cap);
cvShowImage("window",img);
int key=cvWaitKey(33);
if(key==27)break;
}
return 0;
}


沒有留言:

張貼留言