Skip to main content
GameDev.net gamedev.net
🔒 Locked

Capturing a still image from my camera into memory using DirectShow

Started by Staryon Jul 13, 2009 at 9:49 AM 0 replies 1.5k views
Original Post
Staryon
Staryon
Hi all, I hope this is the right forum. I'm developing a library for smartphones in C++ that captures an still image from the camera. I found an example in the Windows Mobile SDK that does that. It can be found here: C:\Program Files\Windows Mobile 5.0 SDK R2\Samples\PocketPC\CPP\Win32\Cameracapture My only problem is the image is captured into a file, and I need to have it in memory for further processing. However since I'm not familiar with DirectShow, I was wondering if you guys can help me in what I need to do to put it into memory. Here is the code that creates a file with the image:


CGraphManager::CaptureStillImageInternal()
{
	HRESULT hr = S_OK;
	CComPtr<IFileSinkFilter> pFileSink;
	CComPtr<IUnknown>		 pUnkCaptureFilter;
	CComPtr<IPin>			 pStillPin;
	CComPtr<IAMVideoControl> pVideoControl;

    if(( m_pCaptureGraphBuilder == NULL ) || ( m_fGraphBuilt == FALSE ))
    {
        ERR( E_FAIL );
    }

	CHK( m_pImageSinkFilter.QueryInterface( &pFileSink ));
	CHK( pFileSink->SetFileName( L"\\test.jpg", NULL ));

	CHK( m_pVideoCaptureFilter.QueryInterface( &pUnkCaptureFilter ));
	CHK( m_pCaptureGraphBuilder->FindPin( pUnkCaptureFilter, PINDIR_OUTPUT, &PIN_CATEGORY_STILL, &MEDIATYPE_Video, FALSE, 0, &pStillPin ));
	CHK( m_pVideoCaptureFilter.QueryInterface( &pVideoControl ));
	CHK( pVideoControl->SetMode( pStillPin, VideoControlFlag_Trigger ));

Cleanup:
	if( FAILED( hr ))
	{
		NotifyMessage( MESSAGE_ERROR, L"Capturing a still image failed" );
	}
    return hr;
}

There has to be a place somewhere there where the image is stored into memory but I cannot find it. Hopefully with that piece of code should be enough for you guys to figure out how to get it. If you need more source code please let me know. Thanks a lot

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.