IC Imaging Control C++

GrabberSinkType::setSinkMode Method

GrabberSinkType::setSinkMode Method

This method sets a new sink mode.
Syntax:
virtual tSinkModes setSinkMode( tSinkModes mode );
Parameter Description
mode

Specifies the new mode to set.

Return value:

The current sink mode. On success, the returned sink mode is identical to the sink mode passed to the function.

Remarks:

This method is used to pause and restart a image stream for avi capturing and frame grabbing. After the sink mode is set to ePAUSE, frame grabbing and avi saving will not start before the sink mode is set to eRUN.

If the sink mode is set to ePAUSE and startLive() is called, the live video is displayed (if enabled) but no frames are passed to the sink. Now, an application can pass eRun to setSinkMode to start avi capturing or frame grabbing without latency because the image stream is already initialized.

Example:

This example demonstrates how to set the sink mode after it was created.

// Create an MediaStreamSink to record an AVI file with the selected CoDec
tMediaStreamSinkPtr pSink = MediaStreamSink::create( 
    MediaStreamContainer::create( MSC_AviContainer ), pCodecs->at( choice ) );
 
// Set the filename.
pSink->setFilename( filename );
 
// The sink is initially paused, so that no video data is written to the file.
pSink->setSinkMode( GrabberSinkType::ePAUSE );
 
// Set pSink as the current sink.
grabber.setSinkType( pSink );
 
// Start the live mode. The live video will be displayed but no images will be written
// to the AVI file because pSink is in pause mode.
if( !grabber.startLive( true ) )
{
    std::cerr << grabber.getLastError().toString() << std::endl;
    return -1;
}
 
std::cout << "Press [enter] to start capturing!";
std::cin.get();
 
// Start the sink. The image stream is written to the AVI file.
pSink->setSinkMode(GrabberSinkType::eRUN );
 
std::cout << "Video recording started." << std::endl;
std::cout << "Press [enter] to stop capturing!";
std::cin.get();
 
// Pause the sink. This stops writing the image stream to the AVI file.
// A subsequent call to setSinkMode with GrabberSinkType::eRUN as the
// parameter would restart AVI recording.
pSink->setSinkMode(GrabberSinkType::ePAUSE );
 
std::cout << "Video recording stopped." << std::endl;
 
// Stop the live mode. This stops writing images to the AVI file if the mode is not
// GrabberSinkType::ePAUSE. The AVI file is closed.
grabber.stopLive();
See also: GrabberSinkType::getSinkMode, GrabberSinkType::tSinkModes

<< GrabberSinkType

Get in touch with us


About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

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

Automated Imaging Association ISO 9001:2015 certified

Contact us