一.设备
1.监控相机:登利路30倍变焦
2.usb采集卡:MINE Vcap2860
二:软件
1.VS2010
2.opencv2.3.1
3.videoInput库 网盘下载地址链接: http://pan.baidu.com/s/1c2gFV7E 密码: s936
三:编程测试
1.代码:
#include "stdafx.h"
#include "videoInput.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <stdio.h>
#pragma comment(linker, "/NODEFAULTLIB:atlthunk.lib")
int _tmain(int argc, _TCHAR* argv[])
{
int numDevices = 0; //设备ID号
videoInput VI;//创建视对象
int num = VI.listDevices();//图像设备数量
char* Devicename = VI.getDeviceName(numDevices);
const char* name = "WDM 2860 Capture";//usb采集卡的名称
while(strcmp(name,Devicename) != 0)//找usb采集卡
{
numDevices++;
if(numDevices >= num)
{
printf("没有找到你的设备\n\n");
system("pause");
return 0;
}
Devicename = VI.getDeviceName(numDevices);
}
int width = 640;
int height= 480;
IplImage *img = cvCreateImage(cvSize(width,height), IPL_DEPTH_8U, 3);
VI.setupDevice(numDevices,width,height);//配置设备
while(1)
{
if(VI.isFrameNew(numDevices))
{
VI.getPixels(numDevices, (unsigned char *)img->imageData, false, true);//获取一帧
cvShowImage("img", img);
if(cvWaitKey(1)==27) break;//按ESC退出
}
}
return 0;
}
2.测试结果: