Thread: Setting camera resolution through DirectShow

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195

    Setting camera resolution through DirectShow

    I want to set the resolution on my camera to 640x480 without using the filter pin dialog. Since the logitech quickcam software can do this, i know its possible, but they wont budge on supplying this information. I woudl prefer a general solution that woudl work with all capture devices, not just logitech cameras. Currently I can call up the filter pin dialog, but I need something that will do it at application startup without user intervention.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Assuming you're using DirectShow, a quick google suggests that the IAMStreamConfig interface is involved.

    gg

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    That interface just lets you set the media type, not the resolution.

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Another google search suggests otherwise.....

    Found this from the WiMoBot source code: http://garage.wimobot.com/
    Code:
    // Sets up the capture filter to capture pictures at the specified 
    // resolution.  the resolution is specified using an id.
    HRESULT SetCameraResolution(HANDLE hCamera, DWORD dwId)
    {
        HRESULT hr = S_OK;
        CameraInfo *pci = (CameraInfo*)hCamera;
    
        // get the IAMStreamConfig interface so that we can set the resolution
        CComPtr<IAMStreamConfig>        pConfig;
        hr = pci->pCaptureBuilder->FindInterface(
            &PIN_CATEGORY_STILL,
            &MEDIATYPE_Video,
            pci->pVideoCaptureFilter,
            IID_IAMStreamConfig,
            (void**)&pConfig);
    
        int iCount = 0;
        int iSize = 0;
        // get the number of different resolutions possible
        hr = pConfig->GetNumberOfCapabilities(&iCount, &iSize);
    
        if (SUCCEEDED(hr) && 
            iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS) && 
            dwId < iCount)
        {
            VIDEO_STREAM_CONFIG_CAPS scc;
            AM_MEDIA_TYPE *pmtConfig;
            // make sure we can set the capture format to the resolution we want
            hr = pConfig->GetStreamCaps(dwId, &pmtConfig, (BYTE*)&scc);
            if (SUCCEEDED(hr))
            {
                // That resolution is available, now we set the capture format to the resolution we want.
                pConfig->SetFormat(pmtConfig);
    
                DeleteMediaType(pmtConfig);
            }
        }
        else
        {
            hr = E_FAIL;
        }
    
    
        return hr;
    }
    So they seem to be using the SetFormat() method to change resolutions.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. camera rotation matrix
    By Vick jr in forum Game Programming
    Replies: 5
    Last Post: 05-26-2009, 08:16 AM
  2. LNK2001 ERROR!!! need help
    By lifeafterdeath in forum C++ Programming
    Replies: 7
    Last Post: 05-27-2008, 05:05 PM
  3. USB camera interface using DirectShow
    By abachler in forum Windows Programming
    Replies: 1
    Last Post: 07-30-2007, 01:05 PM
  4. RTS camera movement
    By blurrymadness in forum C++ Programming
    Replies: 0
    Last Post: 04-22-2007, 10:37 PM
  5. Camera rotation/movement in 3D world
    By tegwin in forum Game Programming
    Replies: 11
    Last Post: 01-24-2003, 01:43 PM