Skip to content

Commit d496ecd

Browse files
committed
Applied clang format on new merged file for CI
1 parent f0170c0 commit d496ecd

File tree

1 file changed

+39
-80
lines changed

1 file changed

+39
-80
lines changed

src/portmonitors/image_rotation/imageRotation.cpp

Lines changed: 39 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
#include "imageRotation.h"
77

8-
#include <algorithm>
9-
#include <cmath>
10-
118
#include <yarp/os/LogComponent.h>
129
#include <yarp/os/LogStream.h>
10+
1311
#include <yarp/sig/Image.h>
12+
13+
#include <algorithm>
14+
#include <cmath>
1415
#include <opencv2/highgui/highgui.hpp>
1516
#include <opencv2/imgproc/imgproc.hpp>
1617
#include <opencv2/videoio/videoio.hpp>
@@ -29,62 +30,42 @@ YARP_LOG_COMPONENT(IMAGEROTATION,
2930

3031
bool ImageRotation::create(const yarp::os::Property& options)
3132
{
32-
//parse the user parameters
33+
// parse the user parameters
3334
yarp::os::Property m_user_params;
3435
yCDebug(IMAGEROTATION) << "user params:" << options.toString();
3536
std::string str = options.find("carrier").asString();
3637
getParamsFromCommandLine(str, m_user_params);
3738
yCDebug(IMAGEROTATION) << "parsed params:" << m_user_params.toString();
3839

39-
//get the value of the parameters
40-
if (m_user_params.check("options_rotate"))
41-
{
40+
// get the value of the parameters
41+
if (m_user_params.check("options_rotate")) {
4242
m_options_rotate_str = m_user_params.find("options_rotate").asString();
4343
}
44-
if (m_user_params.check("options_flip"))
45-
{
44+
if (m_user_params.check("options_flip")) {
4645
m_options_flip_str = m_user_params.find("options_flip").asString();
4746
}
4847

49-
//translate the parameters in opencv
50-
if (m_options_rotate_str == std::string("rotate_cw"))
51-
{
48+
// translate the parameters in opencv
49+
if (m_options_rotate_str == std::string("rotate_cw")) {
5250
m_rot_flags = cv::ROTATE_90_CLOCKWISE;
53-
}
54-
else if (m_options_rotate_str == std::string("rotate_ccw"))
55-
{
51+
} else if (m_options_rotate_str == std::string("rotate_ccw")) {
5652
m_rot_flags = cv::ROTATE_90_COUNTERCLOCKWISE;
57-
}
58-
else if (m_options_rotate_str == std::string("rotate_180"))
59-
{
53+
} else if (m_options_rotate_str == std::string("rotate_180")) {
6054
m_rot_flags = cv::ROTATE_180;
61-
}
62-
else if (m_options_rotate_str == std::string("rotate_none"))
63-
{
64-
}
65-
else
66-
{
55+
} else if (m_options_rotate_str == std::string("rotate_none")) {
56+
} else {
6757
yCDebug(IMAGEROTATION) << "Invalid value of `options_rotate` parameter";
6858
return false;
6959
}
7060

71-
if (m_options_flip_str == std::string("flip_x"))
72-
{
61+
if (m_options_flip_str == std::string("flip_x")) {
7362
m_flip_code = 0;
74-
}
75-
else if (m_options_flip_str == std::string("flip_y"))
76-
{
63+
} else if (m_options_flip_str == std::string("flip_y")) {
7764
m_flip_code = 1;
78-
}
79-
else if (m_options_flip_str == std::string("flip_xy"))
80-
{
65+
} else if (m_options_flip_str == std::string("flip_xy")) {
8166
m_flip_code = -1;
82-
}
83-
else if (m_options_flip_str == std::string("flip_none"))
84-
{
85-
}
86-
else
87-
{
67+
} else if (m_options_flip_str == std::string("flip_none")) {
68+
} else {
8869
yCDebug(IMAGEROTATION) << "Invalid value of `options_flip` parameter";
8970
return false;
9071
}
@@ -112,12 +93,10 @@ void ImageRotation::getParamsFromCommandLine(std::string carrierString, yarp::os
11293
split(carrierString, '+', parameters);
11394

11495
// Iterate over result strings
115-
for (std::string param : parameters)
116-
{
96+
for (std::string param : parameters) {
11797
// If there is no '.', then the param is bad formatted, skip it.
11898
auto pointPosition = param.find('.');
119-
if (pointPosition == std::string::npos)
120-
{
99+
if (pointPosition == std::string::npos) {
121100
continue;
122101
}
123102

@@ -127,7 +106,7 @@ void ImageRotation::getParamsFromCommandLine(std::string carrierString, yarp::os
127106
std::string s = param.substr(pointPosition + 1, param.length());
128107
paramValue.fromString(s.c_str());
129108

130-
//and append to the returned property
109+
// and append to the returned property
131110
prop.put(paramKey, paramValue);
132111
}
133112
return;
@@ -146,14 +125,11 @@ bool ImageRotation::getparam(yarp::os::Property& params)
146125
bool ImageRotation::accept(yarp::os::Things& thing)
147126
{
148127
auto* img = thing.cast_as<yarp::sig::Image>();
149-
if(img == nullptr)
150-
{
128+
if (img == nullptr) {
151129
yCError(IMAGEROTATION, "Expected type Image, but got wrong data type!");
152130
return false;
153131
}
154-
if (img->getPixelCode() != VOCAB_PIXEL_RGB &&
155-
img->getPixelCode() != VOCAB_PIXEL_MONO_FLOAT)
156-
{
132+
if (img->getPixelCode() != VOCAB_PIXEL_RGB && img->getPixelCode() != VOCAB_PIXEL_MONO_FLOAT) {
157133
yCError(IMAGEROTATION, "Received image with invalid/unsupported pixelCode!");
158134
return false;
159135
}
@@ -162,70 +138,53 @@ bool ImageRotation::accept(yarp::os::Things& thing)
162138

163139
yarp::os::Things& ImageRotation::update(yarp::os::Things& thing)
164140
{
165-
yarp::sig::Image* yarpimg = thing.cast_as<yarp::sig::Image >();
166-
if (yarpimg->getPixelCode() == VOCAB_PIXEL_RGB)
167-
{
141+
yarp::sig::Image* yarpimg = thing.cast_as<yarp::sig::Image>();
142+
if (yarpimg->getPixelCode() == VOCAB_PIXEL_RGB) {
168143
m_cvInImage = yarp::cv::toCvMat(*yarpimg);
169144

170145
m_outImgRgb.resize(yarpimg->width(), yarpimg->height());
171146
m_outImgRgb.zero();
172147

173-
if (m_options_flip_str == "flip_none" && m_options_rotate_str != "rotation_none")
174-
{
175-
//just rotation
148+
if (m_options_flip_str == "flip_none" && m_options_rotate_str != "rotation_none") {
149+
// just rotation
176150
cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
177151
m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage1);
178-
}
179-
else if (m_options_flip_str != "flip_none" && m_options_rotate_str == "rotation_none")
180-
{
181-
//just flip
152+
} else if (m_options_flip_str != "flip_none" && m_options_rotate_str == "rotation_none") {
153+
// just flip
182154
cv::flip(m_cvInImage, m_cvOutImage1, m_flip_code);
183155
m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage1);
184-
}
185-
else if (m_options_flip_str == "flip_none" && m_options_rotate_str == "rotation_none")
186-
{
187-
//just copy
156+
} else if (m_options_flip_str == "flip_none" && m_options_rotate_str == "rotation_none") {
157+
// just copy
188158
m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvInImage);
189-
}
190-
else
191-
{
192-
//first a rotation, then a flip
159+
} else {
160+
// first a rotation, then a flip
193161
cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
194162
cv::flip(m_cvOutImage1, m_cvOutImage2, m_flip_code);
195163
m_outImgRgb = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(m_cvOutImage2);
196164
}
197165
m_th.setPortWriter(&m_outImgRgb);
198-
}
199-
else if (yarpimg->getPixelCode() == VOCAB_PIXEL_MONO_FLOAT)
200-
{
166+
} else if (yarpimg->getPixelCode() == VOCAB_PIXEL_MONO_FLOAT) {
201167
m_cvInImage = yarp::cv::toCvMat(*yarpimg);
202168

203169
m_outImgFloat.resize(yarpimg->width(), yarpimg->height());
204170
m_outImgFloat.zero();
205171

206-
if (m_options_flip_str == "flip_none")
207-
{
172+
if (m_options_flip_str == "flip_none") {
208173
// just rotation
209174
cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
210175
m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage1);
211-
}
212-
else if (m_options_flip_str == "rotation_none")
213-
{
176+
} else if (m_options_flip_str == "rotation_none") {
214177
// just flip
215178
cv::flip(m_cvInImage, m_cvOutImage1, m_flip_code);
216179
m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage1);
217-
}
218-
else
219-
{
180+
} else {
220181
// first a rotation, then a flip
221182
cv::rotate(m_cvInImage, m_cvOutImage1, m_rot_flags);
222183
cv::flip(m_cvOutImage1, m_cvOutImage2, m_flip_code);
223184
m_outImgFloat = yarp::cv::fromCvMat<yarp::sig::PixelFloat>(m_cvOutImage2);
224185
}
225186
m_th.setPortWriter(&m_outImgFloat);
226-
}
227-
else
228-
{
187+
} else {
229188
yCError(IMAGEROTATION, "Invalid Image type!");
230189
}
231190
return m_th;

0 commit comments

Comments
 (0)