Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Why is the resolution in SampleGrabber different from the resolution in IAMStreamConfig?

Why is the resolution in SampleGrabber different from the resolution in IAMStreamConfig?

Scheduled Pinned Locked Moved COM
data-structureshelpquestion
1 Posts 1 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    garry fang
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups