#include "stdafx.h"
#include "CameraDS.h"
#include "string"
#include <cv.h>
#include <highgui.h>
#include <stdio.h>
#include <iostream>
#include "windows.h"
#include <fstream>
using namespace std;
int singlematching(IplImage *srcl, IplImage *srcr , IplImage *tp1);
int main()
{
int cam_count;
//仅仅获取摄像头数目
cam_count = CCameraDS::CameraCount();
printf("There are %d cameras.\n", cam_count);
//获取所有摄像头的名称
for(int i=0; i < cam_count; i++)
{
char camera_name[1024];
int retval = CCameraDS::CameraName(i, camera_name, sizeof(camera_name) );
if(retval >0)
printf("Camera #%d's Name is '%s'.\n", i, camera_name);
else
printf("Can not get Camera #%d's name.\n", i);
}
if(cam_count==0)
return -1;
// 创建2个摄像头类
CCameraDS camera1;
CCameraDS camera2;
if(! camera1.OpenCamera(0, false))
{
fprintf(stderr, "Can not open camera.\n");
return -1;
}
//打开第二个摄像头
camera2.OpenCamera(1, false);
cvNamedWindow("cam1",1);
cvNamedWindow("cam2",1);
int nFrmNum = 0;
int k=0;
while(1)
{
//获取一帧
IplImage *pFrame1 = camera1.QueryFrame();
IplImage *pFrame2 = camera2.QueryFrame();
IplImage *fFrame1 = 0;
IplImage *fFrame2 = 0;
float scale=0.2;
CvSize dst_cvsize;
dst_cvsize.width=pFrame1->width*scale;
dst_cvsize.height=pFrame1->height*scale;
fFrame1=cvCreateImage(dst_cvsize,pFrame1->depth,pFrame1->nChannels);
fFrame2=cvCreateImage(dst_cvsize,pFrame1->depth,pFrame1->nChannels);
cvResize(pFrame1,fFrame1,CV_INTER_LINEAR);
cvResize(pFrame2,fFrame2,CV_INTER_LINEAR);
nFrmNum++;
DWORD dwStart = GetTickCount();
DWORD dwEnd = dwStart;
do
{
dwEnd = GetTickCount()-dwStart;
}while(dwEnd <1);
// 显示实时的摄像头视频
cvShowImage("cam1", fFrame1);
cvShowImage("cam2", fFrame2);
IplImage *tp1 = cvLoadImage("tr.bmp",1);
int m;
if(k==5)
{
m=singlematching( pFrame2, pFrame1,tp1);\\运算
k=0;
}
k++;
//cvWaitKey(33);
int key = cvWaitKey(33);
if( key == 27 ) break;
}
camera1.CloseCamera(); //可不调用此函数,CCameraDS析构时会自动关闭摄像头
camera2.CloseCamera();
cvDestroyAllWindows();
return 0;
}
int singlematching(IplImage *srcl, IplImage *srcr ,IplImage *tp1)
{
}
慕妹3242003
ABOUTYOU