Skip to content

Commit 2c1d65d

Browse files
committed
Adding onhost tests for DynamicCalibration node
1 parent 2e3e4a8 commit 2c1d65d

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

tests/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ dai_add_test(dynamic_calibration_test src/ondevice_tests/dynamic_calibration_tes
343343
dai_set_test_labels(dynamic_calibration_test ondevice rvc2_all ci)
344344
target_compile_definitions(dynamic_calibration_test PRIVATE RECORDING_PATH="${dynamic_calibration_test_data}")
345345

346+
dai_add_test(dynamic_calibration_onhost_test src/onhost_tests/dynamic_calibration_test.cpp)
347+
dai_set_test_labels(dynamic_calibration_onhost_test onhost)
348+
346349
# Neural network test
347350
dai_add_test(neural_network_test src/ondevice_tests/neural_network_test.cpp)
348351
target_compile_definitions(neural_network_test PRIVATE BLOB_PATH="${mobilenet_blob}")
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#include <catch2/catch_all.hpp>
2+
#include <depthai/depthai.hpp>
3+
#include <memory>
4+
5+
TEST_CASE("DynamicCalibration - Commands", "[DynamicCalibrationControl]") {
6+
using DCC = dai::DynamicCalibrationControl;
7+
8+
SECTION("Calibrate command") {
9+
auto cmd = DCC::calibrate(true);
10+
REQUIRE(std::holds_alternative<DCC::Commands::Calibrate>(cmd->command));
11+
auto& c = std::get<DCC::Commands::Calibrate>(cmd->command);
12+
REQUIRE(c.force == true);
13+
}
14+
15+
SECTION("CalibrationQuality command") {
16+
auto cmd = DCC::calibrationQuality(false);
17+
REQUIRE(std::holds_alternative<DCC::Commands::CalibrationQuality>(cmd->command));
18+
auto& c = std::get<DCC::Commands::CalibrationQuality>(cmd->command);
19+
REQUIRE(c.force == false);
20+
}
21+
22+
SECTION("StartCalibration command with custom periods") {
23+
auto cmd = DCC::startCalibration(1.0f, 10.0f);
24+
REQUIRE(std::holds_alternative<DCC::Commands::StartCalibration>(cmd->command));
25+
auto& c = std::get<DCC::Commands::StartCalibration>(cmd->command);
26+
REQUIRE(c.loadImagePeriod == Catch::Approx(1.0f));
27+
REQUIRE(c.calibrationPeriod == Catch::Approx(10.0f));
28+
}
29+
30+
SECTION("StopCalibration command") {
31+
auto cmd = DCC::stopCalibration();
32+
REQUIRE(std::holds_alternative<DCC::Commands::StopCalibration>(cmd->command));
33+
}
34+
35+
SECTION("LoadImage command") {
36+
auto cmd = DCC::loadImage();
37+
REQUIRE(std::holds_alternative<DCC::Commands::LoadImage>(cmd->command));
38+
}
39+
40+
SECTION("ResetData command") {
41+
auto cmd = DCC::resetData();
42+
REQUIRE(std::holds_alternative<DCC::Commands::ResetData>(cmd->command));
43+
}
44+
45+
SECTION("SetPerformanceMode command") {
46+
auto cmd = DCC::setPerformanceMode(DCC::PerformanceMode::OPTIMIZE_SPEED);
47+
REQUIRE(std::holds_alternative<DCC::Commands::SetPerformanceMode>(cmd->command));
48+
auto& c = std::get<DCC::Commands::SetPerformanceMode>(cmd->command);
49+
REQUIRE(c.performanceMode == DCC::PerformanceMode::OPTIMIZE_SPEED);
50+
}
51+
52+
SECTION("ApplyCalibration command") {
53+
dai::CalibrationHandler calHandler; // Assuming default constructible
54+
auto cmd = DCC::applyCalibration(calHandler);
55+
REQUIRE(std::holds_alternative<DCC::Commands::ApplyCalibration>(cmd->command));
56+
auto& c = std::get<DCC::Commands::ApplyCalibration>(cmd->command);
57+
// Optionally verify that calibration matches (if operator== is defined)
58+
}
59+
}

0 commit comments

Comments
 (0)