ret = mv_destroy_source(mv_source);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
}
+
+TEST(ObjectDetectionTest, DISABLED_InferenceDLCShouldBeOk)
+{
+ mv_object_detection_h handle;
+ vector<model_info> test_models {
+ { "yolo_v5", "yolov5m.dlc", "yolov5m.json", "label_coco_80.txt", "DOG" }
+ // TODO.
+ };
+
+ 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) {
+ cout << "model name : " << model.model_file << endl;
+
+ ret = mv_object_detection_create(&handle);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ mv_object_detection_set_model(handle, model.model_name.c_str(), model.model_file.c_str(),
+ model.meta_file.c_str(), model.label_file.c_str());
+ mv_object_detection_set_model_path(handle, "/opt/usr/globalapps/mediavision.object.detection/models/dlc/");
+ mv_object_detection_set_engine(handle, "snpe", "npu");
+
+ 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, 0);
+
+ unsigned int number_of_objects;
+ const int *left, *top, *right, *bottom;
+ unsigned long frame_number;
+ const float *confidences;
+
+ ret = mv_object_detection_get_result(handle, &number_of_objects, &frame_number, &confidences, &left, &top,
+ &right, &bottom);
+ ASSERT_EQ(ret, 0);
+
+ for (unsigned int idx = 0; idx < number_of_objects; ++idx) {
+ cout << "Frame number = " << frame_number << " probability = " << confidences[idx] << " " << left[idx]
+ << " x " << top[idx] << " ~ " << right[idx] << " x " << bottom[idx] << endl;
+ }
+
+ for (unsigned int idx = 0; idx < number_of_objects; ++idx) {
+ const char *label;
+
+ ret = mv_object_detection_get_label(handle, idx, &label);
+ ASSERT_EQ(ret, 0);
+ cout << "index = " << idx << " label = " << label << endl;
+
+ string label_str(label);
+
+ transform(label_str.begin(), label_str.end(), label_str.begin(), ::toupper);
+
+ ASSERT_TRUE(label_str == model.anster);
+ }
+
+ 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);
+}
\ No newline at end of file