Why is the resolution in SampleGrabber different from the resolution in IAMStreamConfig?
-
Dear All, I am doing some development with a Logitech C920. I tried to maximize the resolution of C920 to 1920X1080, which it can support. The setting is successful as hr is S_OK. Then I use a samplegrabber to get the image, which is always 640X480. Something is wrong. I am brand new to DirectShow. All my code is based on other's sample code. So, could anyone give me a help? Best, Gary ///////////////////////////////////////////////////////////// void videoCapture::SetResolution(IBaseFilter* pSrcFilter, int Width, int Height) { IAMStreamConfig *pConfig = NULL; pCapture->FindInterface(&PIN_CATEGORY_STILL, &MEDIATYPE_Video, pSrcFilter, IID_IAMStreamConfig, (void**)&pConfig); int resolutions, size; VIDEO_STREAM_CONFIG_CAPS caps; pConfig->GetNumberOfCapabilities(&resolutions, &size); for (int i = 0; i < resolutions; i++) { AM_MEDIA_TYPE *mediaType; if (pConfig->GetStreamCaps(i, &mediaType, reinterpret_cast(&caps)) == S_OK) { int maxWidth = caps.MaxOutputSize.cx; int maxHeigth = caps.MaxOutputSize.cy; if (maxWidth == Width && maxHeigth == Height) { VIDEOINFOHEADER *info = reinterpret_cast(mediaType->pbFormat); info->bmiHeader.biWidth = maxWidth; info->bmiHeader.biHeight = maxHeigth; info->bmiHeader.biSizeImage = DIBSIZE(info->bmiHeader); HRESULT hr = pConfig->SetFormat(mediaType); DeleteMediaType(mediaType); break; } DeleteMediaType(mediaType); } } SAFE_RELEASE(pConfig); } ///////////////////////////////////////////////////////////// HRESULT videoCapture::CaptureVideo(unsigned int devIndex) { if (devIndex == 0) devIndex = 1; HRESULT hr; IBaseFilter *pSrcFilter = NULL; // Attach the filter graph to the capture graph hr = pCapture->SetFiltergraph(pGraph); if (FAILED(hr)) { Msg(TEXT("Failed to set capture filter graph! hr=0x%x"), hr); return hr; } // Use the system device enumerator and class enumerator to find // a video capture/preview device, such as a desktop USB video camera. hr = FindCameraDevice(&pSrcFilter); if (FAILED(hr)) { // Don't display a message because FindCaptureDevice will handle it return hr; } // Add Capture filter to our graph. hr = pGraph->AddFilter(pSrcFilter, L"Video Capture"); if (FAILED(hr)) { Msg(TEXT("Couldn't add the capture filter to the graph! hr=0x%x\r\n\r\n") TEXT("If you have a working video capture device, please make sure\r\n") TEXT("that it is connected and is not b