18#include <catch2/catch_amalgamated.hpp>
21TEST_CASE(
"pm::depthimage_compression_zfpTest",
"[yarp::pm]")
23 YARP_REQUIRE_PLUGIN(
"depthimage_compression_zfp",
"portmonitor")
36 TestCase {
"fast_tcp",
false},
37 TestCase {
"fast_tcp+send.portmonitor+file.depthimage_compression_zfp+recv.portmonitor+file.depthimage_compression_zfp+type.dll",
true}
40 SECTION(
"Test depth image ZFP compression")
46 receiver.
open(
"/recv");
52 const size_t width = 64;
53 const size_t height = 48;
59 for (
size_t y = 0; y < height; y++) {
60 for (
size_t x = 0; x < width; x++) {
61 img.
pixel(x, y) =
static_cast<unsigned char>((x + y) % 256);
70 REQUIRE(received !=
nullptr);
73 CHECK(received->
width() == width);
74 CHECK(received->
height() == height);
76 if (tc.use_compression) {
78 bool has_similar_values =
true;
79 for (
size_t y = 0; y < height && has_similar_values; y++) {
80 for (
size_t x = 0; x < width; x++) {
81 unsigned char original = img.
pixel(x, y);
82 unsigned char compressed = received->
pixel(x, y);
84 if (std::abs(
static_cast<int>(original) -
static_cast<int>(compressed)) > 50) {
85 has_similar_values =
false;
90 CHECK(has_similar_values);
93 for (
size_t y = 0; y < height; y++) {
94 for (
size_t x = 0; x < width; x++) {
95 CHECK(received->
pixel(x, y) == img.
pixel(x, y));
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 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::depthimage_compression_zfpTest", "[yarp::pm]")
void delay(double seconds)
Wait for a certain number of seconds.
The main, catch-all namespace for YARP.