none
How to change size for wince6.0 uvc camera? To still max size picture. RRS feed

  • Question

  • Hi,

    I  implemented USB camera driver for my mini2440 board which has an ARM4I processor. Then I use someone else's MFC class 's interface for my APP. This interface main code like this :

    PreviewCamera(HWND hVideoWnd
    ,LPCTSTR strFileName )
    {
    HRESULT hResult = S_FALSE;
    LONGLONG dwStart = 0, dwEnd = 0;
    WORD     wStartCookie = 1, wEndCookie = 2;
    CRect rectVideo;  
    CComVariant   varCamName; 
    WCHAR      wzDeviceName[ MAX_PATH + 1 ];
    CPropertyBag  PropBag;
    //--define FILTER
    CComPtr<IBaseFilter>            pVideoEncoder;
    CComPtr<IBaseFilter>            pASFMultiplexer;
    CComPtr<IFileSinkFilter>        pFileSinkFilter;
    CComPtr<IDMOWrapperFilter>      pWrapperFilter;

    //release DSHOW interface
    FreeDShow();

    //Create ICaptureGraphBuilder2 
    CHK(m_pCaptureGraphBuilder.CoCreateInstance(CLSID_CaptureGraphBuilder));

    //IGraphBuilder
    CHK(m_pGraphBuilder.CoCreateInstance(CLSID_FilterGraph));

    //3,
    CHK(m_pCaptureGraphBuilder->SetFiltergraph(m_pGraphBuilder ));


    CHK(m_pGraphBuilder.QueryInterface(&m_pMediaControl)); 



    CHK(m_pGraphBuilder.QueryInterface(&m_pMediaSeeking)); 


    CHK(m_pGraphBuilder.QueryInterface(&m_pMediaEvent)); 


    CHK(m_pVideoCaptureFilter.CoCreateInstance(CLSID_VideoCapture));


    CHK(m_pVideoCaptureFilter->QueryInterface(&m_pPropertyBag ));


    //get the first device's name
    if (!GetFirstCameraDriver( wzDeviceName ))
    {
    goto Cleanup;
    }
    varCamName = wzDeviceName;
    if(( varCamName.vt == VT_BSTR ) == NULL ) {
    return FALSE;
    }

    PropBag.Write( L"VCapName", &varCamName );   
    CHK(m_pPropertyBag->Load( &PropBag, NULL ));


    CHK(m_pGraphBuilder->AddFilter( m_pVideoCaptureFilter, L"Video capture source" ));


    CHK(pVideoEncoder.CoCreateInstance( CLSID_DMOWrapperFilter ));
    CHK(pVideoEncoder.QueryInterface( &pWrapperFilter ));
    //load the WMV9 DMO
    CHK(pWrapperFilter->Init( CLSID_CWMV9EncMediaObject, DMOCATEGORY_VIDEO_ENCODER ));

    // 13,将编码器FILTER加入到过滤器图中
    CHK(m_pGraphBuilder->AddFilter( pVideoEncoder, L"WMV9 DMO Encoder" ));


    CHK(m_pCaptureGraphBuilder->SetOutputFileName( &MEDIASUBTYPE_Asf,strFileName, &pASFMultiplexer, &pFileSinkFilter ));



    CHK(m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_PREVIEW,
    &MEDIATYPE_Video, m_pVideoCaptureFilter,
    NULL, NULL ));


    CHK(m_pGraphBuilder.QueryInterface(&m_pVideoWindow));


    m_pVideoWindow->put_Owner((OAHWND)hVideoWnd);
    m_pVideoWindow->put_WindowStyle(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);


    GetClientRect(hVideoWnd,&rectVideo);
    m_pVideoWindow->SetWindowPosition(0,0,rectVideo.Width(),rectVideo.Height());
    m_pVideoWindow->put_Visible(OATRUE);


    CHK(m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pVideoCaptureFilter, pVideoEncoder, pASFMultiplexer ));


    CHK(m_pImageSinkFilter.CoCreateInstance(CLSID_IMGSinkFilter));
    CHK(m_pGraphBuilder->AddFilter(m_pImageSinkFilter, L"Still image filter" ));
    CHK(m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_STILL, &MEDIATYPE_Video, m_pVideoCaptureFilter, NULL, m_pImageSinkFilter ));


    CHK(m_pCaptureGraphBuilder->ControlStream( &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, m_pVideoCaptureFilter, 0, 0 ,0,0 ));


    CHK(m_pMediaControl->Run());
    Sleep(1000);

    Cleanup:

    if (pVideoEncoder != NULL)
    {
    pVideoEncoder.Release();
    pVideoEncoder = NULL;
    }

    if (pASFMultiplexer != NULL)
    {
    pASFMultiplexer.Release();
    pASFMultiplexer = NULL;
    }

    if (pFileSinkFilter != NULL)
    {
    pFileSinkFilter.Release();
    pFileSinkFilter = NULL;
    }

    if (pWrapperFilter != NULL)
    {
    pWrapperFilter.Release();
    pWrapperFilter = NULL;
    }

    if( FAILED( hResult ))
    {
    return FALSE;
    }
    else
    {
    return TRUE;
    }

    }

    it is OK to Preview,but when i use the SnapPicture for still ,i get a picture that size is 352*288( Uncompressed QCIF).  My camera support 1280*748@7fps YUY2 but not applicable MJPEG.  Now I want STILL 1280*748 still picture,How can I do? 

    I find in usbcam.reg there is a statement, ; Default to Uncompressed QCIF if app doesn't specify. 

     

    Friday, August 3, 2012 2:25 PM

All replies