void CVfwTestDlg::StartCapture() { //STEP 1: Create capture window HWND hwndParent=this->m_hWnd; hWndC = capCreateCaptureWindow ( NULL, WS_CHILD | WS_VISIBLE , 0, 0, 640/4, 480/4, hwndParent, 0); /* //OPTIONAL STEP: Get capture devices information char DeviceName[80]; char DeviceVersion[80]; for (int index = 0; index < 10; index++) { // We assume the number of capture decvices is less than 10 if (capGetDriverDescription(index, DeviceName, sizeof (DeviceName), DeviceVersion, sizeof (DeviceVersion))){ // we can now show the capteure device information here } } */ //STEP 2: Connect to a capture device while (capDriverConnect(hWndC, 0) == FALSE); /* //OPTIONAL STEP: Use hardware to render the video input directly into the framebuffer. CAPDRIVERCAPS CapDrvCaps; capDriverGetCaps(hWndC, &CapDrvCaps, sizeof (CAPDRIVERCAPS)); if (CapDrvCaps.fHasOverlay) capOverlay(hWndC, TRUE); */ // OPTIONAL STEP: Setup frame rate CAPTUREPARMS CaptureParms; float FramesPerSec = 30.0; capCaptureGetSetup(hWndC, &CaptureParms, sizeof(CAPTUREPARMS)); CaptureParms.dwRequestMicroSecPerFrame = (DWORD) (1.0e6 / FramesPerSec); capCaptureSetSetup(hWndC, &CaptureParms, sizeof (CAPTUREPARMS)); // OPTIONAL STEP: Setup resolution //BITMAPINFO psVideoFormat; capGetVideoFormat(hWndC, &BmInfo,sizeof(BmInfo)); /*psVideoFormat.bmiHeader.biWidth = 640; psVideoFormat.bmiHeader.biHeight = 480; capSetVideoFormat(hWndC, &psVideoFormat,sizeof(psVideoFormat)); capDriverDisconnect (hWndC);//Can we do better? capDriverConnect (hWndC, 0); */
//STEP 3: Setup the preview window size //CAPSTATUS CapStatus; //capGetStatus(hWndC, &CapStatus, sizeof (CAPSTATUS)); //::SetWindowPos(hWndC, NULL, 0, 0, CapStatus.uiImageWidth, CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);
//STEP 4: Previewing video capPreview(hWndC, TRUE); // start preview capPreviewRate(hWndC, 15); // rate, in milliseconds, the frame rate here is just for preview window, not for capturing capPreviewScale(hWndC,TRUE); //OPTIONAL STEP: Setup callback functions //capSetCallbackOnFrame(hWndC, FrameCallbackProc); // For frame callback //capSetCallbackOnFrame(hWndC, NULL); //Disable callback function } |