CommonLibraries/YoloRuntime/tests/runner_label_layout_test.cpp

34 lines
1.1 KiB
C++
Raw Normal View History

#include "runner_label_layout.h"
#include <array>
#include <iostream>
#include <set>
int main() {
std::array<runner_label_layout, 5> rows{};
std::set<int> y_positions;
for (std::size_t index = 0; index < rows.size(); ++index) {
rows[index] = calculate_runner_label_layout(
YOLO_TASK_CLS, index, 0.0f, 0.0f, 2448, 2048);
if (rows[index].font_size < 10 || rows[index].x <= 0 ||
!y_positions.insert(rows[index].y).second) {
std::cerr << "Classification label rows overlap or are invalid.\n";
return 1;
}
if (index > 0 && rows[index].y <= rows[index - 1].y + rows[index - 1].font_size) {
std::cerr << "Classification label rows have insufficient vertical spacing.\n";
return 2;
}
}
const auto detection = calculate_runner_label_layout(
YOLO_TASK_DETECT, 3, 42.9f, 51.1f, 640, 640);
if (detection.x != 42 || detection.y != 31 || detection.font_size != 10) {
std::cerr << "Detection label placement changed unexpectedly.\n";
return 3;
}
std::cout << "RUNNER_LABEL_LAYOUT_TEST_OK\n";
return 0;
}