20#include <catch2/catch_amalgamated.hpp>
23TEST_CASE(
"pm::depthimage_to_vectorTest",
"[yarp::pm]")
25 YARP_REQUIRE_PLUGIN(
"depthimage_to_vector",
"portmonitor")
38 TestCase {
"fast_tcp",
false},
39 TestCase {
"fast_tcp+recv.portmonitor+file.depthimage_to_vector+type.dll",
true}
42 SECTION(
"Test depth image to vector conversion with portmonitor: " + tc.carrier)
48 receiver.
open(
"/recv");
54 constexpr int width = 4;
55 constexpr int height = 4;
56 constexpr int total_pixels = width * height;
59 depthImg.
resize(width, height);
62 for (
int y = 0; y < height; y++)
64 for (
int x = 0; x < width; x++)
66 float depth_value =
static_cast<float>(x + y * width) + 0.5f;
67 depthImg.
pixel(x, y) = depth_value;
75 if (tc.should_convert)
79 receiver.
read(receivedVec);
82 CHECK(receivedVec.
size() == total_pixels);
85 for (
int i = 0; i < total_pixels; i++)
87 float expected_value =
static_cast<float>(i) + 0.5f;
88 CHECK(receivedVec[i] == expected_value);
95 receiver.
read(receivedImg);
97 CHECK(receivedImg.
width() == width);
98 CHECK(receivedImg.
height() == height);
contains the definition of a Vector type
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.
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 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.
A mini-server for network communication.
bool read(PortReader &reader, bool willReply=false) override
Read an object from the port.
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 & 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::depthimage_to_vectorTest", "[yarp::pm]")
void delay(double seconds)
Wait for a certain number of seconds.
The main, catch-all namespace for YARP.