cameradirectshowvideo-captureccd

VFW_E_NOT_IN_GRAPH in directshow's video-capture


Me again, trying to use directShow. I tried to implement an example from a camera-distributor to read the camera (I would like to get frames in Form of an Byte-Array) and am getting a VFW_E_NOT_IN_GRAPH-Error when trying to connect the pins.

I already searched and now know, that that means, I didn't add a specific Filter to the graphbuilder (or the filter I used isn't compatible?), but I added a Filter and can't see any differences to the sample... however, the sample isn't a project, but only code-scraps, so I think I may have forgotten any initialization...

Could you please take a look at this and tell me whether you find an error? Everything works find without error, just the last hr is filled with 0x8004025F and nothing happens (I made a stop-point within DoRenderSample-method):

    HRESULT hr = S_OK;
    IBaseFilter* pFilter=0;
    hr=CreateKernelFilter(
        CLSID_VideoInputDeviceCategory,
            L"Videology USB-C Camera",
            &pFilter
    );
    CoInitialize(NULL);
//  CComQIPtr<IVideology20K1XX> pKs(pFilter);
    CComQIPtr<IVideologyCommon> pKs( pFilter );
    if(pFilter==0)return;
//  hr=pKs->SetWhiteBalanceMode(wbAuto);

    CBitmapRenderer *m_pSnapshotter = new CBitmapRenderer( _T("Bitmap renderer"), NULL, &hr );

    if( FAILED(hr) )
    {
        ASSERT("Couldn't create bitmap renderer.");
        return;
    }
    m_pSnapshotter->SetCallback( (IBitmapCallback*) this );
    CComQIPtr< IBaseFilter > pGrabBase( m_pSnapshotter );
    IGraphBuilder*  m_pGraphBuilder=0;
     hr = CoCreateInstance(CLSID_FilterGraph, NULL,
    CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&m_pGraphBuilder);
    hr = m_pGraphBuilder->AddFilter( pGrabBase, L"Snapshot" );

    CComPtr<IPin> pOutPin;
    hr= pFilter->FindPin( L"1", &pOutPin );

    CBasePin* pInPin = m_pSnapshotter->GetPin( 0 );
    hr = m_pGraphBuilder->Connect( pOutPin, pInPin );

I hope I didn't forget any important informations... (Using C++-Builder from embarcadero XE2 16 and DirectShow9 from 2005 I think)


Solution

  • The error code tells you what is wrong. VFW_E_NOT_IN_GRAPH, something is not in graph. You connect two pins, which belong to two filters. One of the filters is not in graph. As you add pGrabBase a few lines above, then the other filter is not in the graph. Add it as well prior to connecting pins.