ifm3d
ifm3d::FrameGrabber Class Reference

#include <ifm3d/fg/frame_grabber.h>

Public Types

using Ptr = std::shared_ptr< FrameGrabber >
 
using NewFrameCallback = std::function< void(Frame::Ptr)>
 
using AsyncErrorCallback = std::function< void(int, const std::string &)>
 
using AsyncNotificationCallback = std::function< void(const std::string &, const std::string &)>
 
using BufferList = std::vector< std::variant< std::uint64_t, int, ifm3d::buffer_id > >
 
using ErrorCallback = std::function< void(const ifm3d::Error &)>
 

Public Member Functions

 FrameGrabber (ifm3d::Device::Ptr cam, std::optional< std::uint16_t > pcic_port=std::nullopt)
 Stores a reference to the passed in Device shared pointer. More...
 
virtual ~FrameGrabber ()
 Cleans up resources held by the framegrabbing thread object and blocks until the operating system thread stops.
 
 FrameGrabber (FrameGrabber &&)=delete
 
FrameGrabberoperator= (FrameGrabber &&)=delete
 
 FrameGrabber (FrameGrabber &)=delete
 
FrameGrabberoperator= (const FrameGrabber &)=delete
 
std::shared_future< void > SWTrigger ()
 Triggers the device for image acquisition. More...
 
void OnNewFrame (NewFrameCallback callback=nullptr)
 The callback will be executed whenever a new frame is available. More...
 
std::shared_future< void > Start (const BufferList &buffers, const std::optional< json > &pcicFormat=std::nullopt)
 Starts the worker thread for streaming in pixel data from the device. More...
 
std::shared_future< void > Stop ()
 Stops the worker thread for streaming in pixel data from the device. More...
 
bool IsRunning ()
 Returns true if the worker thread is currently running.
 
std::shared_future< Frame::Ptr > WaitForFrame ()
 Returns a future that will resolve when a new frame is available.
 
void SetOrganizer (std::unique_ptr< Organizer > organizer)
 This allows to override the Organizer which is used for extracting the data from the raw PCIC stream. More...
 
void OnAsyncError (AsyncErrorCallback callback=nullptr)
 This function will enable the async error messages on device. More...
 
void OnAsyncNotification (AsyncNotificationCallback callback=nullptr)
 This function will enable the async notifications on device. More...
 
void OnError (ErrorCallback callback=nullptr)
 The callback will be executed whenever an error condition occur while grabbing the data from device.
 
void SetMasking (const bool mask)
 enable/disable masking on supported buffer More...
 
bool IsMasking ()
 return masking flag
 

Detailed Description

Implements a TCP FrameGrabber connected to the device passed to its ctor

Constructor & Destructor Documentation

◆ FrameGrabber()

ifm3d::FrameGrabber::FrameGrabber ( ifm3d::Device::Ptr  cam,
std::optional< std::uint16_t >  pcic_port = std::nullopt 
)

Stores a reference to the passed in Device shared pointer.

Parameters
[in]camThe Device instance to grab frames from
[in]pcic_portTCP port for the pcic connection

Member Function Documentation

◆ OnAsyncError()

void ifm3d::FrameGrabber::OnAsyncError ( AsyncErrorCallback  callback = nullptr)

This function will enable the async error messages on device.

The callback will be executed whenever a async error are avaliable. It receives a error code and error string to the received async error as an argument.

◆ OnAsyncNotification()

void ifm3d::FrameGrabber::OnAsyncNotification ( AsyncNotificationCallback  callback = nullptr)

This function will enable the async notifications on device.

The callback will be executed whenever a async notification is avaliable. It receives a message id and payload string

◆ OnNewFrame()

void ifm3d::FrameGrabber::OnNewFrame ( NewFrameCallback  callback = nullptr)

The callback will be executed whenever a new frame is available.

It receives a Frame::Ptr to the received frame as an argument.

◆ SetMasking()

void ifm3d::FrameGrabber::SetMasking ( const bool  mask)

enable/disable masking on supported buffer

Parameters
[in]maskflag to enable/disable masking Note: ifm3d::buffer_id::CONFIDENCE_IMAGE should be in schema set passed to ifm3d::FrameGrabber::Start method

◆ SetOrganizer()

void ifm3d::FrameGrabber::SetOrganizer ( std::unique_ptr< Organizer organizer)

This allows to override the Organizer which is used for extracting the data from the raw PCIC stream.

Parameters
organizerThe new organizer to be used

◆ Start()

std::shared_future<void> ifm3d::FrameGrabber::Start ( const BufferList &  buffers,
const std::optional< json > &  pcicFormat = std::nullopt 
)

Starts the worker thread for streaming in pixel data from the device.

Returns a future that will resolve when the FrameGrabber is ready to receive frames.

Parameters
[in]buffersset of buffer_ids for receiving, passing in an empty set will received all available images. The buffer_ids are specific to the current Organizer. See buffer_id for a list of buffer_ids available with the default Organizer
[in]pcicFormatallows to manually set a PCIC schema for asynchronous results. See ifm3d::make_schema for generation logic of the default pcicFormat. Manually setting the pcicFormat should rarely be needed and most usecases should be covered by the default generated pcicFormat.

Note: The FrameGrabber is relying on some specific formatting rules, if they are missing from the schema the FrameGrabber will not be able to extract the image data.

◆ Stop()

std::shared_future<void> ifm3d::FrameGrabber::Stop ( )

Stops the worker thread for streaming in pixel data from the device.

Returns a future which will resolve when framegrabber stops.

◆ SWTrigger()

std::shared_future<void> ifm3d::FrameGrabber::SWTrigger ( )

Triggers the device for image acquisition.

You should be sure to set the TriggerMode for your application to SW in order for this to be effective. This function simply does the triggering, data are still received asynchronously via WaitForFrame().

Calling this function when the device is not in SW trigger mode or on a device that does not support software-trigger should result in a NOOP and no error will be returned (no exceptions thrown). However, we do not recommend calling this function in a tight framegrabbing loop when you know it is not needed. The "cost" of the NOOP is undefined and incurring it is not recommended.


The documentation for this class was generated from the following file: