15#include <opencv2/highgui/highgui.hpp>
16#include <opencv2/imgproc/imgproc.hpp>
17#include <opencv2/videoio/videoio.hpp>
24 "yarp.carrier.portmonitor.image_rotation",
32 std::istringstream
iss(s);
36 elements.push_back(
item);
52 m_options_rotate_str =
m_user_params.find(
"options_rotate").asString();
55 m_options_flip_str =
m_user_params.find(
"options_flip").asString();
59 if (m_options_rotate_str == std::string(
"rotate_cw")) {
60 m_rot_flags = cv::ROTATE_90_CLOCKWISE;
61 }
else if (m_options_rotate_str == std::string(
"rotate_ccw")) {
62 m_rot_flags = cv::ROTATE_90_COUNTERCLOCKWISE;
63 }
else if (m_options_rotate_str == std::string(
"rotate_180")) {
64 m_rot_flags = cv::ROTATE_180;
65 }
else if (m_options_rotate_str == std::string(
"rotate_none")) {
71 if (m_options_flip_str == std::string(
"flip_x")) {
73 }
else if (m_options_flip_str == std::string(
"flip_y")) {
75 }
else if (m_options_flip_str == std::string(
"flip_xy")) {
77 }
else if (m_options_flip_str == std::string(
"flip_none")) {
93 std::vector<std::string> parameters;
97 for (std::string param : parameters) {
107 std::string s = param.substr(
pointPosition + 1, param.length());
129 if (img ==
nullptr) {
149 if (m_options_flip_str ==
"flip_none" && m_options_rotate_str !=
"rotation_none") {
151 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
152 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage1);
153 }
else if (m_options_flip_str !=
"flip_none" && m_options_rotate_str ==
"rotation_none") {
155 cv::flip(m_cvInImage, m_cvOutImage1, m_flip_code);
156 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage1);
157 }
else if (m_options_flip_str ==
"flip_none" && m_options_rotate_str ==
"rotation_none") {
159 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvInImage);
162 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
163 cv::flip(m_cvOutImage1, m_cvOutImage2, m_flip_code);
164 m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage2);
171 m_outImgFloat.
zero();
173 if (m_options_flip_str ==
"flip_none") {
175 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
176 m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage1);
177 }
else if (m_options_flip_str ==
"rotation_none") {
179 cv::flip(m_cvInImage, m_cvOutImage1, m_flip_code);
180 m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage1);
183 cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
184 cv::flip(m_cvOutImage1, m_cvOutImage2, m_flip_code);
185 m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage2);
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.
#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.