FrameHandlerSink::create Method

Creates a new FrameHandlerSink.
Syntax:
static tFrameHandlerSinkPtr create( unsigned int countBuffers );
          static tFrameHandlerSinkPtr create( IFrameFilter* pFilter,
                                              unsigned int countBuffers = 0 );
          static tFrameHandlerSinkPtr create( const tFrameFilterList& lst,
                                              unsigned int countBuffers = 0 );

          static tFrameHandlerSinkPtr create( IFrameFilter* pFilter,
                                              const FrameTypeInfo& type,
                                              unsigned int countBuffers );
          static tFrameHandlerSinkPtr create( const tFrameFilterList& lst,
                                              const FrameTypeInfo& type,
                                              unsigned int countBuffers );
          static tFrameHandlerSinkPtr create( IFrameFilter* pFilter,
                                              const smart_ptr<MemBufferCollection>& pCol );
          static tFrameHandlerSinkPtr create( const tFrameFilterList& lst,
                                              const smart_ptr<MemBufferCollection>& pCol );

          static tFrameHandlerSinkPtr create( const smart_ptr<MemBufferCollection>& pCol );
          static tFrameHandlerSinkPtr create( const FrameTypeInfo& type,
                                              unsigned int countBuffers );
          static tFrameHandlerSinkPtr create( tColorformatEnum colorformat,
                                              unsigned int countBuffers );
          static tFrameHandlerSinkPtr create( const FrameTypeInfoArray& acceptedInputTypes,
                                              unsigned int countBuffers );

          static tFrameHandlerSinkPtr create( const tCreateData& data );

Parameter Description
countBuffers

The number of buffers to create in the MemBufferCollection.

When countBuffers is 0, no MemBufferCollection is created. In this case, the frame filter (or the last filter of the filter chain) is called with no destination frame. In this kind of filter, you can perform image analysis similar to the GrabberListener approach, but the time of one copy operation is saved, because the image data is not copied into the MemBufferCollection.

pFilter

The frame filter for the transform/copy operation.

lst

A tFrameFilterList of frame filters. The filters in this list are connected in a filter chain that is used to transform the image data.

type

The image data type in the MemBufferCollection.

colorformat

The image data color format in the MemBufferCollection.

pCol

Pointer to a custom MemBufferCollection.

acceptedInputTypes

A FrameTypeInfoArray of allowed frame types that this sink accepts. When the live video is started, one of these types is selected in order to minimize the necessary conversion operations.

data

To duplicate a FrameHandlerSink, you can call FrameHandlerSink::getCreateData to access the parameters with which it was created. You can use this tCreateData structure to initialize another FrameHandlerSink.

Return Value:

A pointer to the new FrameHandlerSink, or 0, if an error occurred.

Examples:

The simplest way to create a FrameHandlerSink is to only specify the number of MemBuffers in the MemBufferCollection of the sink:

// Create a sink containing a MemBufferCollection of 5 buffers.
// The buffer format will be selected automatically.
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( 5 );
// Set the sink.
m_Grabber.setSinkType( pSink );

You can select the format of the MemBuffers in the MemBufferCollection by specifying a FrameTypeInfo. Because FrameTypeInfo has a constructor that takes a tColorformatEnum, you can use eRGB24, eRGB32 to select the buffer format:

// Create a sink containing a MemBufferCollection of 3 RGB24 buffers.
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eRGB24, 3 );
// Set the sink.
m_Grabber.setSinkType( pSink );

You can customize the copy operation to the MemBuffers using frame filters. Use FilterLoader to load a frame filter from stdfilters.ftf:

// Load the Rotate/Flip filter from stdfilters.ftf
m_pRotFlipFilter = FilterLoader::createFilter( "Rotate Flip" );
// Enable vertical flip.
m_pRotFlipFilter->setParameter( "flipv", true );
// Create a sink, using this frame filter to copy the image data into
// a MemBufferCollection of 5 RGB24 buffers.
//
// Note: m_pRotFlipFilter.get() is used to get a plain pointer from the smart_com.
//       The smart_com must not be deleted, while it is being used by the sink.
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( m_pRotFlipFilter.get(), eRGB24, 5 );
// Set the sink.
m_Grabber.setSinkType( pSink );

To create a filter chain, load multiple filters and insert them into a tFrameFilterList. If you pass a list of frame filters to FrameHandlerSink::create, the transform functions of the filters will be called to transform and copy the image data into the MemBufferCollection:

// Load the Rotate/Flip filter from stdfilters.ftf
m_pRotFlipFilter = FilterLoader::createFilter( "Rotate Flip" );
// Enable horizontal flip.
m_pRotFlipFilter->setParameter( "fliph", true );
// Load the ROI filter from stdfilters.ftf
m_pROIFilter = FilterLoader::createFilter( "ROI" );
// Set an ROI.
m_pROIFilter->setParameter( "X", 10 );
m_pROIFilter->setParameter( "Y", 10 );
m_pROIFilter->setParameter( "Width", 100 );
m_pROIFilter->setParameter( "Height", 100 );
// Create a filter chain using these two filters, by putting them into a
// tFrameFilterList.
//
// Note: .get() is used to get a plain pointer from the smart_com.
//       The smart_com's must not be deleted while it is being used by the sink.
tFrameFilterList filterChain;
filterChain.push_back( m_pRotFlipFilter.get() );
filterChain.push_back( m_pROIFilter.get() );
// Create a sink, using this frame filter chain to copy the image data into
// a MemBufferCollection of 3 Y800 buffers.
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( filterChain, eY800, 3 );
// Set the sink.
m_Grabber.setSinkType( pSink );

See also: FrameHandlerSink, tFrameHandlerSinkPtr, MemBufferCollection, IFrameFilter, FrameTypeInfo, FrameTypeInfoArray, tFrameFilterList

<< FrameHandlerSink