求各位大神帮忙指导下 程序运行无误 但一直出现 Test.exe 已停止工作
此问题是读取USB摄像头 有的摄像头用这个程序没问题 ,有的却显示 Test.exe已停止工作#include <cvcam.h>
#include <cv.h>
#include <highgui.h>
#include "stdio.h"
#include <windows.h>
#include "cxcore.h"
void callback(IplImage* image);
void main()
{
HWND CaptureWindow1=0;
int *CameraNumber;
int nSelected = cvcamSelectCamera(&CameraNumber);
//3õê¼»ˉὸöéãÏñí·
cvNamedWindow("cvcam1 Window",1);
cvResizeWindow("cvcam1 Window",200,200);
CaptureWindow1=(HWND)cvGetWindowHandle("cvcam1 Window");
cvcamSetProperty(CameraNumber[0], CVCAM_PROP_ENABLE, CVCAMTRUE);
cvcamSetProperty(CameraNumber[0], CVCAM_PROP_RENDER, CVCAMTRUE);
cvcamSetProperty(CameraNumber[0], CVCAM_PROP_WINDOW, &CaptureWindow1);
cvcamSetProperty(CameraNumber[0],CVCAM_PROP_CALLBACK,callback);
cvcamInit();
cvcamStart();
while(2000)
cvWaitKey(0);
cvcamStop();
cvcamExit();
free(CameraNumber);
cvDestroyWindow("cvcam1 Window");
}
void callback(IplImage* image)
{
IplImage* image1 = image;
int i,j;
assert (image);
for(i=0; i<image1->height; i+=10)
{
for(j=(image1->widthStep)*i; j<(image1->widthStep)*(i+1);
j+=image1->nChannels)
{
image1->imageData[j] = (char)255;
image1->imageData[j+1] = 0;
image1->imageData[j+2] = 0;
}
}
}