- Add OpenCV and stdexec dependencies - ImageRPC type bridging OpenCV and RPC layers - Stereo rectification boilerplate - get-available-methods RPC method with get_count/get_method_name_by_id/get_method_names - Tests for remote method retrieval - CPU/GPU stereo matcher interfaces with SGBM implementation - Documentation consistency pass across impl and docs TG-5 #ready-for-test TG-2 #in-progress
63 lines
1.9 KiB
C++
63 lines
1.9 KiB
C++
#include <gtest/gtest.h>
|
|
#include <opencv2/core.hpp>
|
|
|
|
#include "cloud_point/cpu_stereo_matcher.hpp"
|
|
#include "cloud_point/gpu_stereo_matcher.hpp"
|
|
#include "cloud_point/stereo_matcher_factory.hpp"
|
|
|
|
using namespace score;
|
|
|
|
namespace {
|
|
|
|
/// @brief Create a simple synthetic stereo pair with a horizontal shift.
|
|
std::pair<cv::Mat, cv::Mat> make_synthetic_stereo(int shift = 2) {
|
|
cv::Mat left = cv::Mat::zeros(100, 100, CV_8UC1);
|
|
cv::Mat right = cv::Mat::zeros(100, 100, CV_8UC1);
|
|
|
|
for (int y = 0; y < 100; ++y) {
|
|
for (int x = 0; x < 100; ++x) {
|
|
left.at<uchar>(y, x) = static_cast<uchar>(x % 256);
|
|
right.at<uchar>(y, x) = static_cast<uchar>((x + shift) % 256);
|
|
}
|
|
}
|
|
return {left, right};
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST(StereoMatcherTest, CpuMatcherComputesDisparity) {
|
|
auto [left, right] = make_synthetic_stereo();
|
|
CpuStereoMatcher matcher;
|
|
|
|
cv::Mat disparity = matcher.compute(left, right);
|
|
|
|
EXPECT_FALSE(disparity.empty());
|
|
EXPECT_EQ(disparity.rows, left.rows);
|
|
EXPECT_EQ(disparity.cols, left.cols);
|
|
}
|
|
|
|
TEST(StereoMatcherTest, FactoryCpuCreatesNonNull) {
|
|
auto matcher = StereoMatcherFactory::create(StereoAlgorithmType::CPU);
|
|
ASSERT_NE(matcher, nullptr);
|
|
|
|
auto [left, right] = make_synthetic_stereo();
|
|
cv::Mat disparity = matcher->compute(left, right);
|
|
|
|
EXPECT_FALSE(disparity.empty());
|
|
}
|
|
|
|
TEST(StereoMatcherTest, FactoryGpuFallsBackToCpuWhenUnavailable) {
|
|
// On this machine CUDA is absent; factory should fall back to CPU.
|
|
auto matcher = StereoMatcherFactory::create(StereoAlgorithmType::GPU);
|
|
ASSERT_NE(matcher, nullptr);
|
|
|
|
auto [left, right] = make_synthetic_stereo();
|
|
EXPECT_NO_THROW(matcher->compute(left, right));
|
|
}
|
|
|
|
TEST(StereoMatcherTest, GpuMatcherThrowsOnThisMachine) {
|
|
// Direct construction of GpuStereoMatcher should throw because
|
|
// HAVE_OPENCV_CUDA is undefined here.
|
|
EXPECT_THROW(GpuStereoMatcher(), std::runtime_error);
|
|
}
|