diff options
author | Inki Dae <inki.dae@samsung.com> | 2024-01-29 18:24:41 +0900 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2024-01-31 02:23:17 +0000 |
commit | ba0a0d8f812f1e1ececaa693b98314b8e275b062 (patch) | |
tree | 0c30c9edaf92d48e727874ca33ea43664a05239d /test/testsuites/machine_learning | |
parent | 7ac8759646555c5227bda37e8f5aec4c4ad77b84 (diff) | |
download | mediavision-ba0a0d8f812f1e1ececaa693b98314b8e275b062.tar.gz mediavision-ba0a0d8f812f1e1ececaa693b98314b8e275b062.tar.bz2 mediavision-ba0a0d8f812f1e1ececaa693b98314b8e275b062.zip |
mv_machine_learning: introduce get_result_count API for object detection 3d
[Issue type] : new feature
Introduce get_result_count API for object detection 3d task group.
In user perspective, this API provides information on how many results exist
so that user can request each result corresponding to a user-given index.
And also, in framework perspective, it provides consistent API behavior -
get_result_count API call updates _current_result of task group by calling
getOutput function of ITask, and other API call returns _current_result
value by calling getOutputCache function of ITask.
get_result_count : return a number of results to detected 3d objectes.
get_point_count : return a number of points to a given 3d object index.
get_points : return x and y positions to a given position index.
And we are enough with these API so so drop existing API.
In addition, this patch cleans up ObjectDetection3d and ObjectDetection3dAdapter
classes by dropping unnecessary code, and getOutput and getOutputCache functions
to Adapter class which was already introduced by other task groups.
Change-Id: I8370bb71fc94cf6109f1fb3e25a9bbee7d39a2bb
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'test/testsuites/machine_learning')
-rw-r--r-- | test/testsuites/machine_learning/object_detection_3d/test_object_detection_3d.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/test/testsuites/machine_learning/object_detection_3d/test_object_detection_3d.cpp b/test/testsuites/machine_learning/object_detection_3d/test_object_detection_3d.cpp index 0ce07a53..6732dc6e 100644 --- a/test/testsuites/machine_learning/object_detection_3d/test_object_detection_3d.cpp +++ b/test/testsuites/machine_learning/object_detection_3d/test_object_detection_3d.cpp @@ -90,6 +90,8 @@ TEST(ObjectDetection3dTest, InferenceShouldBeOk) { "objectron", "object_detection_3d_cup.tflite", "object_detection_3d_cup.json", "" } // TODO. }; + const unsigned int coordinate_answers[][9] = { { 459, 381, 258, 374, 222, 649, 583, 674, 599 }, + { 381, 457, 511, 235, 243, 492, 571, 247, 273 } }; const string image_path = IMAGE_PATH; mv_source_h mv_source = NULL; @@ -124,25 +126,28 @@ TEST(ObjectDetection3dTest, InferenceShouldBeOk) ret = mv_object_detection_3d_inference(handle, mv_source); ASSERT_EQ(ret, 0); - unsigned int probability; + unsigned long frame_number; + unsigned int result_cnt; - ret = mv_object_detection_3d_get_probability(handle, &probability); + ret = mv_object_detection_3d_get_result_count(handle, &frame_number, &result_cnt); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - std::cout << "Probability = " << probability << std::endl; + for (unsigned int object_idx = 0; object_idx < result_cnt; ++object_idx) { + float confidence; + unsigned int point_cnt; - unsigned int num_of_points; + ret = mv_object_detection_3d_get_point_count(handle, object_idx, &confidence, &point_cnt); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - ret = mv_object_detection_3d_get_num_of_points(handle, &num_of_points); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); + for (unsigned int point_idx = 0; point_idx < point_cnt; ++point_idx) { + int pos_x, pos_y; - unsigned int *x_array, *y_array; + ret = mv_object_detection_3d_get_points(handle, point_idx, &pos_x, &pos_y); + ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - ret = mv_object_detection_3d_get_points(handle, &x_array, &y_array); - ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); - - for (unsigned int idx = 0; idx < num_of_points; ++idx) - std::cout << "index = " << idx + 1 << " : " << x_array[idx] << " x " << y_array[idx] << std::endl; + ASSERT_TRUE(pos_x == coordinate_answers[0][point_idx] && pos_y == coordinate_answers[1][point_idx]); + } + } ret = mv_object_detection_3d_destroy(handle); ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE); |