Video Camera Handling

BOOL InitVideo(CWnd *ClientWnd, stWebCam& WebCam, int iX, int iY)
{
{

WebCam.hWndC = capCreateCaptureWindow ( (LPSTR) “Video Display”, // window name if pop-up
WS_CHILD | WS_VISIBLE,       // window style
iX, iY, 500, 350,              // window position and dimensions
ClientWnd->GetSafeHwnd() , (int) -1 );

//AfxGetApp()->GetMainWnd()->GetSafeHwnd()

WebCam.fOK = capDriverConnect(WebCam.hWndC, 0);

if(!WebCam.fOK)
{
//            MessageBox(hWndC,”No Camera is connected to the system.                \n”, “Camera not available”, MB_ICONINFORMATION);

::SetWindowPos(WebCam.hWndC, NULL, 0, 0, 0,0, SWP_NOZORDER | SWP_NOMOVE);

return FALSE;
}

//Obtaining the Capabilities of a Capture Driver

capDriverGetCaps(WebCam.hWndC, &WebCam.CapDrvCaps, sizeof (CAPDRIVERCAPS));

//Obtaining the Status of a Capture Window

capGetStatus(WebCam.hWndC, &WebCam.CapStatus, sizeof (CAPSTATUS));

::SetWindowPos(WebCam.hWndC, NULL, 0, 0, WebCam.CapStatus.uiImageWidth,
WebCam.CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);

//Previewing Video

capPreviewRate(WebCam.hWndC, 150);//66);     // rate, in milliseconds
capPreview(WebCam.hWndC, TRUE);       // starts preview

//capPreview(hWnd, FALSE);        // disables preview

//Enabling Video Overlay

capDriverGetCaps(WebCam.hWndC, &WebCam.CapDrvCaps, sizeof (CAPDRIVERCAPS));

if (WebCam.CapDrvCaps.fHasOverlay)
capOverlay(WebCam.hWndC, TRUE);
}

return TRUE;

}

void VideoFormat(stWebCam WebCam)
{
if(capDlgVideoFormat(WebCam.hWndC))
{
capGetStatus(WebCam.hWndC, &WebCam.CapStatus, sizeof (CAPSTATUS));

::SetWindowPos(WebCam.hWndC, NULL, 0, 0, WebCam.CapStatus.uiImageWidth,
WebCam.CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
}

}
void VideoSource(stWebCam WebCam)
{

capDlgVideoSource(WebCam.hWndC);

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: