Cpp-Processing
protobuf-tests.h
1 #define CATCH_CONFIG_MAIN
2 #include <catch2/catch_test_macros.hpp>
3 #include <string>
4 #include <vector>
5 #include "detections-utils.h"
6 #include "CelanturDetection.h"
7 
8 TEST_CASE("Test protobuf serialisation", "[protobuf]") {
9  std::vector<celantur::CelanturDetection> detections(2);
10 
11  detections[0].class_id = 1;
12  detections[0].class_name = "person";
13  detections[0].confidence = 0.9;
14  detections[0].box = cv::Rect(0, 0, 100, 100);
15  detections[0].model_class_id = 11;
16 
17  detections[1].class_id = 2;
18  detections[1].class_name = "car";
19  detections[1].confidence = 0.8;
20  detections[1].box = cv::Rect(100, 100, 200, 200);
21  detections[1].model_class_id = 22;
22 
23  std::string serialised = celantur::serialise_detections_proto(detections);
24  std::vector<celantur::CelanturDetection> deserialised = celantur::deserialise_detections_proto(serialised);
25 
26  REQUIRE(detections == deserialised);
27 }
28