15#include <opencv2/highgui/highgui.hpp>
16#include <opencv2/imgproc/imgproc.hpp>
17#include <opencv2/videoio/videoio.hpp>
24 "yarp.carrier.portmonitor.image_rotation",
42 m_options_rotate_str =
m_user_params.find(
"options_rotate").asString();
45 m_options_flip_str =
m_user_params.find(
"options_flip").asString();
49 if (m_options_rotate_str == std::string(
"rotate_cw")) {
50 m_rot_flags = cv::ROTATE_90_CLOCKWISE;
51 }
else if (m_options_rotate_str == std::string(
"rotate_ccw")) {
52 m_rot_flags = cv::ROTATE_90_COUNTERCLOCKWISE;
53 }
else if (m_options_rotate_str == std::string(
"rotate_180")) {
54 m_rot_flags = cv::ROTATE_180;
55 }
else if (m_options_rotate_str == std::string(
"rotate_none")) {
61 if (m_options_flip_str == std::string(
"flip_x")) {
63 }
else if (m_options_flip_str == std::string(
"flip_y")) {
65 }
else if (m_options_flip_str == std::string(
"flip_xy")) {
67 }
else if (m_options_flip_str == std::string(
"flip_none")) {
80void split(
const std::string& s,
char delim, std::vector<std::string>& elements)
82 std::istringstream
iss(s);
85 elements.push_back(
item);
92 std::vector<std::string> parameters;
96 for (std::string param : parameters) {
106 std::string s = param.substr(
pointPosition + 1, param.length());
128 if (img ==
nullptr) {
148 if (m_options_flip_str ==
"flip_none" && m_options_rotate_str !=
"rotation_none") {
150 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
151 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage1);
152 }
else if (m_options_flip_str !=
"flip_none" && m_options_rotate_str ==
"rotation_none") {
154 cv::flip(m_cvInImage, m_cvOutImage1, m_flip_code);
155 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage1);
156 }
else if (m_options_flip_str ==
"flip_none" && m_options_rotate_str ==
"rotation_none") {
158 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvInImage);
161 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
162 cv::flip(m_cvOutImage1, m_cvOutImage2, m_flip_code);
163 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage2);
170 m_outImgFloat.
zero();
172 if (m_options_flip_str ==
"flip_none") {
174 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
175 m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage1);
176 }
else if (m_options_flip_str ==
"rotation_none") {
178 cv::flip(m_cvInImage, m_cvOutImage1, m_flip_code);
179 m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage1);
182 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
183 cv::flip(m_cvOutImage1, m_cvOutImage2, m_flip_code);
184 m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage2);
void split(const std::string &s, char delim, std::vector< std::string > &elements)
bool accept(yarp::os::Things &thing) override
This will be called when the data reach the portmonitor object.
bool setparam(const yarp::os::Property ¶ms) override
This will be called when the portmonitor carrier parameters are set via YARP admin port.
void destroy() override
This will be called when the portmonitor object destroyes.
void getParamsFromCommandLine(std::string carrierString, yarp::os::Property &prop)
bool create(const yarp::os::Property &options) override
This will be called when the dll is properly loaded by the portmonitor carrier.
bool getparam(yarp::os::Property ¶ms) override
This will be called when the portmonitor carrier parameters are requested via YARP admin port.
yarp::os::Things & update(yarp::os::Things &thing) override
After data get accpeted in the accept() callback, an instance of that is given to the update function...
A mini-server for performing network communication in the background.
static LogCallback printCallback()
Get current print callback.
static LogType minimumPrintLevel()
Get current minimum print level.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string toString() const override
Return a standard text representation of the content of the object.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Base class for generic things.
void setPortWriter(yarp::os::PortWriter *writer)
Set the reference to a PortWriter object.
A single value (typically within a Bottle).
virtual std::string asString() const
Get string value.
Base class for storing images.
size_t width() const
Gets width of image in pixels.
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
void zero()
Set all pixels to 0.
size_t height() const
Gets height of image in pixels.
virtual int getPixelCode() const
Gets pixel type identifier.
void split(const std::string &s, char delim, std::vector< std::string > &elements)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
::cv::Mat toCvMat(yarp::sig::Image &yarpImage)
Convert a yarp::sig::FlexImage to a cv::Mat object.
An interface to the operating system, including Port based communication.