19#include <catch2/catch_amalgamated.hpp>
24 YARP_REQUIRE_PLUGIN(
"image_rotation",
"portmonitor")
36 size_t expected_width;
37 size_t expected_height;
42 TestCase {
"fast_tcp", 32, 16},
44 TestCase {
"fast_tcp+recv.portmonitor+file.image_rotation+options_rotate.rotate_cw+type.dll", 16, 32},
46 TestCase {
"fast_tcp+recv.portmonitor+file.image_rotation+options_rotate.rotate_ccw+type.dll", 16, 32},
48 TestCase {
"fast_tcp+recv.portmonitor+file.image_rotation+options_rotate.rotate_180+type.dll", 32, 16}
51 SECTION(
"Test image rotation with expected dimensions: " + std::to_string(tc.expected_width) +
"x" + std::to_string(tc.expected_height))
57 receiver.
open(
"/recv");
63 const size_t original_width = 32;
64 const size_t original_height = 16;
67 img.
resize(original_width, original_height);
70 for (
size_t y = 0; y < original_height; y++) {
71 for (
size_t x = 0; x < original_width; x++) {
72 img.
pixel(x, y).r =
static_cast<unsigned char>(x * 11);
73 img.
pixel(x, y).g =
static_cast<unsigned char>(y * 22);
74 img.
pixel(x, y).b = 128;
83 REQUIRE(received !=
nullptr);
86 CHECK(received->
width() == tc.expected_width);
87 CHECK(received->
height() == tc.expected_height);
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
T & prepare()
Access the object which will be transmitted by the next call to yarp::os::BufferedPort::write.
static Carrier * getCarrierTemplate(const std::string &name)
Get template for carrier.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static bool setLocalMode(bool flag)
Chooses whether communication is process-local.
Utilities for manipulating the YARP network, including initialization and shutdown.
T & pixel(size_t x, size_t y)
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.
size_t height() const
Gets height of image in pixels.
TEST_CASE("pm::image_rotationTest", "[yarp::pm]")
void delay(double seconds)
Wait for a certain number of seconds.
The main, catch-all namespace for YARP.