7 #ifndef IFM3D_FG_FRAMEGRABBER_H
8 #define IFM3D_FG_FRAMEGRABBER_H
13 #include <ifm3d/device/device.h>
14 #include <ifm3d/device/err.h>
15 #include <ifm3d/device/pcic_command.h>
16 #include <ifm3d/fg/buffer.h>
17 #include <ifm3d/fg/frame.h>
18 #include <ifm3d/fg/module_frame_grabber.h>
19 #include <ifm3d/fg/organizer.h>
34 using Ptr = std::shared_ptr<FrameGrabber>;
35 using NewFrameCallback = std::function<void(Frame::Ptr)>;
36 using AsyncErrorCallback = std::function<void(
int,
const std::string&)>;
37 using AsyncNotificationCallback =
38 std::function<void(
const std::string&,
const std::string&)>;
39 using ErrorCallback = std::function<void(
const ifm3d::Error&)>;
41 std::vector<std::variant<std::uint64_t, int, ifm3d::buffer_id>>;
42 using PCICCommandResponse =
43 std::variant<std::monostate, std::string, std::vector<std::uint8_t>>;
52 std::optional<std::uint16_t> pcic_port = std::nullopt);
111 const BufferList& buffers,
112 const std::optional<json>& schema = std::nullopt);
119 std::shared_future<void>
Stop();
158 void OnError(ErrorCallback callback =
nullptr);
190 std::unique_ptr<Impl> _impl;
Exception wrapper for library and system errors encountered by the library.
Definition: err.h:115
Implements a TCP FrameGrabber connected to the device passed to its ctor.
Definition: frame_grabber.h:32
std::shared_future< void > SWTrigger()
Triggers the device for image acquisition.
bool IsMasking()
return masking flag
std::shared_future< void > Start(const BufferList &buffers, const std::optional< json > &schema=std::nullopt)
Starts the worker thread for streaming in pixel data from the device.
bool IsRunning()
Returns true if the worker thread is currently running.
void OnAsyncError(AsyncErrorCallback callback=nullptr)
This function will enable the async error messages on device.
std::shared_future< void > Stop()
Stops the worker thread for streaming in pixel data from the device.
FrameGrabber(ifm3d::Device::Ptr cam, std::optional< std::uint16_t > pcic_port=std::nullopt)
Stores a reference to the passed in Device shared pointer.
std::shared_future< Frame::Ptr > WaitForFrame()
Returns a future that will resolve when a new frame is available.
void OnAsyncNotification(AsyncNotificationCallback callback=nullptr)
This function will enable the async notifications on device.
virtual ~FrameGrabber()
Cleans up resources held by the framegrabbing thread object and blocks until the operating system thr...
void OnNewFrame(NewFrameCallback callback=nullptr)
The callback will be executed whenever a new frame is available.
void OnError(ErrorCallback callback=nullptr)
The callback will be executed whenever an error condition occur while grabbing the data from device.
void SetMasking(bool mask)
enable/disable masking on supported buffer
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.
std::shared_future< PCICCommandResponse > SendCommand(const PCICCommand &command)
Sends a command to the frame grabber.
Definition: pcic_command.h:11