对摄像头图像就行预览

来源:互联网 发布:打印照片排版软件 编辑:程序博客网 时间:2024/05/16 14:15

代码如下:

 HWND myWindow;
 this->GetDlgItem(IC_SCREEN,&myWindow);  
HWND handle=capCreateCaptureWindow("Capture",WS_VISIBLE|WS_CHILD,0,0,  360,280,myWindow,0);

 if(handle==false) 
{
  AfxMessageBox("摄像头加载失败");  
return; 
}  
if(!::SendMessage(handle, WM_CAP_DRIVER_CONNECT ,0,0)) 
{  
AfxMessageBox("驱动连接失败"); 
 ::SendMessage(handle, WM_CAP_DRIVER_DISCONNECT,0,0); 
  CloseHandle(handle);  return; 
}
 if(!::SendMessage(handle, WM_CAP_SET_PREVIEWRATE ,100,0)) 
{  
AfxMessageBox("设置刷新频率错误");  
CloseHandle(handle);  
return;
 }
 if(!::SendMessage(handle, WM_CAP_SET_PREVIEW ,true,NULL)) 

 AfxMessageBox("预览失败");
  CloseHandle(handle);  
return; 
}

原创粉丝点击