Files
chicken-counting-sukawarna-det/cpp/tests/test_config.cpp
T
2026-07-22 00:03:02 +07:00

57 lines
2.1 KiB
C++

#include <cassert>
#include <iostream>
#include "chicken_counter/config.hpp"
int main() {
std::cout << "=== test_config ===" << std::endl;
auto raw = cc::load_data(
"/media/jetson/DATA/.Codes/chicken-counting-sukawarna-det/configs/cameras/example_camera.yaml");
// print detection device type for debugging
std::cout << "device type: " << raw["detection"]["device"].type_name()
<< " value: " << raw["detection"]["device"] << std::endl;
auto cam = raw.get<cc::CameraConfig>();
assert(cam.camera_id == "coop_cam_03");
assert(cam.detection.conf > 0.0f);
assert(cam.roi.points.size() >= 2);
assert(cam.roi.is_polygon());
auto cpoly = cam.roi.counting_polygon();
assert(cpoly.size() == 4);
auto crect = cam.roi.counting_rect();
assert(crect.width >= 20 && crect.height >= 20);
std::cout << " camera_config: " << cam.camera_id << " OK" << std::endl;
std::cout << " detection model: " << cam.detection.model_path << std::endl;
std::cout << " device: " << cam.detection.device << std::endl;
std::cout << " counting rect: "
<< crect.x << "," << crect.y << " "
<< crect.width << "x" << crect.height << std::endl;
auto batch = cc::load_batch_config(
"/media/jetson/DATA/.Codes/chicken-counting-sukawarna-det/configs/cycle7_batch.yaml");
assert(!batch.cameras.empty());
assert(batch.batch.compress_max_mb > 0);
std::cout << " batch_config: " << batch.cameras.size() << " cameras OK" << std::endl;
auto first_id = batch.cameras.begin()->first;
auto built = cc::build_camera_config_from_batch(
batch, first_id,
"/tmp/test.mp4",
"/tmp/output/test.mp4",
"/tmp/checkpoints/" + first_id);
assert(built.camera_id == first_id);
assert(built.source == "/tmp/test.mp4");
assert(built.display.output_path == "/tmp/output/test.mp4");
assert(!built.display.show_window);
assert(built.feedback.enabled);
std::cout << " build_from_batch: " << built.camera_id << " OK" << std::endl;
std::cout << "=== all tests passed ===" << std::endl;
return 0;
}