#include "stdafx.h" #include <stdio.h> #include <cv.h> #include "cxcore.h" #include <highgui.h> #include "math.h" #include <stdio.h> #include <ctype.h> #include "ARFrameGrabber.h" //#include <streams.h> void main(int argc, char* argv[]) { IplImage *frame =0; static ARFrameGrabber frameGrabber; //声明对象 IplImage ds_frame; frameGrabber.Init(0, true); //设置支持directshow的设备编号,从0开始 frameGrabber.SetFlippedImage(true); //图像是否翻转 for(;;) { frameGrabber.GrabByteFrame(); //获取一帧 BYTE *myBuffer = frameGrabber.GetByteBuffer(); //得到图像的缓冲 int width = frameGrabber.GetWidth(); int height = frameGrabber.GetHeight(); int stride = (width * sizeof( RGBTRIPLE ) + 3) & -4; cvInitImageHeader( &ds_frame, cvSize(width, height), 8, 3,IPL_ORIGIN_BL, 4 ); //创建iplimage ds_frame.widthStep = stride; cvSetData( &ds_frame, myBuffer, stride ); //copy数据 frame = &ds_frame; /**//* 视频分析部分 */ //int nFrmNum = 0; cvNamedWindow("vedio",1); cvShowImage("vedio",frame); if (cvWaitKey(20)>=0) break; } cvReleaseImage(&frame); cvDestroyWindow("vedio"); }