IC Imaging Control C++

FrameHandlerSink::snapImages Method

FrameHandlerSink::snapImages Method

Queues up a snap job, thus allowing a number of frames to be copied into the MemBufferCollection. The method returns when either the specified number of frames are snapped, or the timeout has occurred.
Error snapImages( unsigned int count, DWORD timeout = INFINITE );
Parameter Description

Number of frames to copy into the MemBufferCollection.


Number of milliseconds to wait before returning from this function, should no frames be available from the device.

Return Value:

An error object reporting the status of the performed operation. Use Error::isError to check whether the operation was successful.


If the method runs into a timeout, it is not guaranteed, that count frames are snapped. In the case of a timeout, it is possible that by the time this method has returned, GrabberListener::frameReady has already been called.

If live mode has not been started, this method starts live mode before grabbing the image and stops live mode afterward. Because starting live mode is a very time-consuming operation, it is usually preferable to start live mode before calling snapImage more than once.


The following example shows how to snap an image and save it to a bitmap file. It assumes that a FrameHandlerSink, containing a MemBufferCollection has been setup using FrameHandlerSink::create and assigned to the grabber with Grabber::setSinkType.

// This cast is only valid, if we have previously assigned a FrameHandlerSink to the grabber.
tFrameHandlerSinkPtr pSink = static_smart_ptr_cast<FrameHandlerSink>( m_Grabber.getSinkTypePtr() );
// Snap one image and copy it into the MemBufferCollection.
Error e = pSink->snapImages( 1 );
if( e.isError() )
    // Display an error.
    ::MessageBoxA( 0, e.toString().c_str(), "Error", MB_OK|MB_ICONERROR );
    // Save the image to a bitmap file.
    saveToFileBMP( *pSink->getLastAcqMemBuffer(), "image.bmp" );

See also: FrameHandlerSink, FrameHandlerSink::snapImagesAsync

<< FrameHandlerSink

Get in touch with us

About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, video converters and embedded vision components for factory automation, quality assurance, medicine, science, security and a variety of other markets.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE, MIPI interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

ISO 9001:2015 certified MVTEC | Edge AI + Vision Alliance | EMVA

Contact us