- add block-averaged PLY grid decimation with validity-aware vertex generation - validate and load ply_stride and wls_filter from cloud_point configuration - pass matcher tuning through CloudPointClient and apply both settings in CLI exports - cover stride averaging, sparse blocks, invalid values, and config parsing
77 lines
2.9 KiB
C++
77 lines
2.9 KiB
C++
#include <cstdio>
|
|
#include <fstream>
|
|
#include <gtest/gtest.h>
|
|
#include <string>
|
|
#include <tuple>
|
|
|
|
#include "cloud_point_rpc/config.hpp"
|
|
|
|
namespace {
|
|
|
|
struct TempConfig {
|
|
std::string path;
|
|
explicit TempConfig(const std::string &yaml)
|
|
: path("test_config_" +
|
|
std::to_string(reinterpret_cast<uintptr_t>(this)) + ".yaml") {
|
|
std::ofstream(path) << yaml;
|
|
}
|
|
~TempConfig() { std::remove(path.c_str()); }
|
|
};
|
|
|
|
} // namespace
|
|
|
|
TEST(ConfigLoaderTest, CloudPointSectionDefaultsWhenAbsent) {
|
|
TempConfig cfg("server:\n ip: \"127.0.0.1\"\n port: 8080\n");
|
|
const auto c = score::ConfigLoader::load(cfg.path);
|
|
EXPECT_EQ(c.cloud_point.algorithm, "gpu");
|
|
EXPECT_EQ(c.cloud_point.num_disparities, 128);
|
|
EXPECT_DOUBLE_EQ(c.cloud_point.min_depth_m, 0.01);
|
|
EXPECT_DOUBLE_EQ(c.cloud_point.max_depth_m, 10.0);
|
|
}
|
|
|
|
TEST(ConfigLoaderTest, CloudPointSectionIsParsed) {
|
|
TempConfig cfg("server:\n ip: \"127.0.0.1\"\n port: 8080\n"
|
|
"cloud_point:\n algorithm: cpu\n num_disparities: 160\n"
|
|
" min_depth_m: 0.02\n max_depth_m: 0.3\n");
|
|
const auto c = score::ConfigLoader::load(cfg.path);
|
|
EXPECT_EQ(c.cloud_point.algorithm, "cpu");
|
|
EXPECT_EQ(c.cloud_point.num_disparities, 160);
|
|
EXPECT_DOUBLE_EQ(c.cloud_point.min_depth_m, 0.02);
|
|
EXPECT_DOUBLE_EQ(c.cloud_point.max_depth_m, 0.3);
|
|
}
|
|
|
|
TEST(ConfigLoaderTest, CloudPointExportAndFilterKeys) {
|
|
TempConfig cfg("server:\n ip: \"127.0.0.1\"\n port: 8080\n"
|
|
"cloud_point:\n ply_stride: 4\n wls_filter: true\n");
|
|
const auto c = score::ConfigLoader::load(cfg.path);
|
|
EXPECT_EQ(c.cloud_point.ply_stride, 4);
|
|
EXPECT_TRUE(c.cloud_point.wls_filter);
|
|
TempConfig bad("server:\n ip: \"127.0.0.1\"\n port: 8080\n"
|
|
"cloud_point:\n ply_stride: 0\n");
|
|
EXPECT_THROW(std::ignore = score::ConfigLoader::load(bad.path),
|
|
std::runtime_error);
|
|
}
|
|
|
|
TEST(ConfigLoaderTest, CloudPointPartialSectionKeepsDefaults) {
|
|
TempConfig cfg("server:\n ip: \"127.0.0.1\"\n port: 8080\n"
|
|
"cloud_point:\n max_depth_m: 0.5\n");
|
|
const auto c = score::ConfigLoader::load(cfg.path);
|
|
EXPECT_EQ(c.cloud_point.algorithm, "gpu");
|
|
EXPECT_EQ(c.cloud_point.num_disparities, 128);
|
|
EXPECT_DOUBLE_EQ(c.cloud_point.max_depth_m, 0.5);
|
|
}
|
|
|
|
TEST(ConfigLoaderTest, CloudPointRejectsBadAlgorithm) {
|
|
TempConfig cfg("server:\n ip: \"127.0.0.1\"\n port: 8080\n"
|
|
"cloud_point:\n algorithm: fpga\n");
|
|
EXPECT_THROW(std::ignore = score::ConfigLoader::load(cfg.path),
|
|
std::runtime_error);
|
|
}
|
|
|
|
TEST(ConfigLoaderTest, CloudPointRejectsInvertedDepthRange) {
|
|
TempConfig cfg("server:\n ip: \"127.0.0.1\"\n port: 8080\n"
|
|
"cloud_point:\n min_depth_m: 1.0\n max_depth_m: 0.5\n");
|
|
EXPECT_THROW(std::ignore = score::ConfigLoader::load(cfg.path),
|
|
std::runtime_error);
|
|
}
|