OpenCV学习笔记(6)基于 VC+OpenCV+DirectShow 的多个摄像头同步工作
因项目需要采集2个摄像头的数据进行双目检测,一开始采用以下代码来测试:<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px;" class="wlWriterEditableSmartContent">#include "stdafx.h"#include <cv.h>#include <cxcore.h>#include <highgui.h>int main(int argc, _TCHAR* argv[]){ CvCapture* capture1 = cvCreateCameraCapture( 0 ); CvCapture* capture2 = cvCreateCameraCapture( 1 ); double w = 320, h = 240; cvSetCaptureProperty ( capture1, CV_CAP_PROP_FRAME_WIDTH,w ); cvSetCaptureProperty ( capture1, CV_CAP_PROP_FRAME_HEIGHT, h ); cvSetCaptureProperty ( capture2, CV_CAP_PROP_FRAME_WIDTH,w ); cvSetCaptureProperty ( capture2, CV_CAP_PROP_FRAME_HEIGHT, h ); cvNamedWindow( "Camera_1", CV_WINDOW_AUTOSIZE ); cvNamedWindow( "Camera_2", CV_WINDOW_AUTOSIZE ); IplImage* frame1; IplImage* frame2; int n = 2; while(1) { frame1 = cvQueryFrame( capture1 ); if( !frame1 ) break; cvShowImage( "Camera_1", frame1 ); frame2 = cvQueryFrame( capture2 ); if( !frame2 ) break; cvShowImage( "Camera_2", frame2 ); int key = cvWaitKey(30); if( key == 27 ) break; } cvReleaseCapture( &capture1 ); cvReleaseCapture( &capture2 ); cvDestroyWindow( "Camera_1" ); cvDestroyWindow( "Camera_2" ); return 0;}<!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.http://dunnhq.com -->
页:
[1]