OpenCVãè¤æ°ã«ã¡ã©ã«å¯¾å¿ãã¦ãªã件ã«ã¤ãã¦
ã©ãã«ããã¾ããããªãã¨æã£ããããã¯ãè¤æ°å¯¾å¿ãã¦ããªãããã§ã(2ã¤ã¾ã§ã¯ãªãã¨ãå¯è½ã§ããã).
ã¨ããããã§VideoInputã¨ããã©ã¤ãã©ãª(DirectShowã楽ã«ä½¿ãã©ã¤ãã©ãª)ããããã®è¨äºãé ¼ãã«ãã£ã¦ã¿ã¾ããã
ã©ã¤ãã©ãªã¯Visual Studio2005ã³ã³ãã¤ã«verã2008ã§é©ç¨ãã¾ãããåé¡ç¡ãã£ãã§ããããã§è¤æ°ã«ã¡ã©ã¸ã®å¯¾å¿ãå¯è½ã«ãã¾ããããããã¨ããããã¾ãã
解説ãªãã£ããèºããããªç¹ã¨ãã¦
ãã«ãæã«atlthunk.lib ãªã³ã«ã¨ã©ã¼ãåºãã
ããã¸ã§ã¯ãâããããã£âæ§æããããã£âãªã³ã«âã³ãã³ãã©ã¤ã³â追å ã®ãªãã·ã§ã³ ã«
/NODEFAULTLIB:"atlthunk"
ã¨è¨è¿°ãã¾ãï¼
ãããã¸ããããããããã¨
以ä¸ã¯è¤æ°ã«ã¡ã©ï¼ä¸å°)ã®å ´åã®ãµã³ãã«ã§ãã
//---------------------------------------------------------------------- // æ¦è¦ : videoInputã©ã¤ãã©ãªãç¨ãããã£ããã£ãµã³ãã«(memcpyç)ãã¡ãã£ã¨å¤æ´ããver // File Name : CaptureVI.cpp // Library : OpenCV for MS-Windows 1.0 / videoInput Library 0.195 // Author : dandelion // Date : Dec 29, 2008; 20:3r //---------------------------------------------------------------------- #include <iostream> #include <cstdlib> //ãããã¤ã³ã¯ã«ã¼ã(OpenCVé¢é£) #include <cv.h> #include <cxcore.h> #include <highgui.h> //ãããã¤ã³ã¯ã«ã¼ã(videoInput Libraryé¢é£) #include "videoInput.h" //ã©ã¤ãã©ãªèªã¿è¾¼ã¿(OpenCVé¢é£) #pragma comment(lib,"cv.lib") #pragma comment(lib,"cxcore.lib") #pragma comment(lib,"highgui.lib") // ã©ã¤ãã©ãªèªã¿è¾¼ã¿(videoInput Libraryé¢é£) #pragma comment(lib,"videoInput.lib") //å®æ° #define CAPTURE_WIDTH 320 //ãã£ããã£ãµã¤ãº(å¹ ) #define CAPTURE_HEIGHT 240 //ãã£ããã£ãµã¤ãº(é«ã) using namespace std; int main(void) { // device enum { device1, device2, device3, }; int key = 0; //ãã£ããã£ç»å IplImage *image = cvCreateImage(cvSize(CAPTURE_WIDTH, CAPTURE_HEIGHT), IPL_DEPTH_8U, 3); IplImage *image2 = cvCreateImage(cvSize(CAPTURE_WIDTH, CAPTURE_HEIGHT), IPL_DEPTH_8U, 3); IplImage *image3 = cvCreateImage(cvSize(CAPTURE_WIDTH, CAPTURE_HEIGHT), IPL_DEPTH_8U, 3); //ã¦ã£ã³ã㦠char* window_name = "Capture using videoInput Library"; char* window_name2 = "Capture using videoInput2 Library"; char* window_name3 = "Capture using videoInput3 Library"; cvNamedWindow(window_name, CV_WINDOW_AUTOSIZE); cvNamedWindow(window_name2, CV_WINDOW_AUTOSIZE); cvNamedWindow(window_name3, CV_WINDOW_AUTOSIZE); //videoInputãªãã¸ã§ã¯ã videoInput VI; //å©ç¨å¯è½ãªãã£ããã£ããã¤ã¹æ°ãåå¾ int numDevices = VI.listDevices(); //ãã£ããã£ããã¤ã¹ãè¦ã¤ãããªãã£ããçµäº if(numDevices == 0) { cerr << "[Error] Capture device not found!!" << endl; exit(-1); } //ããã¤ã¹åæåï¼ä»åã¯ããã¤ã¹ID = 0ï¼CAPTURE_WIDTH x CAPTURE_HEIGHTã§ãã£ããã£ï¼ VI.setupDevice(device1, CAPTURE_WIDTH, CAPTURE_HEIGHT); VI.setupDevice(device2, CAPTURE_WIDTH, CAPTURE_HEIGHT); VI.setupDevice(device3, CAPTURE_WIDTH, CAPTURE_HEIGHT); //ESCãã¼ãæ¼ãããã¾ã§ãã£ããã£ãç¶ãã while(key != 0x1b) { //ãã£ããã£ç»åãimageDataã«ã³ãã¼ memcpy(image->imageData, VI.getPixels(device1, false), image->imageSize); //ç»å表示 cvShowImage(window_name, image); memcpy(image->imageData, VI.getPixels(device2, false), image->imageSize); cvShowImage(window_name2, image); memcpy(image->imageData, VI.getPixels(device3, false), image->imageSize); cvShowImage(window_name3, image); //ãã¼å ¥å key = cvWaitKey(1); } //å¾å¦ç VI.stopDevice(device1); VI.stopDevice(device2); VI.stopDevice(device3); cvDestroyWindow(window_name); cvDestroyWindow(window_name2); cvDestroyWindow(window_name3); cvReleaseImage(&image); return 0; }