FP Perception 0.1.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
fp_perception::OpenCVDriver Class Reference

OpenCVDriver class for handling video input from a camera using OpenCV. More...

#include <opencv_vision_driver.hpp>

Inheritance diagram for fp_perception::OpenCVDriver:
Inheritance graph
[legend]
Collaboration diagram for fp_perception::OpenCVDriver:
Collaboration graph
[legend]

Public Member Functions

 OpenCVDriver ()
 
 ~OpenCVDriver () override
 
void initialize (const rclcpp::Node::SharedPtr &node) override
 Initialize the driver.
 
void deinitialize () override
 Stop driver streaming.
 
vision_frame captureFrame () override
 Get the latest image data from the driver.
 
void test () override
 Test function to check the driver functionality by writing the image to a file This function creates a "test" directory if it doesn't exist and saves the captured image.
 
- Public Member Functions inherited from fp_perception::DriverBase
virtual ~DriverBase ()=default
 
virtual std::string getName () const
 Get the name of the driver.
 
void check_directory (std::string folder_name)
 Check if the test directory exists, create it if not.
 
const std::filesystem::path check_file (const std::string &file_name)
 

Protected Member Functions

void produce_diagnostics (diagnostic_updater::DiagnosticStatusWrapper &status)
 
- Protected Member Functions inherited from fp_perception::DriverBase
void initialize_base (const rclcpp::Node::SharedPtr &node)
 Initializer base driver in place of constructor due to plugin semantics.
 
bool diagnostics_enabled () const
 
void enable_diagnostics (const std::string &hardware_id, const std::string &task_name, std::function< void(diagnostic_updater::DiagnosticStatusWrapper &)> task, std::chrono::milliseconds period=std::chrono::seconds(1))
 
void disable_diagnostics ()
 

Protected Attributes

int device_id
 
cv::VideoCapture capture_device
 
std::atomic< uint64_t > successful_capture_count_ { 0 }
 
std::atomic< uint64_t > capture_failure_count_ { 0 }
 
- Protected Attributes inherited from fp_perception::DriverBase
rclcpp::Node::SharedPtr node_
 ROS node for the driver.
 
std::string name_
 Name of the driver.
 
std::mutex buffer_mutex_
 Mutex to protect access to the driver data.
 
std::condition_variable buffer_cv_
 Condition variable to notify when new data is available.
 
std::atomic< bool > is_running_ { false }
 Flag to indicate if the driver thread is running.
 
bool diagnostics_enabled_ { false }
 Flag to enable standard ROS diagnostics publishing.
 
std::unique_ptr< diagnostic_updater::Updater > diagnostics_updater_
 
rclcpp::TimerBase::SharedPtr diagnostics_timer_
 

Detailed Description

OpenCVDriver class for handling video input from a camera using OpenCV.

This class is responsible for managing the video input from a camera using OpenCV. It provides methods to start and stop the video stream, as well as retrieve image data.

Constructor & Destructor Documentation

◆ OpenCVDriver()

fp_perception::OpenCVDriver::OpenCVDriver ( )
inline

◆ ~OpenCVDriver()

fp_perception::OpenCVDriver::~OpenCVDriver ( )
inlineoverride

Member Function Documentation

◆ captureFrame()

vision_frame fp_perception::OpenCVDriver::captureFrame ( )
inlineoverridevirtual

Get the latest image data from the driver.

Returns
vision_frame The latest frame captured from the camera.
Exceptions
fp_perception_exceptionif not implemented in derived classes

Implements fp_perception::VisionSourceDriver.

◆ deinitialize()

void fp_perception::OpenCVDriver::deinitialize ( )
inlineoverridevirtual

Stop driver streaming.

Implements fp_perception::DriverBase.

◆ initialize()

void fp_perception::OpenCVDriver::initialize ( const rclcpp::Node::SharedPtr &  node)
inlineoverridevirtual

Initialize the driver.

This function should be overridden in derived classes to provide specific initialization.

Parameters
nodeShared pointer to the ROS node

Reimplemented from fp_perception::DriverBase.

◆ produce_diagnostics()

void fp_perception::OpenCVDriver::produce_diagnostics ( diagnostic_updater::DiagnosticStatusWrapper &  status)
inlineprotected

◆ test()

void fp_perception::OpenCVDriver::test ( )
inlineoverridevirtual

Test function to check the driver functionality by writing the image to a file This function creates a "test" directory if it doesn't exist and saves the captured image.

Reimplemented from fp_perception::DriverBase.

Member Data Documentation

◆ capture_device

cv::VideoCapture fp_perception::OpenCVDriver::capture_device
protected

◆ capture_failure_count_

std::atomic<uint64_t> fp_perception::OpenCVDriver::capture_failure_count_ { 0 }
protected

◆ device_id

int fp_perception::OpenCVDriver::device_id
protected

◆ successful_capture_count_

std::atomic<uint64_t> fp_perception::OpenCVDriver::successful_capture_count_ { 0 }
protected

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