PDA

View Full Version : snapImages()



Unregistered
January 12, 2004, 22:04:54
I have an application in which the user can switch between three modes. In Mode A, live video (with an overlay) is displayed on screen. In Mode B, the video is saved to an AVI. In Mode C, I used a frameReady listener to analyse the (monochrome) video and colour it in realtime based on the information in the image.

The application starts in Mode A, and everything works fine. However, if the user goes into Mode B, and /then/ back into Mode A, any call to snapImages() produces its "The timeout elapsed before all images could be snapped" error. Going into Mode C then A has no such effect.

The (simplified) code used to switch between modes is as follows:



m_Grabber.removeListener(pcListener, DShowLib::GrabberListener::eFRAMEREADY);
m_Grabber.removeListener(pcListener, DShowLib::GrabberListener::eOVERLAYCALLBACK);

m_Grabber.stopLive();

if (pcListener)
{
pcListener->present = false;
delete pcListener;
pcListener = NULL;
}

...

if (modeA)
{
m_Grabber.addListener(pcListener, DShowLib::GrabberListener::eOVERLAYCALLBACK );
m_Grabber.setSinkType(DShowLib::FrameGrabberSink( DShowLib::FrameGrabberSink::tFrameGrabberMode::eSN AP, DShowLib::eRGB24 ) );
m_Grabber.setHWND(GetActiveView()->GetSafeHwnd());
m_Grabber.startLive(true);
}
if (modeB)
{
DShowLib::Grabber::tCompressorListPtr m_pCompressorList = m_Grabber.getAvailableVideoCompressors();
DShowLib::AviSink AviSink( saveTo.operator LPCTSTR(), m_pCompressorList->operator[]( pDoc->settings.capture.codec ) );
m_Grabber.setSinkType( AviSink );
m_Grabber.getSinkType().setSinkMode(DShowLib::Grab berSinkType::eRUN);
m_Grabber.addListener(pcListener, DShowLib::GrabberListener::eOVERLAYCALLBACK );
m_Grabber.setHWND(GetActiveView()->GetSafeHwnd());
m_Grabber.startLive(true);
}
if (modeC)
{
m_Grabber.addListener(pcListener, DShowLib::GrabberListener::eFRAMEREADY | DShowLib::GrabberListener::eOVERLAYCALLBACK );
m_Grabber.setSinkType(DShowLib::FrameGrabberSink( DShowLib::FrameGrabberSink::tFrameGrabberMode::eGR AB, DShowLib::eRGB24 ) );
m_Grabber.setActiveMemBufferCollection( m_pMemBuffColl );
m_Grabber.startLive(false);
}



snapImages() only claims to need unlocked buffers and eSNAP sinktype, and both of these conditions should be fulfilled by going into Mode A, irrelevent of whether you've been in Mode C beforehand?

Help!

Stefan Geissler
January 13, 2004, 08:48:52
Hello,

I tried to reproduce your problem, but it does not occur on my computer (may be, because i could not reproduce all circumstances of your program).

The mode switch is implemented as follows:


m_cGrabber.stopLive(); // Is performed normally in the radio button handlers to change the mode

m_cGrabber.removeListener(&m_cListener, DShowLib::GrabberListener::eFRAMEREADY);
m_cGrabber.removeListener(&m_cListener, DShowLib::GrabberListener::eOVERLAYCALLBACK);

switch( m_iMode )
{
case A : m_cGrabber.setSinkType(DShowLib::FrameGrabberSink
( DShowLib::FrameGrabberSink::tFrameGrabberMode::eSN AP,DShowLib::eRGB24 ) );
m_cGrabber.startLive();
break;

case B : DShowLib::AviSink AviSink( "Test.AVI",GUID_NULL );
m_cGrabber.setSinkType( AviSink );
m_cGrabber.startLive();
}

I think, the difference to your program is, that i call stopLive() before i try to remove the listeners.
The membuffer is set up after the video capture device and the video format has been selected.

The whole project is attached to this entry.

You may send your project as zipped file to support at imagingcontrol dot com, so i can check it.