對攝像頭影象就行預覽
阿新 • • 發佈:2019-02-03
程式碼如下:
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;
}