8#include <RobotsIO/Utils/SegmentationYarpPort.h>
10#include <yarp/cv/Cv.h>
12using namespace RobotsIO::Utils;
13using namespace yarp::cv;
14using namespace yarp::sig;
18 segmentation_in_(port_prefix +
"/segmentation:i"),
19 rgb_out_(port_prefix +
"/rgb:o"),
20 provide_rgb_(provide_rgb)
24SegmentationYarpPort::~SegmentationYarpPort()
28bool SegmentationYarpPort::reset()
30 segmentation_in_.flush();
36bool SegmentationYarpPort::is_stepping_required()
const
50 ImageOf<PixelMono>* yarp_mask = segmentation_in_.receive_data(blocking);
52 if (yarp_mask ==
nullptr)
54 cv_mask_in_ = cv::Mat();
55 return std::make_pair(
false, cv::Mat());
58 yarp_mask_in_.copy(*yarp_mask);
59 cv_mask_in_ = toCvMat(yarp_mask_in_);
60 time_stamp_mask_in_ = segmentation_in_.time_stamp();
62 return std::make_pair(
true, cv_mask_in_);
68 if (cv_mask_in_.empty())
69 return std::make_pair(
false, cv::Mat());
71 return std::make_pair(
true, cv_mask_in_);
77 return time_stamp_mask_in_;
86 cv_rgb_out_ = image.clone();
87 yarp_rgb_out_ = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(cv_rgb_out_);
89 rgb_out_.set_time_stamp(timestamp);
90 rgb_out_.send_data(yarp_rgb_out_);
std::pair< bool, cv::Mat > segmentation(const bool &blocking) override
virtual void set_rgb_image(const cv::Mat &image, const double ×tamp) override
int get_frames_between_iterations() const override
SegmentationYarpPort(const std::string &port_prefix, const bool &provide_rgb)
std::pair< bool, cv::Mat > latest_segmentation() override
virtual double get_time_stamp() override