none
Alternative for ISampleGrabber

    General discussion

  • Hi everyone

    I'm developing a program that captures video stream from a webcam, and when needed it also captures this stream into an avi file, my question is:

    I want to capture also still images from this video stream when a button is clicked, the only way for doing this is by using ISampleGrabber which is now obsolete on windows 7 because of missing the header file "qedit.h" in the newer versions of Windows SDK

    Is there another solution to grab a still image from this video stream without using ISampleGrabber ???

    OR even by using it, but how to use it on windows 7 and visual studio 2010

     

    Thanks in advance

     

    Monday, November 29, 2010 9:38 PM

All replies

  • ISamplerGrabber is still in Windows 7, you just need the interface definitions.  Of course you can always write your own filter that takes its place.

     

     

    interface ISampleGrabberCB : public IUnknown
    {
    	virtual STDMETHODIMP SampleCB( double SampleTime, IMediaSample *pSample ) = 0;
    	virtual STDMETHODIMP BufferCB( double SampleTime, BYTE *pBuffer, long BufferLen ) = 0;
    };
    
    
    
    interface ISampleGrabber : public IUnknown
    {
    	virtual HRESULT STDMETHODCALLTYPE SetOneShot( BOOL OneShot ) = 0;
    	virtual HRESULT STDMETHODCALLTYPE SetMediaType( const AM_MEDIA_TYPE *pType ) = 0;
    	virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType( AM_MEDIA_TYPE *pType ) = 0;
    	virtual HRESULT STDMETHODCALLTYPE SetBufferSamples( BOOL BufferThem ) = 0;
    	virtual HRESULT STDMETHODCALLTYPE GetCurrentBuffer( long *pBufferSize, long *pBuffer ) = 0;
    	virtual HRESULT STDMETHODCALLTYPE GetCurrentSample( IMediaSample **ppSample ) = 0;
    	virtual HRESULT STDMETHODCALLTYPE SetCallback( ISampleGrabberCB *pCallback, long WhichMethodToCallback ) = 0;
    };
    
    
    static const IID IID_ISampleGrabber = { 0x6B652FFF, 0x11FE, 0x4fce, { 0x92, 0xAD, 0x02, 0x66, 0xB5, 0xD7, 0xC7, 0x8F } };
    static const IID IID_ISampleGrabberCB = { 0x0579154A, 0x2B53, 0x4994, { 0xB0, 0xD0, 0xE7, 0x73, 0x14, 0x8E, 0xFF, 0x85 } };
    static const CLSID CLSID_SampleGrabber = { 0xC1F400A0, 0x3F08, 0x11d3, { 0x9F, 0x0B, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37 } };
    

     


    www.chrisnet.net
    Monday, November 29, 2010 10:59 PM
  • Thank you Chris for you helpful reply

     

    but I'm now trying to compile the sample code obtained from MSDN

    http://msdn.microsoft.com/en-us/library/dd407288%28v=VS.85%29.aspx

     

    and I used the code in your post as my qedit.h file

    but i got the following errors and i don't know that they mean

    error C2787: 'ISampleGrabber' : no GUID has been associated with this object

    error C3861: 'ConnectFilters': identifier not found

    error C3861: 'ConnectFilters': identifier not found

    error C3861: 'FreeMediaType': identifier not found

     

    please help me figuring out these errors to use this sample as a base of my work

     

    thanks so much for you help

    Tuesday, November 30, 2010 11:02 AM
  • MrX, I've the same errors for a similar application..

    Somebody HELP please!!!

    Tuesday, November 01, 2011 9:17 PM
  • ConnectFilters you can find here:

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd387915(v=vs.85).aspx its no API function.

     

    Get the interface this way:

    http://msdn.microsoft.com/en-us/library/windows/desktop/dd375791(v=VS.85).aspx   Find an Interface on a Filter or Pin.

     

     

    If you use MASM the access is possible this way:

    ISampleGrabber             STRUCT DWORD
        ISampleGrabber_QueryInterface          comethod3       ?
        ISampleGrabber_AddRef          comethod1       ?
        ISampleGrabber_Release          comethod1       ?

        ISampleGrabber_SetOneShot  comethod2       ?
        ISampleGrabber_SetMediaType  comethod2       ?
        ISampleGrabber_GetConnectedMediaType comethod2       ?
        ISampleGrabber_SetBufferSamples  comethod2       ?
        ISampleGrabber_GetCurrentBuffer  comethod3       ?
        ISampleGrabber_GetCurrentSample  comethod2       ?      
        ISampleGrabber_SetCallback  comethod1       ?
    ISampleGrabber ENDS   


    ; provide the Sample Grabber:

                                         ; CoCreateInstance(CLSID_SampleGrabber,
                                         ;   NULL,
                                         ;   CLSCTX_INPROC,
                                         ;   IID_IBaseFilter,
                                         ;   (LPVOID *)&pSampleGrabberFilter);
                                        
                                    invoke CoCreateInstance, offset CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, \
                                                           offset IID_IBaseFilter, ADDR pSampleGrabberFilter
                                        .if eax ;  error
                                           ret
                                        .endif

    ; add to your filter graph:
                                            ;  pGraphBuilder->AddFilter(pSampleGrabberFilter,  L"Sample Grabber");
                                                mov eax,pGraphBuilder
                                                .if eax && pSampleGrabberFilter
                                                  mov edx,[eax]
                                                  invoke IGraphBuilder.IGraphBuilder_AddFilter[edx], eax, pSampleGrabberFilter, _STR("Sample Grabber")                                                
                                                .endif 


    ; use the methods this way:
                                                ; SampleGrabber::SetBufferSamples
                                            mov ebx, pSampleGrabber
                                            .if ebx
                                              mov edi,[ebx]                 
                                              invoke ISampleGrabber.ISampleGrabber_SetBufferSamples[edi], ebx, TRUE
                                            .endif

     

    Wednesday, November 02, 2011 3:13 AM
  • Wednesday, November 02, 2011 10:33 AM
  • Thank you Chris for you helpful reply

     

    but I'm now trying to compile the sample code obtained from MSDN

    http://msdn.microsoft.com/en-us/library/dd407288%28v=VS.85%29.aspx

     

    and I used the code in your post as my qedit.h file

    but i got the following errors and i don't know that they mean

    error C2787: 'ISampleGrabber' : no GUID has been associated with this object

    error C3861: 'ConnectFilters': identifier not found

    error C3861: 'ConnectFilters': identifier not found

    error C3861: 'FreeMediaType': identifier not found

     

    please help me figuring out these errors to use this sample as a base of my work

     

    thanks so much for you help

    me too thank you.
    Friday, May 18, 2012 10:05 AM
  • You can feed your stream to a VMR9 in windowless mode and use GetCurrentImage. If the VMR9 isn't what you want for your display, you can use a tee, feed one side to whatever you do want, and the other to the VMR9. Have the VMR9 use a zero-by-zero output rectangle (or any other trick you like for hiding it). GetCurrentImage will still work. Don't call it too often, though, as it reads from video ram and will slow you down intolerably if you do.

    Stevens Miller http://www.withoutsupervision.com

    Friday, May 18, 2012 11:05 AM
  • You can feed your stream to a VMR9 in windowless mode and use GetCurrentImage. If the VMR9 isn't what you want for your display, you can use a tee, feed one side to whatever you do want, and the other to the VMR9. Have the VMR9 use a zero-by-zero output rectangle (or any other trick you like for hiding it). GetCurrentImage will still work. Don't call it too often, though, as it reads from video ram and will slow you down intolerably if you do.

    Stevens Miller http://www.withoutsupervision.com

    Hello again and thank you...

    So to sum up... I shouldn't use VMR9 if I want to create a virtual webcam... that gets continuous frames/images from a webcam and push them into the virtual webcam.

    Monday, May 21, 2012 12:27 PM
  • So to sum up... I shouldn't use VMR9 if I want to create a virtual webcam... that gets continuous frames/images from a webcam and push them into the virtual webcam.

    Carlesis, I think you're in the wrong thread. The OP was asking about capturing still images when a button is clicked. GetCurrentImage will work fine for that.

    Stevens Miller http://www.withoutsupervision.com

    Monday, May 21, 2012 12:52 PM
  • ok I will open a thread about the ISampleGrabber.

    Thank you.

    Wednesday, May 23, 2012 8:44 AM