[ create a new paste ] login | about

Link: http://codepad.org/ngz6tVyL    [ raw code | output | fork ]

C, pasted on Jul 8:
#include <stdio.h>
#include <stdlib.h>
#include <highgui.h>
#include <windows.h>
#include <cv.h>

#pragma comment(lib,"cv.lib")
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"cvaux.lib")
#pragma comment(lib,"highgui.lib")

int main(int argc, char** argv){
	int key;
	CvCapture	*capture;
	IplImage	*frameImage;
	char		windowNameCapture[] = "処理前";
	//時間tのグレイスケール用の宣言
	char		windowName1[] = "時間tのグレイスケール画像";
	IplImage *resultImage1=cvCreateImage(cvSize(640,480), IPL_DEPTH_8U,1);
	//時間t+⊿tのグレイスケール用の宣言
	char		windowName2[] = "時間t+⊿tのグレイスケール画像";
	IplImage *resultImage2=cvCreateImage(cvSize(640,480), IPL_DEPTH_8U,1);
	//resultImage1とresultImage2の差分画像
	char		windowName3[] = "差分画像";
	IplImage *resultImage3=cvCreateImage(cvSize(640,480), IPL_DEPTH_8U,1);

	//カメラ初期化
	if ( (capture = cvCreateCameraCapture(0)) == NULL){
		//カメラがなかった場合、
		printf("カメラが見つかりません\n");
		return -1;
	}

	//ウィンドウ生成
	cvNamedWindow(windowNameCapture, CV_WINDOW_AUTOSIZE);
	cvNamedWindow(windowName1, CV_WINDOW_AUTOSIZE);
	cvNamedWindow(windowName2, CV_WINDOW_AUTOSIZE);
	cvNamedWindow(windowName3, CV_WINDOW_AUTOSIZE);

	//メインループ
		frameImage = cvQueryFrame(capture);
	while(1){
		cvCvtColor(frameImage,resultImage1,CV_RGB2GRAY);
		
		
	
		Sleep(100);//⊿tの設定
		frameImage = cvQueryFrame(capture);	
		cvCvtColor(frameImage,resultImage2,CV_RGB2GRAY);		
		cvAbsDiff(resultImage1,resultImage2,resultImage3);
		
		//画像を表示する
		cvShowImage(windowNameCapture, frameImage);
		cvShowImage(windowName1, resultImage1);
		cvShowImage(windowName2, resultImage2);
		cvShowImage(windowName3, resultImage3);

		//qが押されたらループを抜ける
		key = cvWaitKey(1);
		if (key == 'q'){
			break;
		}
	}

	//キャプチャを開放する
	cvReleaseCapture(&capture);
	//ウィンドウを破棄
	cvDestroyWindow(windowNameCapture);
	cvDestroyWindow(windowName1);
	cvDestroyWindow(windowName2);
	cvDestroyWindow(windowName3);

	return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Line 20: error: highgui.h: No such file or directory
Line 20: error: windows.h: No such file or directory
Line 15: error: cv.h: No such file or directory
In function 'main':
Line 14: error: 'CvCapture' undeclared (first use in this function)
Line 14: error: (Each undeclared identifier is reported only once
Line 14: error: for each function it appears in.)
Line 14: error: 'capture' undeclared (first use in this function)
Line 15: error: 'IplImage' undeclared (first use in this function)
Line 15: error: 'frameImage' undeclared (first use in this function)
Line 19: error: 'resultImage1' undeclared (first use in this function)
Line 19: error: 'IPL_DEPTH_8U' undeclared (first use in this function)
Line 22: error: 'resultImage2' undeclared (first use in this function)
Line 25: error: 'resultImage3' undeclared (first use in this function)
Line 35: error: 'CV_WINDOW_AUTOSIZE' undeclared (first use in this function)
Line 43: error: 'CV_RGB2GRAY' undeclared (first use in this function)


Create a new paste based on this one


Comments: