locked
How to set Resolution of the camera RRS feed

  • Question

  • following is my code to set the Resolution
    HRESULT CPhoneFunctions::CameraSetResolution(unsigned int nWidth, unsigned int nHeight)
    {
    HRESULT hr = S_OK;
    CComPtr pStreamConfig;
    int iCount = 0;
    int iSize = 0;
    hr = m_pCaptureGraphBuilder->FindInterface(&PIN_CATEGORY_STILL,&MEDIATYPE_Video,m_pVideoCaptureFilter,IID_IAMStreamConfig,(void**)&pStreamConfig); if(pStreamConfig == NULL)
        return S_FALSE;
    hr = pStreamConfig->GetNumberOfCapabilities(&iCount,&iSize);
    if(iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
    {
         for (int iFormat = 0;iFormat < iCount;iFormat++)
         {
              VIDEOINFOHEADER* pVih;
              VIDEO_STREAM_CONFIG_CAPS scc;
              BITMAPINFOHEADER* pBih = NULL;
              AM_MEDIA_TYPE* pmtConfig;
              hr = pStreamConfig->GetStreamCaps(iFormat,&pmtConfig,(BYTE*)&scc);
              if(SUCCEEDED(hr))
              { 
                  pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;
                  pBih = &pVih->bmiHeader;
                  if(pBih->biWidth == nWidth && (pBih->biHeight == nHeight || pBih->biHeight == -1 * nHeight))
                  {
                     hr = pStreamConfig->SetFormat(pmtConfig);
                     DeleteMediaType(pmtConfig);
                     if(hr == S_OK)
                     {
                         return S_OK;
                     }
                          // WCHAR wszBuf[256] = {0};
                          // AMGetErrorText(hr, wszBuf, 256);
                          return S_FALSE;
                   }
               }
           }
        }
    return S_FALSE;
    }


    but it doesn't work, the max resolution the camera can support 1600*1200

    I can't find out what is error. anybody can help me ? thank you.
    Thursday, December 31, 2009 2:22 AM

Answers

  • I'm not a C++ Dev, but I did look into Camera support before and from what I can tell the APIs rely on the OEM to support them. In a lot of cases they only support the bare minimum. So in my case my phone supported 2MegaPixels but I could only ever get it to take a 480x640 picture due to the OEM not fully supporting the API. Lets hope MS make the OEMs support the APIs for Win7! Btw this is not an isolated case, there are many APIs that suffer from this problem.
    • Marked as answer by Eric_Su Tuesday, January 5, 2010 6:58 AM
    Thursday, December 31, 2009 7:33 AM