summaryrefslogtreecommitdiff
path: root/test/testsuites/machine_learning
diff options
context:
space:
mode:
authorInki Dae <inki.dae@samsung.com>2024-01-23 18:30:35 +0900
committerInki Dae <inki.dae@samsung.com>2024-01-25 05:22:03 +0000
commitc18f6fddd7f4f0cd96dff5d6955cbc5219434c24 (patch)
treeb83d7c94e86ecb91f0958f5ee98091a5f8ef5536 /test/testsuites/machine_learning
parent9bf6fba23bf11f1780c87c7c53ac2e2f1a688162 (diff)
downloadmediavision-c18f6fddd7f4f0cd96dff5d6955cbc5219434c24.tar.gz
mediavision-c18f6fddd7f4f0cd96dff5d6955cbc5219434c24.tar.bz2
mediavision-c18f6fddd7f4f0cd96dff5d6955cbc5219434c24.zip
mv_machine_learning: introduce get_result_count API for object detection group
[Issue type] : new feature Introduce get_result_cnt API for object detection 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 get_result API call returns _current_result value by calling getOutputCache function of ITask. And we are enough with get_result_count and get_result API so drop existing get_label API. Change-Id: I9e5d593d9a1926c504d1ea51272e404b045a6d6b 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/test_object_detection.cpp54
-rw-r--r--test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp67
2 files changed, 56 insertions, 65 deletions
diff --git a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp
index 2a205dd1..7958f792 100644
--- a/test/testsuites/machine_learning/object_detection/test_object_detection.cpp
+++ b/test/testsuites/machine_learning/object_detection/test_object_detection.cpp
@@ -171,28 +171,25 @@ TEST(ObjectDetectionTest, InferenceShouldBeOk)
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_object_detection_inference(handle, mv_source);
- ASSERT_EQ(ret, 0);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
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;
- }
+ ret = mv_object_detection_get_result_count(handle, &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;
+ unsigned long frame_number;
+ float confidence;
const char *label;
- ret = mv_object_detection_get_label(handle, idx, &label);
- ASSERT_EQ(ret, 0);
- cout << "index = " << idx << " label = " << label << endl;
+ int ret = mv_object_detection_get_result(handle, idx, &frame_number, &confidence, &left, &top, &right,
+ &bottom, &label);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ cout << "Frame number = " << frame_number << " probability = " << confidence << " " << left << " x " << top
+ << " ~ " << right << " x " << bottom << " label = " << label << endl;
string label_str(label);
@@ -246,28 +243,25 @@ TEST(FaceDetectionTest, InferenceShouldBeOk)
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
ret = mv_face_detection_inference(handle, mv_source);
- ASSERT_EQ(ret, 0);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
unsigned int number_of_objects;
- const int *left, *top, *right, *bottom;
- unsigned long frame_number;
- const float *confidences;
-
- ret = mv_face_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;
- }
+ ret = mv_face_detection_get_result_count(handle, &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;
+ unsigned long frame_number;
+ float confidence;
const char *label;
- ret = mv_face_detection_get_label(handle, idx, &label);
- ASSERT_EQ(ret, 0);
- cout << "index = " << idx << " label = " << label << endl;
+ int ret = mv_face_detection_get_result(handle, idx, &frame_number, &confidence, &left, &top, &right,
+ &bottom, &label);
+ ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+
+ cout << "Frame number = " << frame_number << " probability = " << confidence << " " << left << " x " << top
+ << " ~ " << right << " x " << bottom << " label = " << label << endl;
string label_str(label);
diff --git a/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp b/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp
index 9dc68a11..9cda1fcf 100644
--- a/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp
+++ b/test/testsuites/machine_learning/object_detection/test_object_detection_async.cpp
@@ -45,34 +45,31 @@ struct model_info {
void object_detection_callback(void *user_data)
{
- unsigned int number_of_objects;
- const int *left, *top, *right, *bottom;
- unsigned long frame_number = 0;
- const float *confidences;
mv_object_detection_h handle = static_cast<mv_object_detection_h>(user_data);
- while (frame_number < MAX_INFERENCE_ITERATION - 10) {
- int ret = mv_object_detection_get_result(handle, &number_of_objects, &frame_number, &confidences, &left, &top,
- &right, &bottom);
- if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION)
- break;
+ bool is_loop_exit = false;
- ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+ while (!is_loop_exit) {
+ unsigned int number_of_objects;
- 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;
- }
+ int ret = mv_object_detection_get_result_count(handle, &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;
+ unsigned long frame_number;
+ float confidence;
const char *label;
- ret = mv_object_detection_get_label(handle, idx, &label);
- if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION)
- break;
-
+ int ret = mv_object_detection_get_result(handle, idx, &frame_number, &confidence, &left, &top, &right,
+ &bottom, &label);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- cout << "index = " << idx << " label = " << label << endl;
+
+ if (frame_number > MAX_INFERENCE_ITERATION - 10)
+ is_loop_exit = true;
+
+ cout << "Frame number = " << frame_number << " probability = " << confidence << " " << left << " x " << top
+ << " ~ " << right << " x " << bottom << " label = " << label << endl;
string label_str(label);
@@ -201,31 +198,31 @@ TEST(ObjectDetectionAsyncTest, InferenceShouldBeOkWithDestroyFirst)
void face_detection_callback(void *user_data)
{
- unsigned int number_of_objects;
- const int *left, *top, *right, *bottom;
- unsigned long frame_number = 0;
- const float *confidences;
mv_object_detection_h handle = static_cast<mv_object_detection_h>(user_data);
- while (frame_number < MAX_INFERENCE_ITERATION - 10) {
- int ret = mv_face_detection_get_result(handle, &number_of_objects, &frame_number, &confidences, &left, &top,
- &right, &bottom);
- if (ret == MEDIA_VISION_ERROR_INVALID_OPERATION)
- break;
+ bool is_loop_exit = false;
- ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
+ while (!is_loop_exit) {
+ unsigned int number_of_objects;
- 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;
- }
+ int ret = mv_face_detection_get_result_count(handle, &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;
+ unsigned long frame_number;
+ float confidence;
const char *label;
- ret = mv_face_detection_get_label(handle, idx, &label);
+ int ret = mv_face_detection_get_result(handle, idx, &frame_number, &confidence, &left, &top, &right,
+ &bottom, &label);
ASSERT_EQ(ret, MEDIA_VISION_ERROR_NONE);
- cout << "index = " << idx << " label = " << label << endl;
+
+ if (frame_number > MAX_INFERENCE_ITERATION - 10)
+ is_loop_exit = true;
+
+ cout << "Frame number = " << frame_number << " probability = " << confidence << " " << left << " x " << top
+ << " ~ " << right << " x " << bottom << " label = " << label << endl;
string label_str(label);