20#include <catch2/catch_amalgamated.hpp>
25 YARP_REQUIRE_PLUGIN(
"depthimage_to_rgb",
"portmonitor")
41 TestCase {
"fast_tcp",
false},
42 TestCase {
"fast_tcp+recv.portmonitor+file.depthimage_to_rgb+type.dll",
true}
45 SECTION(
"Test depth image to RGB heatmap conversion with portmonitor: " + tc.carrier)
51 receiver.
open(
"/recv");
57 constexpr int width = 16;
58 constexpr int height = 16;
61 depthImg.
resize(width, height);
64 for (
int y = 0; y < height; y++)
66 for (
int x = 0; x < width; x++)
68 float depth_value = 0.2f + (
static_cast<float>(x + y * width) / (width * height - 1)) * 9.8f;
69 depthImg.
pixel(x, y) = depth_value;
78 REQUIRE(receivedImg !=
nullptr);
81 CHECK(receivedImg->
width() == width);
82 CHECK(receivedImg->
height() == height);
84 if (tc.should_convert)
92 bool hasNonZeroPixel =
false;
93 for (
int i = 0; i < width * height * 3; i++)
95 CHECK(pixels[i] <= 255);
98 hasNonZeroPixel =
true;
102 CHECK(hasNonZeroPixel);
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.
Image class with user control of representation details.
T & pixel(size_t x, size_t y)
size_t width() const
Gets width of image in pixels.
unsigned char * getRawImage() const
Access to the internal image buffer.
virtual size_t getPixelSize() const
Gets pixel size in memory in bytes.
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.
virtual int getPixelCode() const
Gets pixel type identifier.
TEST_CASE("pm::depthimage_to_rgbTest", "[yarp::pm]")
void delay(double seconds)
Wait for a certain number of seconds.
The main, catch-all namespace for YARP.