test: add yoloxs model test case for Hailo-8L NPU
authorInki Dae <inki.dae@samsung.com>
Wed, 22 Jan 2025 01:05:53 +0000 (10:05 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 22 Jan 2025 01:05:53 +0000 (10:05 +0900)
Change-Id: Ia608d7b8691126db7729f7571cec65d6ff8e991f
Signed-off-by: Inki Dae <inki.dae@samsung.com>
test/testsuites/machine_learning/object_detection/test_object_detection.cpp

index 6ab0410f924f4cef9f3e0d162f271e0eec1d6585..6852d61ef6942a093afff9386bcd795468a39649 100644 (file)
@@ -221,6 +221,65 @@ TEST(ObjectDetectionTest, InferenceShouldBeOk)
        ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
 }
 
+TEST(ObjectDetectionHailo8LTest, YoloXsInferenceShouldBeOk)
+{
+       mv_object_detection_h handle;
+       vector<test_model_input> test_models {
+               {}
+               // TODO.
+       };
+       const int coordinate_answers[3][4] = { { 327, 0, 718, 513 }, { 409, 66, 1001, 601 }, { 24, 29, 311, 546 } };
+
+       mv_source_h mv_source = NULL;
+       int ret = mv_create_source(&mv_source);
+       ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+       ret = ImageHelper::loadImageToSource(IMG_DOG, mv_source);
+       ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+       for (const auto &model : test_models) {
+               ret = mv_object_detection_create(&handle);
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+               ret = mv_object_detection_set_model(handle, model.model_file.c_str(), model.meta_file.c_str(),
+                                                                                       model.label_file.c_str(), model.model_name.c_str());
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+               ret = mv_object_detection_configure(handle);
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+               ret = mv_object_detection_prepare(handle);
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+               ret = mv_object_detection_inference(handle, mv_source);
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+               unsigned long frame_number;
+               unsigned int number_of_objects;
+
+               ret = mv_object_detection_get_result_count(handle, &frame_number, &number_of_objects);
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+               for (unsigned int idx = 0; idx < number_of_objects; ++idx) {
+                       int left, top, right, bottom;
+
+                       int ret = mv_object_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom);
+                       ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+                       ASSERT_EQ(coordinate_answers[idx][0], left);
+                       ASSERT_EQ(coordinate_answers[idx][1], top);
+                       ASSERT_EQ(coordinate_answers[idx][2], right);
+                       ASSERT_EQ(coordinate_answers[idx][3], bottom);
+               }
+
+               ret = mv_object_detection_destroy(handle);
+               ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+       }
+
+       ret = mv_destroy_source(mv_source);
+       ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+}
+
 TEST(FaceDetectionTest, InferenceShouldBeOk)
 {
        mv_object_detection_h handle;