BOOL CGPIODLLApp::CameraOpen(int width, int height)
{
//打开驱动
Camerahl = CreateFile (_T("CIS1:"), GENERIC_WRITE|GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if(Camerahl==INVALID_HANDLE_VALUE )
{
return FALSE;
}
//打开摄像头
DeviceIoControl(Camerahl,CAM_IOCTL_MOVIE_START,NULL,0,NULL,0,NULL,NULL);
DeviceIoControl(Camerahl,IOCTL_CAM_SETGAMMA,NULL,0,NULL,0,NULL,NULL);
unsigned char i,pOut;
unsigned char inbuffer320240[][2]={
{ 0xfc, 0x00},
{ 0x02, 0x03}, // 1600*1200//00 02
{ 0xfc, 0x01},
{ 0x02, 0x77}
};// 03 OK 07 1OK;
unsigned char inbuffer640480[][2]={
{ 0xfc, 0x00},
{ 0x02, 0x02}, // 1600*1200//00 02
{ 0xfc, 0x01},
{ 0x02, 0x67}
};// 03 OK 07 1OK;
unsigned char inbuffer12801024[][2]={
{ 0xfc, 0x00},
{ 0x02, 0x01}, // 1600*1200//00 02
{ 0xfc, 0x01},
{ 0x02, 0x57}
};// 03 OK 07 1OK;
if( width==320 && height==240)
{
for(i=0;i<=(sizeof(inbuffer320240)/2);i++)
{
DeviceIoControl(Camerahl,IOCTL_CAM_WRITEREG, inbuffer320240, 2,&pOut ,1, NULL, NULL);
}
pOut=3;
DeviceIoControl(Camerahl,IOCTL_CAM_SETSCALE, &i, 1,&pOut ,1, NULL, NULL);
DeviceIoControl(Camerahl,CAM_IOCTL_MOVIE_START,NULL,0,NULL,0,NULL,NULL);
DeviceIoControl(Camerahl,IOCTL_CAM_SETGAMMA,NULL,0,NULL,0,NULL,NULL);
}
else if( width==640 && height==480)
{
for(i=0;i<=(sizeof(inbuffer640480)/2);i++)
{
DeviceIoControl(Camerahl,IOCTL_CAM_WRITEREG, inbuffer640480, 2,&pOut ,1, NULL, NULL);
}
pOut=2;
DeviceIoControl(Camerahl,IOCTL_CAM_SETSCALE, &i, 1,&pOut ,1, NULL, NULL);
DeviceIoControl(Camerahl,CAM_IOCTL_MOVIE_START,NULL,0,NULL,0,NULL,NULL);
DeviceIoControl(Camerahl,IOCTL_CAM_SETGAMMA,NULL,0,NULL,0,NULL,NULL);
}
else if( width==1280 && height==1024)
{
for(i=0;i<=(sizeof(inbuffer12801024)/2);i++)
{
DeviceIoControl(Camerahl,IOCTL_CAM_WRITEREG, inbuffer12801024, 2,&pOut ,1, NULL, NULL);
}
pOut=1;
DeviceIoControl(Camerahl,IOCTL_CAM_SETSCALE, &i, 1,&pOut ,1, NULL, NULL);
DeviceIoControl(Camerahl,CAM_IOCTL_MOVIE_START,NULL,0,NULL,0,NULL,NULL);
DeviceIoControl(Camerahl,IOCTL_CAM_SETGAMMA,NULL,0,NULL,0,NULL,NULL);
}
else
{
return FALSE;
}
return TRUE;
}
void CGPIODLLApp::CameraClose()
{
CloseHandle(Camerahl);
}
void CGPIODLLApp::CameraPhoto(unsigned char outBuff[])
{
char inBuff;
//读buffer操作 数据由pBufOut传出
DeviceIoControl(Camerahl,CAM_IOCTL_GET_LATEST_FRAME, &inBuff, sizeof(inBuff), outBuff ,sizeof(inBuff), NULL, NULL);
} |