From: shobhitv Date: Wed, 4 Sep 2024 09:35:57 +0000 (+0530) Subject: [ITC][madia-vision-dl][ACR-1848] Added TCs for new APIs X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05c4708b3150c501265e8394a68c46f36d609115;p=test%2Ftct%2Fnative%2Fapi.git [ITC][madia-vision-dl][ACR-1848] Added TCs for new APIs Change-Id: Ia09f5adcd601a6666aabc9dcb211d0492031949c Signed-off-by: shobhitv --- diff --git a/src/itc/media-vision-dl/CMakeLists.txt b/src/itc/media-vision-dl/CMakeLists.txt index 7518435b3..6d212fd3a 100644 --- a/src/itc/media-vision-dl/CMakeLists.txt +++ b/src/itc/media-vision-dl/CMakeLists.txt @@ -13,6 +13,11 @@ SET(TC_SOURCES IF( DEFINED TIZENIOT || DEFINED MOBILE || DEFINED WEARABLE) SET(TC_SOURCES ITs-media-vision-face-recognition.c + ITs-media-vision-face-detection.c + ITs-media-vision-facial-landmark.c + ITs-media-vision-image-classification.c + ITs-media-vision-object-detection.c + ITs-media-vision-pose-landmark.c ) ENDIF() diff --git a/src/itc/media-vision-dl/ITs-media-vision-common.c b/src/itc/media-vision-dl/ITs-media-vision-common.c index 0c6eb737e..a73e81186 100644 --- a/src/itc/media-vision-dl/ITs-media-vision-common.c +++ b/src/itc/media-vision-dl/ITs-media-vision-common.c @@ -189,4 +189,232 @@ FINISH: return ret; } +void *ImageClassificationCallback(void *user_data) +{ + mv_image_classification_h handle = (mv_image_classification_h) user_data; + bool is_loop_exit = false; + + while (!is_loop_exit) + { + unsigned long frame_number; + unsigned int nCount; + + int nRet = mv_image_classification_get_result_count(handle, &frame_number, &nCount); + if ( nRet == MEDIA_VISION_ERROR_INVALID_OPERATION) + { + FPRINTF("[Line : %d][%s] mv_image_classification_get_result_count API failed\n", __LINE__, API_NAMESPACE); + break; + } + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_get_result_count", MediaVisionGetError(nRet)); + + for (unsigned long idx = 0; idx < nCount; ++idx) { + const char *label = NULL; + + nRet = mv_image_classification_get_label(handle, idx, &label); + if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] mv_image_classification_get_label API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + + if (strcmp(label, "Banana") != 0) + { + FPRINTF("[Line : %d][%s] mv_image_classification_get_label API failed, lebel value is different: %s\n", __LINE__, API_NAMESPACE, label); + return 1; + } + } + } + return 0; +} + +void *FaceDetectionCallback(void *user_data) +{ + mv_face_detection_h handle = (mv_face_detection_h) user_data; + const int coordinate_answers[2][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) + { + unsigned long frame_number = 0; + unsigned int nCount = 0; + + int nRet = mv_face_detection_get_result_count(handle, &frame_number, &nCount); + if ( nRet == MEDIA_VISION_ERROR_INVALID_OPERATION) + { + FPRINTF("[Line : %d][%s] mv_face_detection_get_result_count API failed\n", __LINE__, API_NAMESPACE); + break; + } + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_get_result_count", MediaVisionGetError(nRet)); + + for (unsigned long idx = 0; idx < nCount; ++idx) + { + int left, top, right, bottom; + + nRet = mv_face_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); + if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] mv_face_detection_get_bound_box API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + if ( (coordinate_answers[idx][0] != left) || (coordinate_answers[idx][1] != top) || (coordinate_answers[idx][2] != right) || (coordinate_answers[idx][3] != bottom) ) + { + FPRINTF("[Line : %d][%s] Incorrect coordinates received\n", __LINE__, API_NAMESPACE); + return 1; + } + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } + return 0; +} + +void *FacialLandmarkCallback(void *user_data) +{ + mv_facial_landmark_h handle = (mv_facial_landmark_h) user_data; + const unsigned int coordinate_answers[][5] = { { 42, 87, 63, 48, 83 }, { 32, 31, 53, 75, 76 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number = 0; + unsigned int nCount = 0; + + int nRet = mv_facial_landmark_get_result_count(handle, &frame_number, &nCount); + if ( nRet == MEDIA_VISION_ERROR_INVALID_OPERATION) + { + FPRINTF("[Line : %d][%s] mv_facial_landmark_get_result_count API failed\n", __LINE__, API_NAMESPACE); + break; + } + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_get_result_count", MediaVisionGetError(nRet)); + + for (unsigned long idx = 0; idx < nCount; ++idx) + { + unsigned int pos_x, pos_y; + + nRet = mv_facial_landmark_get_position(handle, idx, &pos_x, &pos_y); + if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] mv_facial_landmark_get_position API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + + if ( distance_x > 3 || distance_y > 3) + { + FPRINTF("[Line : %d][%s] Incorrect distance received.\n", __LINE__, API_NAMESPACE); + return 1; + } + } + } + return 0; +} + +void *ObjectDetectionCallback(void *user_data) +{ + mv_object_detection_h handle = (mv_object_detection_h) user_data; + const int coordinate_answers[2][4] = { { 194, 27, 502, 298 }, { 12, 6, 164, 270 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) + { + unsigned long frame_number = 0; + unsigned int nCount = 0; + + int nRet = mv_object_detection_get_result_count(handle, &frame_number, &nCount); + if (nRet == MEDIA_VISION_ERROR_INVALID_OPERATION) + { + FPRINTF("[Line : %d][%s] mv_object_detection_get_result_count API failed\n", __LINE__, API_NAMESPACE); + break; + } + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_get_result_count", MediaVisionGetError(nRet)); + + for (unsigned long idx = 0; idx < nCount; ++idx) + { + int left, top, right, bottom; + + nRet = mv_object_detection_get_bound_box(handle, idx, &left, &top, &right, &bottom); + if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] mv_object_detection_get_bound_box API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + if ( (coordinate_answers[idx][0] != left) || (coordinate_answers[idx][1] != top) || (coordinate_answers[idx][2] != right) || (coordinate_answers[idx][3] != bottom) ) + { + FPRINTF("[Line : %d][%s] Incorrect coordinates received\n", __LINE__, API_NAMESPACE); + return 1; + } + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + } + } + return 0; +} + +void *PoseLandMarkCallback(void *user_data) +{ + mv_pose_landmark_h handle = (mv_pose_landmark_h) user_data; + const unsigned int coordinate_answers[][10] = { { 300, 300, 275, 250, 325, 325, 225, 225, 350, 375 }, + { 50, 87, 100, 137, 100, 137, 187, 250, 187, 250 } }; + + bool is_loop_exit = false; + + while (!is_loop_exit) { + unsigned long frame_number = 0; + unsigned int nCount = 0; + + int nRet = mv_pose_landmark_get_result_count(handle, &frame_number, &nCount); + if ( nRet == MEDIA_VISION_ERROR_INVALID_OPERATION) + { + FPRINTF("[Line : %d][%s] mv_pose_landmark_get_result_count API failed\n", __LINE__, API_NAMESPACE); + break; + } + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_get_result_count", MediaVisionGetError(nRet)); + + for (unsigned long idx = 0; idx < nCount; ++idx) + { + unsigned int pos_x, pos_y; + + nRet = mv_pose_landmark_get_position(handle, idx, &pos_x, &pos_y); + if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[Line : %d][%s] mv_pose_landmark_get_position API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + if (frame_number > MAX_INFERENCE_ITERATION - 10) + is_loop_exit = true; + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + + if ( distance_x > 2 || distance_y > 2) + { + FPRINTF("[Line : %d][%s] Incorrect distance received.\n", __LINE__, API_NAMESPACE); + return 1; + } + } + } + return 0; +} + /** @} */ diff --git a/src/itc/media-vision-dl/ITs-media-vision-common.h b/src/itc/media-vision-dl/ITs-media-vision-common.h index 32e23f1d1..20c9f7320 100644 --- a/src/itc/media-vision-dl/ITs-media-vision-common.h +++ b/src/itc/media-vision-dl/ITs-media-vision-common.h @@ -25,6 +25,12 @@ #include #include #include +#include +#include +#include +#include +#include + #if defined(MOBILE) || defined(TIZENIOT) || defined(WEARABLE) #include #endif // MOBILE OR TIZENIOT OR WEARABLE @@ -34,6 +40,7 @@ #include #include +#include /** @addtogroup itc-media-vision * @ingroup itc * @{ @@ -48,6 +55,8 @@ #define VISIONTRAININGFACERECOGNITIONFEATURE "http://tizen.org/feature/vision.training.face_recognition" #define PATHLEN 1024 +#define FILE_PATH_SIZE 1024 +#define MAX_INFERENCE_ITERATION 50 #define START_TEST_INFERENCE \ { \ @@ -101,6 +110,31 @@ } \ } +#define START_TEST_COMMON \ + { \ + FPRINTF("[Line : %d][%s] Starting test : %s\n", __LINE__, API_NAMESPACE, __FUNCTION__); \ + if (g_bMismatch) { \ + FPRINTF("[Line : %d][%s] Create Object API and " \ + "TCTCheckSystemInfoFeatureSupported returned different feature support error" \ + "for media-vision so leaving test\n", \ + __LINE__, API_NAMESPACE); \ + return 1; \ + } \ + if (g_bIsFaceRecognitionFeatureSupported == false) { \ + FPRINTF("[Line : %d][%s] Face recognition feature is not supported and " \ + "api also returned not supported so leaving test\n", \ + __LINE__, API_NAMESPACE); \ + return 0; \ + } \ + if (g_bMediavisionModelCreation == false) { \ + FPRINTF("[Line : %d][%s] Precondition of media-vision failed so " \ + "leaving test\n", \ + __LINE__, API_NAMESPACE); \ + return 1; \ + } \ + } + + // Add CallBack function declarations here bool MvSupportedAttributeCallBack(mv_config_attribute_type_e attribute_type, const char *attribute_name, void *user_data); @@ -116,10 +150,16 @@ bool g_bMediavisionFaceRecognitionModelCreation; bool g_bMediavisionInferenceModelCreation; bool g_bIsVisionInferenceFeatureSupported; bool g_bIsFaceRecognitionFeatureSupported; -bool g_bMediavisionFaceRecognitionModelCreation; +bool g_bMediavisionModelCreation; + char *ImageUtilGetError(int nRet); int image_load(const char *file_path, mv_source_h source); +void *ImageClassificationCallback(void *user_data); +void *FaceDetectionCallback(void *user_data); +void *FacialLandmarkCallback(void *user_data); +void *ObjectDetectionCallback(void *user_data); +void *PoseLandMarkCallback(void *user_data); /** @} */ #endif //_ITS_MEDIA_VISION_COMMON_H_ diff --git a/src/itc/media-vision-dl/ITs-media-vision-face-detection.c b/src/itc/media-vision-dl/ITs-media-vision-face-detection.c new file mode 100644 index 000000000..6f3f019e0 --- /dev/null +++ b/src/itc/media-vision-dl/ITs-media-vision-face-detection.c @@ -0,0 +1,344 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ITs-media-vision-common.h" + +//& set: MediaVision + +/** @addtogroup itc-media-vision + * @ingroup itc + * @{ + */ + +static mv_face_detection_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +#define IMG_NAME "faceDetection.jpg" + +/** + * @function ITs_media_vision_face_detection_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_face_detection_startup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_face_detection_startup \n", __LINE__, API_NAMESPACE); +#endif + struct stat stBuff; + if (stat(ERR_LOG, &stBuff) == 0) { + remove(ERR_LOG); + } + + g_bMediavisionModelCreation = false; + g_bMismatch = false; + g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFEATURE, API_NAMESPACE); + + char pszValue[CONFIG_VALUE_LEN_MAX] = {0,}; + + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) + { + FPRINTF("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", pszValue); + } + else + { + FPRINTF("[Line : %d][%s] GetValueForTCTSetting returned error for DEVICE_SUITE_TARGET_30\n", __LINE__, API_NAMESPACE); + } + + int nRet = mv_face_detection_create(&gInferenceHandle); + + if (!g_bIsFaceRecognitionFeatureSupported) + { + if (nRet != TIZEN_ERROR_NOT_SUPPORTED) + { + FPRINTF("[%s:%d] mv_face_detection_create failed to return TIZEN_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\n", + __FILE__, __LINE__, nRet); + g_bMismatch = true; + return; + } + + FPRINTF("[%s:%d] mv_face_detection_create is unsupported\n", __FILE__, __LINE__); + g_bMismatch = false; + } + else if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[%s:%d] mv_face_detection_create failed, error returned =(%d)\n", __FILE__, __LINE__, nRet); + g_bMediavisionModelCreation = false; + return; + } + + nRet = mv_create_source(&gSourceHandle); + if ( (nRet != MEDIA_VISION_ERROR_NONE) || (gSourceHandle == NULL) ) + { + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + g_bMediavisionModelCreation = false; + return; + } + + g_bMediavisionModelCreation = true; + + return; +} + +/** + * @function ITs_media_vision_face_detection_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_face_detection_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_face_detection_cleanup \n", __LINE__, API_NAMESPACE); +#endif + if (gInferenceHandle != NULL) + { + mv_face_detection_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) + { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir != NULL) + { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + return; +} + + +/** + * @testcase ITc_mv_face_detection_create_destroy_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification create and destroy APIs + * @scenario Call mv_face_detection_create and mv_face_detection_destroy APIs + * @apicovered mv_face_detection_create and mv_face_detection_destroy + * @passcase If mv_face_recognition_create and mv_face_detection_destroy Pass + * @failcase If mv_face_recognition_create Or mv_face_detection_destroy fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_face_recognition_create and mv_face_detection_destroy +int ITc_mv_face_detection_create_destroy_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_face_detection_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_destroy", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_create", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_destroy", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_create", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_face_detection_configure_prepare_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_face_detection_configure and mv_face_detection_prepare APIs + * @apicovered mv_face_detection_configure and mv_face_detection_prepare + * @passcase If mv_face_detection_configure and mv_face_detection_prepare Pass + * @failcase If mv_face_detection_configure Or mv_face_detection_prepare fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_face_detection_configure and mv_face_detection_prepare +int ITc_mv_face_detection_configure_prepare_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_face_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_prepare", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_face_detection_inference_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_face_detection_inference API + * @apicovered mv_face_detection_configure, mv_face_detection_prepare and mv_face_detection_inference + * @passcase If pre condition APIs and mv_face_detection_inference API Pass + * @failcase If pre condition APIs Or mv_face_detection_inference API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_face_detection_inference API +int ITc_mv_face_detection_inference_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_face_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_inference", MediaVisionGetError(nRet)); + + return 0; +} + + +/** + * @testcase ITc_mv_face_detection_inference_async_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_face_detection_inference_async API + * @apicovered mv_face_detection_configure, mv_face_detection_prepare and mv_face_detection_inference_async + * @passcase If pre condition APIs and mv_face_detection_inference_async API Pass + * @failcase If pre condition APIs Or mv_face_detection_inference_async API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_face_detection_inference_async API +int ITc_mv_face_detection_inference_async_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_face_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) + { + nRet = mv_face_detection_inference_async(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_inference_async", MediaVisionGetError(nRet)); + + if (iter == 0) + pthread_create(&thread_id, NULL, FaceDetectionCallback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + if (status != 0) + { + FPRINTF("[Line : %d][%s] mv_face_detection_get_result_count API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + + +/** + * @testcase ITc_mv_face_detection_get_result_count_bound_box_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test face detection result coumt and get bound box APIs + * @scenario Call mv_face_detection_get_result_count and mv_face_detection_get_bound_box APIs + * @apicovered mv_face_detection_configure, mv_face_detection_prepare and mv_face_detection_inference and mv_face_detection_get_result_count and mv_face_detection_get_bound_box + * @passcase If pre condition APIs and mv_face_detection_get_result_count and mv_face_detection_get_bound_box API Pass + * @failcase If pre condition APIs Or mv_face_detection_get_result_count Or mv_face_detection_get_bound_box API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_face_detection_get_result_count and mv_face_detection_get_result_bound_box API +int ITc_mv_face_detection_get_result_count_bound_box_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_face_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_face_detection_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_inference", MediaVisionGetError(nRet)); + + unsigned long frame_number = 0; + unsigned int nCount = 0; + + nRet = mv_face_detection_get_result_count(gInferenceHandle, &frame_number, &nCount); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_get_result_count", MediaVisionGetError(nRet)); + PRINT_RESULT(2, nCount, "mv_face_detection_get_result_count", MediaVisionGetError(nRet)); + + const int coordinate_answers[2][4] = { { 553, 87, 583, 129 }, { 397, 110, 427, 149 } }; + + for (unsigned int idx = 0; idx < nCount; ++idx) { + int left, top, right, bottom; + + nRet = mv_face_detection_get_bound_box(gInferenceHandle, idx, &left, &top, &right, &bottom); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_detection_get_bound_box", MediaVisionGetError(nRet)); + + PRINT_RESULT(coordinate_answers[idx][0], left, "mv_face_detection_get_bound_box", MediaVisionGetError(nRet)); + PRINT_RESULT(coordinate_answers[idx][1], top, "mv_face_detection_get_bound_box", MediaVisionGetError(nRet)); + PRINT_RESULT(coordinate_answers[idx][2], right, "mv_face_detection_get_bound_box", MediaVisionGetError(nRet)); + PRINT_RESULT(coordinate_answers[idx][3], bottom, "mv_face_detection_get_bound_box", MediaVisionGetError(nRet)); + } + + return 0; +} diff --git a/src/itc/media-vision-dl/ITs-media-vision-facial-landmark.c b/src/itc/media-vision-dl/ITs-media-vision-facial-landmark.c new file mode 100644 index 000000000..e44c7c799 --- /dev/null +++ b/src/itc/media-vision-dl/ITs-media-vision-facial-landmark.c @@ -0,0 +1,352 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ITs-media-vision-common.h" + +//& set: MediaVision + +/** @addtogroup itc-media-vision + * @ingroup itc + * @{ + */ + +static mv_facial_landmark_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +#define IMG_NAME "faceLandmark.jpg" + +/** + * @function ITs_media_vision_facial_landmark_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_facial_landmark_startup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_facial_landmark_startup \n", __LINE__, API_NAMESPACE); +#endif + struct stat stBuff; + if (stat(ERR_LOG, &stBuff) == 0) { + remove(ERR_LOG); + } + + g_bMediavisionModelCreation = false; + g_bMismatch = false; + g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFEATURE, API_NAMESPACE); + + char pszValue[CONFIG_VALUE_LEN_MAX] = {0,}; + + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) + { + FPRINTF("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", pszValue); + } + else + { + FPRINTF("[Line : %d][%s] GetValueForTCTSetting returned error for DEVICE_SUITE_TARGET_30\n", __LINE__, API_NAMESPACE); + } + + int nRet = mv_facial_landmark_create(&gInferenceHandle); + + if (!g_bIsFaceRecognitionFeatureSupported) + { + if (nRet != TIZEN_ERROR_NOT_SUPPORTED) + { + FPRINTF("[%s:%d] mv_facial_landmark_create failed to return TIZEN_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\n", + __FILE__, __LINE__, nRet); + g_bMismatch = true; + return; + } + + FPRINTF("[%s:%d] mv_facial_landmark_create is unsupported\n", __FILE__, __LINE__); + g_bMismatch = false; + } + else if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[%s:%d] mv_facial_landmark_create failed, error returned =(%d)\n", __FILE__, __LINE__, nRet); + g_bMediavisionModelCreation = false; + return; + } + + nRet = mv_create_source(&gSourceHandle); + if ( (nRet != MEDIA_VISION_ERROR_NONE) || (gSourceHandle == NULL) ) + { + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + g_bMediavisionModelCreation = false; + return; + } + + g_bMediavisionModelCreation = true; + + return; +} + +/** + * @function ITs_media_vision_facial_landmark_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_facial_landmark_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_facial_landmark_cleanup \n", __LINE__, API_NAMESPACE); +#endif + if (gInferenceHandle != NULL) + { + mv_facial_landmark_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) + { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir != NULL) + { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + return; +} + + +/** + * @testcase ITc_mv_facial_landmark_create_destroy_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification create and destroy APIs + * @scenario Call mv_facial_landmark_create and mv_facial_landmark_destroy APIs + * @apicovered mv_facial_landmark_create and mv_facial_landmark_destroy + * @passcase If mv_face_recognition_create and mv_facial_landmark_destroy Pass + * @failcase If mv_face_recognition_create Or mv_facial_landmark_destroy fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_face_recognition_create and mv_facial_landmark_destroy +int ITc_mv_facial_landmark_create_destroy_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_facial_landmark_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_destroy", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_create", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_destroy", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_create", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_facial_landmark_configure_prepare_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_facial_landmark_configure and mv_facial_landmark_prepare APIs + * @apicovered mv_facial_landmark_configure and mv_facial_landmark_prepare + * @passcase If mv_facial_landmark_configure and mv_facial_landmark_prepare Pass + * @failcase If mv_facial_landmark_configure Or mv_facial_landmark_prepare fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_facial_landmark_configure and mv_facial_landmark_prepare +int ITc_mv_facial_landmark_configure_prepare_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_facial_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_prepare", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_facial_landmark_inference_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_facial_landmark_inference API + * @apicovered mv_facial_landmark_configure, mv_facial_landmark_prepare and mv_facial_landmark_inference + * @passcase If pre condition APIs and mv_facial_landmark_inference API Pass + * @failcase If pre condition APIs Or mv_facial_landmark_inference API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_facial_landmark_inference API +int ITc_mv_facial_landmark_inference_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_facial_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_inference", MediaVisionGetError(nRet)); + + return 0; +} + + +/** + * @testcase ITc_mv_facial_landmark_inference_async_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_facial_landmark_inference_async API + * @apicovered mv_facial_landmark_configure, mv_facial_landmark_prepare and mv_facial_landmark_inference_async + * @passcase If pre condition APIs and mv_facial_landmark_inference_async API Pass + * @failcase If pre condition APIs Or mv_facial_landmark_inference_async API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_facial_landmark_inference_async API +int ITc_mv_facial_landmark_inference_async_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_facial_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) + { + nRet = mv_facial_landmark_inference_async(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_inference_async", MediaVisionGetError(nRet)); + + if (iter == 0) + pthread_create(&thread_id, NULL, FacialLandmarkCallback, gInferenceHandle); + } + + void *status; + pthread_join(thread_id, &status); + if (status != 0) + { + FPRINTF("[Line : %d][%s] mv_facial_landmark_inference_async API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + + +/** + * @testcase ITc_mv_facial_landmark_get_result_count_position_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test face detection result count and get bound box APIs + * @scenario Call mv_facial_landmark_get_result_count and mv_facial_landmark_get_position APIs + * @apicovered mv_facial_landmark_configure, mv_facial_landmark_prepare and mv_facial_landmark_inference and mv_facial_landmark_get_result_count and mv_facial_landmark_get_position + * @passcase If pre condition APIs and mv_facial_landmark_get_result_count and mv_facial_landmark_get_position API Pass + * @failcase If pre condition APIs Or mv_facial_landmark_get_result_count Or mv_facial_landmark_get_position API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_facial_landmark_get_result_count and mv_facial_landmark_get_position API +int ITc_mv_facial_landmark_get_result_count_position_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_facial_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_facial_landmark_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_inference", MediaVisionGetError(nRet)); + + unsigned long frame_number = 0; + unsigned int nCount = 0; + + nRet = mv_facial_landmark_get_result_count(gInferenceHandle, &frame_number, &nCount); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_get_result_count", MediaVisionGetError(nRet)); + PRINT_RESULT(5, nCount, "mv_facial_landmark_get_result_count", MediaVisionGetError(nRet)); + + const unsigned int coordinate_answers[][5] = { { 42, 87, 63, 48, 83 }, { 32, 31, 53, 75, 76 } }; + + for (unsigned int idx = 0; idx < nCount; ++idx) + { + unsigned int pos_x, pos_y; + + nRet = mv_facial_landmark_get_position(gInferenceHandle, idx, &pos_x, &pos_y); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_facial_landmark_get_position", MediaVisionGetError(nRet)); + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + if (distance_x > 2 || distance_y > 2) + { + FPRINTF("[Line : %d][%s] mv_facial_landmark_get_position API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + } + + return 0; +} diff --git a/src/itc/media-vision-dl/ITs-media-vision-image-classification.c b/src/itc/media-vision-dl/ITs-media-vision-image-classification.c new file mode 100644 index 000000000..95eea5eb0 --- /dev/null +++ b/src/itc/media-vision-dl/ITs-media-vision-image-classification.c @@ -0,0 +1,339 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ITs-media-vision-common.h" + +//& set: MediaVision + +/** @addtogroup itc-media-vision + * @ingroup itc + * @{ + */ + +static mv_image_classification_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +#define IMG_NAME "banana.jpg" + + +/** + * @function ITs_media_vision_image_classification_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_image_classification_startup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_image_classification_startup \n", __LINE__, API_NAMESPACE); +#endif + struct stat stBuff; + if (stat(ERR_LOG, &stBuff) == 0) { + remove(ERR_LOG); + } + + g_bMediavisionModelCreation = false; + g_bMismatch = false; + g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFEATURE, API_NAMESPACE); + + char pszValue[CONFIG_VALUE_LEN_MAX] = {0,}; + + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) + { + FPRINTF("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", pszValue); + } + else + { + FPRINTF("[Line : %d][%s] GetValueForTCTSetting returned error for DEVICE_SUITE_TARGET_30\n", __LINE__, API_NAMESPACE); + } + + int nRet = mv_image_classification_create(&gInferenceHandle); + + if (!g_bIsFaceRecognitionFeatureSupported) + { + if (nRet != TIZEN_ERROR_NOT_SUPPORTED) + { + FPRINTF("[%s:%d] mv_image_classification_create failed to return TIZEN_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\n", + __FILE__, __LINE__, nRet); + g_bMismatch = true; + return; + } + + FPRINTF("[%s:%d] mv_image_classification_create is unsupported\n", __FILE__, __LINE__); + g_bMismatch = false; + } + else if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[%s:%d] mv_image_classification_create failed, error returned =(%d)\n", __FILE__, __LINE__, nRet); + g_bMediavisionModelCreation = false; + return; + } + + nRet = mv_create_source(&gSourceHandle); + if ( (nRet != MEDIA_VISION_ERROR_NONE) || (gSourceHandle == NULL) ) + { + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + g_bMediavisionModelCreation = false; + return; + } + + g_bMediavisionModelCreation = true; + + return; +} + +/** + * @function ITs_media_vision_image_classification_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_image_classification_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_image_classification_cleanup \n", __LINE__, API_NAMESPACE); +#endif + if (gInferenceHandle != NULL) + { + mv_image_classification_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) + { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir != NULL) + { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + return; +} + +/** + * @testcase ITc_mv_image_classification_create_destroy_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification create and destroy APIs + * @scenario Call mv_image_classification_create and mv_image_classification_destroy APIs + * @apicovered mv_image_classification_create and mv_image_classification_destroy + * @passcase If mv_face_recognition_create and mv_image_classification_destroy Pass + * @failcase If mv_face_recognition_create Or mv_image_classification_destroy fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_face_recognition_create and mv_image_classification_destroy +int ITc_mv_image_classification_create_destroy_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_image_classification_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_destroy", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_create", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_destroy", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_create", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_image_classification_configure_prepare_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_image_classification_configure and mv_image_classification_prepare APIs + * @apicovered mv_image_classification_configure and mv_image_classification_prepare + * @passcase If mv_image_classification_configure and mv_image_classification_prepare Pass + * @failcase If mv_image_classification_configure Or mv_image_classification_prepare fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_image_classification_configure and mv_image_classification_prepare +int ITc_mv_image_classification_configure_prepare_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_image_classification_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_configure", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_prepare", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_image_classification_inference_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_image_classification_inference API + * @apicovered mv_image_classification_configure, mv_image_classification_prepare and mv_image_classification_inference + * @passcase If pre condition APIs and mv_image_classification_inference API Pass + * @failcase If pre condition APIs Or mv_image_classification_inference API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_image_classification_inference API +int ITc_mv_image_classification_inference_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_image_classification_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_configure", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_inference", MediaVisionGetError(nRet)); + + return 0; +} + + +/** + * @testcase ITc_mv_image_classification_inference_async_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_image_classification_inference_async API + * @apicovered mv_image_classification_configure, mv_image_classification_prepare and mv_image_classification_inference_async + * @passcase If pre condition APIs and mv_image_classification_inference_async API Pass + * @failcase If pre condition APIs Or mv_image_classification_inference_async API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_image_classification_inference_async API +int ITc_mv_image_classification_inference_async_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_image_classification_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_configure", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) + { + nRet = mv_image_classification_inference_async(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_inference_async", MediaVisionGetError(nRet)); + + if (iter == 0) + pthread_create(&thread_id, NULL, ImageClassificationCallback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + if (status != 0) + { + FPRINTF("[Line : %d][%s] mv_image_classification_get_result_count API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + + +/** + * @testcase ITc_mv_image_classification_get_result_count_label_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification get count and get label APIs + * @scenario Call mv_image_classification_get_result_count and mv_image_classification_get_label APIs + * @apicovered mv_image_classification_configure, mv_image_classification_prepare and mv_image_classification_inference and mv_image_classification_get_result_count and mv_image_classification_get_label + * @passcase If pre condition APIs and mv_image_classification_get_result_count and mv_image_classification_get_label API Pass + * @failcase If pre condition APIs Or mv_image_classification_get_result_count Or mv_image_classification_get_label API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_image_classification_get_result_count and mv_image_classification_get_result_babel API +int ITc_mv_image_classification_get_result_count_label_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_image_classification_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_configure", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_image_classification_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_inference", MediaVisionGetError(nRet)); + + unsigned long frame_number = 0; + unsigned int nCount = 0; + + nRet = mv_image_classification_get_result_count(gInferenceHandle, &frame_number, &nCount); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_get_result_count", MediaVisionGetError(nRet)); + PRINT_RESULT(1, nCount, "mv_image_classification_get_result_count", MediaVisionGetError(nRet)); + + const char *pLabel = NULL; + nRet = mv_image_classification_get_label(gInferenceHandle, 0, &pLabel); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_image_classification_get_label", MediaVisionGetError(nRet)); + if (strcmp(pLabel, "Banana") != 0) + { + FPRINTF("[Line : %d][%s] mv_image_classification_get_label API failed. Label received is: %s\n", __LINE__, API_NAMESPACE, pLabel); + return 1; + } + + return 0; +} diff --git a/src/itc/media-vision-dl/ITs-media-vision-object-detection.c b/src/itc/media-vision-dl/ITs-media-vision-object-detection.c new file mode 100644 index 000000000..deddb59a4 --- /dev/null +++ b/src/itc/media-vision-dl/ITs-media-vision-object-detection.c @@ -0,0 +1,344 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ITs-media-vision-common.h" + +//& set: MediaVision + +/** @addtogroup itc-media-vision + * @ingroup itc + * @{ + */ + +static mv_object_detection_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +#define IMG_NAME "dog2.jpg" + +/** + * @function ITs_media_vision_object_detection_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_object_detection_startup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_object_detection_startup \n", __LINE__, API_NAMESPACE); +#endif + struct stat stBuff; + if (stat(ERR_LOG, &stBuff) == 0) { + remove(ERR_LOG); + } + + g_bMediavisionModelCreation = false; + g_bMismatch = false; + g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFEATURE, API_NAMESPACE); + + char pszValue[CONFIG_VALUE_LEN_MAX] = {0,}; + + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) + { + FPRINTF("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", pszValue); + } + else + { + FPRINTF("[Line : %d][%s] GetValueForTCTSetting returned error for DEVICE_SUITE_TARGET_30\n", __LINE__, API_NAMESPACE); + } + + int nRet = mv_object_detection_create(&gInferenceHandle); + + if (!g_bIsFaceRecognitionFeatureSupported) + { + if (nRet != TIZEN_ERROR_NOT_SUPPORTED) + { + FPRINTF("[%s:%d] mv_object_detection_create failed to return TIZEN_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\n", + __FILE__, __LINE__, nRet); + g_bMismatch = true; + return; + } + + FPRINTF("[%s:%d] mv_object_detection_create is unsupported\n", __FILE__, __LINE__); + g_bMismatch = false; + } + else if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[%s:%d] mv_object_detection_create failed, error returned =(%d)\n", __FILE__, __LINE__, nRet); + g_bMediavisionModelCreation = false; + return; + } + + nRet = mv_create_source(&gSourceHandle); + if ( (nRet != MEDIA_VISION_ERROR_NONE) || (gSourceHandle == NULL) ) + { + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + g_bMediavisionModelCreation = false; + return; + } + + g_bMediavisionModelCreation = true; + + return; +} + +/** + * @function ITs_media_vision_object_detection_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_object_detection_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_object_detection_cleanup \n", __LINE__, API_NAMESPACE); +#endif + if (gInferenceHandle != NULL) + { + mv_object_detection_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) + { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir != NULL) + { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + return; +} + + +/** + * @testcase ITc_mv_object_detection_create_destroy_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification create and destroy APIs + * @scenario Call mv_object_detection_create and mv_object_detection_destroy APIs + * @apicovered mv_object_detection_create and mv_object_detection_destroy + * @passcase If mv_face_recognition_create and mv_object_detection_destroy Pass + * @failcase If mv_face_recognition_create Or mv_object_detection_destroy fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_face_recognition_create and mv_object_detection_destroy +int ITc_mv_object_detection_create_destroy_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_object_detection_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_destroy", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_create", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_destroy", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_create", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_object_detection_configure_prepare_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_object_detection_configure and mv_object_detection_prepare APIs + * @apicovered mv_object_detection_configure and mv_object_detection_prepare + * @passcase If mv_object_detection_configure and mv_object_detection_prepare Pass + * @failcase If mv_object_detection_configure Or mv_object_detection_prepare fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_object_detection_configure and mv_object_detection_prepare +int ITc_mv_object_detection_configure_prepare_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_object_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_prepare", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_object_detection_inference_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_object_detection_inference API + * @apicovered mv_object_detection_configure, mv_object_detection_prepare and mv_object_detection_inference + * @passcase If pre condition APIs and mv_object_detection_inference API Pass + * @failcase If pre condition APIs Or mv_object_detection_inference API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_object_detection_inference API +int ITc_mv_object_detection_inference_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_object_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_inference", MediaVisionGetError(nRet)); + + return 0; +} + + +/** + * @testcase ITc_mv_object_detection_inference_async_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_object_detection_inference_async API + * @apicovered mv_object_detection_configure, mv_object_detection_prepare and mv_object_detection_inference_async + * @passcase If pre condition APIs and mv_object_detection_inference_async API Pass + * @failcase If pre condition APIs Or mv_object_detection_inference_async API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_object_detection_inference_async API +int ITc_mv_object_detection_inference_async_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_object_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) + { + nRet = mv_object_detection_inference_async(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_inference_async", MediaVisionGetError(nRet)); + + if (iter == 0) + pthread_create(&thread_id, NULL, ObjectDetectionCallback, gInferenceHandle); + } + void *status; + pthread_join(thread_id, &status); + if (status != 0) + { + FPRINTF("[Line : %d][%s] mv_object_detection_get_result_count API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + + +/** + * @testcase ITc_mv_object_detection_get_result_count_bound_box_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test face detection result coumt and get bound box APIs + * @scenario Call mv_object_detection_get_result_count and mv_object_detection_get_bound_box APIs + * @apicovered mv_object_detection_configure, mv_object_detection_prepare and mv_object_detection_inference and mv_object_detection_get_result_count and mv_object_detection_get_bound_box + * @passcase If pre condition APIs and mv_object_detection_get_result_count and mv_object_detection_get_bound_box API Pass + * @failcase If pre condition APIs Or mv_object_detection_get_result_count Or mv_object_detection_get_bound_box API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_object_detection_get_result_count and mv_object_detection_get_result_bound_box API +int ITc_mv_object_detection_get_result_count_bound_box_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_object_detection_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_configure", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_object_detection_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_inference", MediaVisionGetError(nRet)); + + unsigned long frame_number = 0; + unsigned int nCount = 0; + + nRet = mv_object_detection_get_result_count(gInferenceHandle, &frame_number, &nCount); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_get_result_count", MediaVisionGetError(nRet)); + PRINT_RESULT(2, nCount, "mv_object_detection_get_result_count", MediaVisionGetError(nRet)); + + const int coordinate_answers[2][4] = { { 194, 27, 502, 298 }, { 12, 6, 164, 270 } }; + + for (unsigned int idx = 0; idx < nCount; ++idx) { + int left, top, right, bottom; + + nRet = mv_object_detection_get_bound_box(gInferenceHandle, idx, &left, &top, &right, &bottom); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_object_detection_get_bound_box", MediaVisionGetError(nRet)); + + PRINT_RESULT(coordinate_answers[idx][0], left, "mv_object_detection_get_bound_box", MediaVisionGetError(nRet)); + PRINT_RESULT(coordinate_answers[idx][1], top, "mv_object_detection_get_bound_box", MediaVisionGetError(nRet)); + PRINT_RESULT(coordinate_answers[idx][2], right, "mv_object_detection_get_bound_box", MediaVisionGetError(nRet)); + PRINT_RESULT(coordinate_answers[idx][3], bottom, "mv_object_detection_get_bound_box", MediaVisionGetError(nRet)); + } + + return 0; +} diff --git a/src/itc/media-vision-dl/ITs-media-vision-pose-landmark.c b/src/itc/media-vision-dl/ITs-media-vision-pose-landmark.c new file mode 100644 index 000000000..dd65ebf1f --- /dev/null +++ b/src/itc/media-vision-dl/ITs-media-vision-pose-landmark.c @@ -0,0 +1,353 @@ +/** + * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ITs-media-vision-common.h" + +//& set: MediaVision + +/** @addtogroup itc-media-vision + * @ingroup itc + * @{ + */ + +static mv_pose_landmark_h gInferenceHandle = NULL; +static mv_source_h gSourceHandle = NULL; +static const char *gInferenceExampleDir = NULL; + +#define IMG_NAME "poseLandmark.jpg" + +/** + * @function ITs_media_vision_pose_landmark_startup + * @description Called before each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_pose_landmark_startup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_pose_landmark_startup \n", __LINE__, API_NAMESPACE); +#endif + struct stat stBuff; + if (stat(ERR_LOG, &stBuff) == 0) { + remove(ERR_LOG); + } + + g_bMediavisionModelCreation = false; + g_bMismatch = false; + g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFEATURE, API_NAMESPACE); + + char pszValue[CONFIG_VALUE_LEN_MAX] = {0,}; + + if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) + { + FPRINTF("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\n", __LINE__, API_NAMESPACE, pszValue); + + gInferenceExampleDir = (char *) calloc(strlen(pszValue) + strlen("/res/res/inference") + 1, sizeof(char)); + snprintf(gInferenceExampleDir, strlen(pszValue) + strlen("/res/res/inference") + 1, "%s/res/res/inference", pszValue); + } + else + { + FPRINTF("[Line : %d][%s] GetValueForTCTSetting returned error for DEVICE_SUITE_TARGET_30\n", __LINE__, API_NAMESPACE); + } + + int nRet = mv_pose_landmark_create(&gInferenceHandle); + + if (!g_bIsFaceRecognitionFeatureSupported) + { + if (nRet != TIZEN_ERROR_NOT_SUPPORTED) + { + FPRINTF("[%s:%d] mv_pose_landmark_create failed to return TIZEN_ERROR_NOT_SUPPORTED for unsupported feature, error returned = (%d)\n", + __FILE__, __LINE__, nRet); + g_bMismatch = true; + return; + } + + FPRINTF("[%s:%d] mv_pose_landmark_create is unsupported\n", __FILE__, __LINE__); + g_bMismatch = false; + } + else if (nRet != MEDIA_VISION_ERROR_NONE) + { + FPRINTF("[%s:%d] mv_pose_landmark_create failed, error returned =(%d)\n", __FILE__, __LINE__, nRet); + g_bMediavisionModelCreation = false; + return; + } + + nRet = mv_create_source(&gSourceHandle); + if ( (nRet != MEDIA_VISION_ERROR_NONE) || (gSourceHandle == NULL) ) + { + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + g_bMediavisionModelCreation = false; + return; + } + + g_bMediavisionModelCreation = true; + + return; +} + +/** + * @function ITs_media_vision_pose_landmark_cleanup + * @description Called after each test + * @parameter NA + * @return NA + */ +void ITs_media_vision_pose_landmark_cleanup(void) +{ +#if DEBUG + FPRINTF("[Line : %d][%s] Inside ITs_media_vision_pose_landmark_cleanup \n", __LINE__, API_NAMESPACE); +#endif + if (gInferenceHandle != NULL) + { + mv_pose_landmark_destroy(gInferenceHandle); + gInferenceHandle = NULL; + } + + if (gSourceHandle) + { + mv_destroy_source(gSourceHandle); + gSourceHandle = NULL; + } + + if (gInferenceExampleDir != NULL) + { + free(gInferenceExampleDir); + gInferenceExampleDir = NULL; + } + + return; +} + + +/** + * @testcase ITc_mv_pose_landmark_create_destroy_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification create and destroy APIs + * @scenario Call mv_pose_landmark_create and mv_pose_landmark_destroy APIs + * @apicovered mv_pose_landmark_create and mv_pose_landmark_destroy + * @passcase If mv_face_recognition_create and mv_pose_landmark_destroy Pass + * @failcase If mv_face_recognition_create Or mv_pose_landmark_destroy fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_face_recognition_create and mv_pose_landmark_destroy +int ITc_mv_pose_landmark_create_destroy_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_pose_landmark_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_destroy", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_create", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_destroy(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_destroy", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_create(&gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_create", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_pose_landmark_configure_prepare_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_pose_landmark_configure and mv_pose_landmark_prepare APIs + * @apicovered mv_pose_landmark_configure and mv_pose_landmark_prepare + * @passcase If mv_pose_landmark_configure and mv_pose_landmark_prepare Pass + * @failcase If mv_pose_landmark_configure Or mv_pose_landmark_prepare fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test If mv_pose_landmark_configure and mv_pose_landmark_prepare +int ITc_mv_pose_landmark_configure_prepare_p(void) +{ + START_TEST_COMMON; + + int nRet = mv_pose_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_prepare", MediaVisionGetError(nRet)); + + return 0; +} + +/** + * @testcase ITc_mv_pose_landmark_inference_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_pose_landmark_inference API + * @apicovered mv_pose_landmark_configure, mv_pose_landmark_prepare and mv_pose_landmark_inference + * @passcase If pre condition APIs and mv_pose_landmark_inference API Pass + * @failcase If pre condition APIs Or mv_pose_landmark_inference API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_pose_landmark_inference API +int ITc_mv_pose_landmark_inference_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_pose_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_inference", MediaVisionGetError(nRet)); + + return 0; +} + + +/** + * @testcase ITc_mv_pose_landmark_inference_async_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test image classification configure and prepare APIs + * @scenario Call mv_pose_landmark_inference_async API + * @apicovered mv_pose_landmark_configure, mv_pose_landmark_prepare and mv_pose_landmark_inference_async + * @passcase If pre condition APIs and mv_pose_landmark_inference_async API Pass + * @failcase If pre condition APIs Or mv_pose_landmark_inference_async API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_pose_landmark_inference_async API +int ITc_mv_pose_landmark_inference_async_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_pose_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + pthread_t thread_id; + for (unsigned int iter = 0; iter < MAX_INFERENCE_ITERATION; ++iter) + { + nRet = mv_pose_landmark_inference_async(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_inference_async", MediaVisionGetError(nRet)); + + if (iter == 0) + pthread_create(&thread_id, NULL, PoseLandMarkCallback, gInferenceHandle); + } + + void *status; + pthread_join(thread_id, &status); + if (status != 0) + { + FPRINTF("[Line : %d][%s] mv_pose_landmark_get_result_count API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + + return 0; +} + + +/** + * @testcase ITc_mv_pose_landmark_get_result_count_position_p + * @author SRID(shobhit.v) + * @reviewer SRID(utk.tiwari) + * @type auto + * @since_tizen 9.0 + * @description To test face detection result count and get bound box APIs + * @scenario Call mv_pose_landmark_get_result_count and mv_pose_landmark_get_position APIs + * @apicovered mv_pose_landmark_configure, mv_pose_landmark_prepare and mv_pose_landmark_inference and mv_pose_landmark_get_result_count and mv_pose_landmark_get_position + * @passcase If pre condition APIs and mv_pose_landmark_get_result_count and mv_pose_landmark_get_position API Pass + * @failcase If pre condition APIs Or mv_pose_landmark_get_result_count Or mv_pose_landmark_get_position API fails + * @precondition NA + * @postcondition NA + * */ +//& type: auto +//& purpose: To test mv_pose_landmark_get_result_count and mv_pose_landmark_get_position API +int ITc_mv_pose_landmark_get_result_count_position_p(void) +{ + START_TEST_COMMON; + char pszImageFilename[1024]; + + int nRet = mv_pose_landmark_configure(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_configure", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_prepare(gInferenceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_prepare", MediaVisionGetError(nRet)); + + snprintf(pszImageFilename, 1024, "%s/images/%s", gInferenceExampleDir, IMG_NAME); + nRet = image_load(pszImageFilename, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_pose_landmark_inference(gInferenceHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_inference", MediaVisionGetError(nRet)); + + unsigned long frame_number = 0; + unsigned int nCount = 0; + + nRet = mv_pose_landmark_get_result_count(gInferenceHandle, &frame_number, &nCount); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_get_result_count", MediaVisionGetError(nRet)); + PRINT_RESULT(10, nCount, "mv_pose_landmark_get_result_count", MediaVisionGetError(nRet)); + + const unsigned int coordinate_answers[][10] = { { 300, 300, 275, 250, 325, 325, 225, 225, 350, 375 }, + { 50, 87, 100, 137, 100, 137, 187, 250, 187, 250 } }; + + for (unsigned int idx = 0; idx < nCount; ++idx) + { + unsigned int pos_x, pos_y; + + nRet = mv_pose_landmark_get_position(gInferenceHandle, idx, &pos_x, &pos_y); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_pose_landmark_get_position", MediaVisionGetError(nRet)); + + int distance_x = pos_x - coordinate_answers[0][idx]; + int distance_y = pos_y - coordinate_answers[1][idx]; + + distance_x = distance_x < 0 ? distance_x * -1 : distance_x; + distance_y = distance_y < 0 ? distance_y * -1 : distance_y; + if (distance_x > 2 || distance_y > 2) + { + FPRINTF("[Line : %d][%s] mv_pose_landmark_get_position API failed\n", __LINE__, API_NAMESPACE); + return 1; + } + } + + return 0; +} diff --git a/src/itc/media-vision-dl/tct-media-vision-dl-native_mobile.h b/src/itc/media-vision-dl/tct-media-vision-dl-native_mobile.h index f6a267c29..a5a91bc0c 100644 --- a/src/itc/media-vision-dl/tct-media-vision-dl-native_mobile.h +++ b/src/itc/media-vision-dl/tct-media-vision-dl-native_mobile.h @@ -48,51 +48,83 @@ extern int ITc_mediavision_mv_pose_create_destroy_p(void); extern int ITc_mediavision_mv_pose_set_from_file_p(void); extern int ITc_mediavision_mv_pose_compare_p(void); +extern int ITc_mv_image_classification_create_destroy_p(void); +extern int ITc_mv_image_classification_configure_prepare_p(void); +extern int ITc_mv_image_classification_inference_p(void); +extern int ITc_mv_image_classification_inference_async_p(void); +extern int ITc_mv_image_classification_get_result_count_label_p(void); + +extern int ITc_mv_face_detection_create_destroy_p(void); +extern int ITc_mv_face_detection_configure_prepare_p(void); +extern int ITc_mv_face_detection_inference_p(void); +extern int ITc_mv_face_detection_inference_async_p(void); +extern int ITc_mv_face_detection_get_result_count_bound_box_p(void); + +extern int ITc_mv_facial_landmark_create_destroy_p(void); +extern int ITc_mv_facial_landmark_configure_prepare_p(void); +extern int ITc_mv_facial_landmark_inference_p(void); +extern int ITc_mv_facial_landmark_inference_async_p(void); +extern int ITc_mv_facial_landmark_get_result_count_position_p(void); + +extern int ITc_mv_pose_landmark_create_destroy_p(void); +extern int ITc_mv_pose_landmark_configure_prepare_p(void); +extern int ITc_mv_pose_landmark_inference_p(void); +extern int ITc_mv_pose_landmark_inference_async_p(void); +extern int ITc_mv_pose_landmark_get_result_count_position_p(void); + +extern int ITc_mv_object_detection_create_destroy_p(void); +extern int ITc_mv_object_detection_configure_prepare_p(void); +extern int ITc_mv_object_detection_inference_p(void); +extern int ITc_mv_object_detection_inference_async_p(void); +extern int ITc_mv_object_detection_get_result_count_bound_box_p(void); + testcase tc_array[] = { - { "ITc_mediavision_mv_inference_create_destroy_p", ITc_mediavision_mv_inference_create_destroy_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_configure_p", ITc_mediavision_mv_inference_configure_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_prepare_p", ITc_mediavision_mv_inference_prepare_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_foreach_supported_engine_p", - ITc_mediavision_mv_inference_foreach_supported_engine_p, ITs_media_vision_inference_startup, - ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_image_classify_p", ITc_mediavision_mv_inference_image_classify_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_object_detect_p", ITc_mediavision_mv_inference_object_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_face_detect_p", ITc_mediavision_mv_inference_face_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_facial_landmark_detect_p", ITc_mediavision_mv_inference_facial_landmark_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_pose_landmark_detect_p", ITc_mediavision_mv_inference_pose_landmark_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_get_number_of_poses_p", ITc_mediavision_mv_inference_get_number_of_poses_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_get_number_of_landmarks_p", ITc_mediavision_mv_inference_get_number_of_landmarks_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_get_landmark_p", ITc_mediavision_mv_inference_get_landmark_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_engine_set_get_array_string_attribute_p", - ITc_mediavision_mv_engine_set_get_array_string_attribute_p, ITs_media_vision_inference_startup, - ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_pose_get_label_p", ITc_mediavision_mv_inference_pose_get_label_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_pose_create_destroy_p", ITc_mediavision_mv_pose_create_destroy_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_pose_set_from_file_p", ITc_mediavision_mv_pose_set_from_file_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_pose_compare_p", ITc_mediavision_mv_pose_compare_p, ITs_media_vision_inference_startup, - ITs_media_vision_inference_cleanup }, - { "ITc_mv_face_recognition_create_destroy_p", ITc_mv_face_recognition_create_destroy_p, - ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, - { "ITc_mv_face_recognition_prepare_p", ITc_mv_face_recognition_prepare_p, ITs_media_vision_face_recognition_startup, - ITs_media_vision_face_recognition_cleanup }, - { "ITc_mv_face_recognition_register_unregister_p", ITc_mv_face_recognition_register_unregister_p, - ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, - { "ITc_mv_face_recognition_inference_p", ITc_mv_face_recognition_inference_p, - ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mediavision_mv_inference_create_destroy_p", ITc_mediavision_mv_inference_create_destroy_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_configure_p", ITc_mediavision_mv_inference_configure_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_prepare_p", ITc_mediavision_mv_inference_prepare_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_foreach_supported_engine_p", ITc_mediavision_mv_inference_foreach_supported_engine_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_image_classify_p", ITc_mediavision_mv_inference_image_classify_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_object_detect_p", ITc_mediavision_mv_inference_object_detect_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_face_detect_p", ITc_mediavision_mv_inference_face_detect_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_facial_landmark_detect_p", ITc_mediavision_mv_inference_facial_landmark_detect_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_pose_landmark_detect_p", ITc_mediavision_mv_inference_pose_landmark_detect_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_get_number_of_poses_p", ITc_mediavision_mv_inference_get_number_of_poses_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_get_number_of_landmarks_p", ITc_mediavision_mv_inference_get_number_of_landmarks_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_get_landmark_p", ITc_mediavision_mv_inference_get_landmark_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_engine_set_get_array_string_attribute_p", ITc_mediavision_mv_engine_set_get_array_string_attribute_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_pose_get_label_p", ITc_mediavision_mv_inference_pose_get_label_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_pose_create_destroy_p", ITc_mediavision_mv_pose_create_destroy_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_pose_set_from_file_p", ITc_mediavision_mv_pose_set_from_file_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_pose_compare_p", ITc_mediavision_mv_pose_compare_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mv_face_recognition_create_destroy_p", ITc_mv_face_recognition_create_destroy_p, ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_face_recognition_prepare_p", ITc_mv_face_recognition_prepare_p, ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_face_recognition_register_unregister_p", ITc_mv_face_recognition_register_unregister_p, ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_face_recognition_inference_p", ITc_mv_face_recognition_inference_p, ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_image_classification_create_destroy_p", ITc_mv_image_classification_create_destroy_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_configure_prepare_p", ITc_mv_image_classification_configure_prepare_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_inference_p", ITc_mv_image_classification_inference_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_inference_async_p", ITc_mv_image_classification_inference_async_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_get_result_count_label_p", ITc_mv_image_classification_get_result_count_label_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_face_detection_create_destroy_p", ITc_mv_face_detection_create_destroy_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_configure_prepare_p", ITc_mv_face_detection_configure_prepare_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_inference_p", ITc_mv_face_detection_inference_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_inference_async_p", ITc_mv_face_detection_inference_async_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_get_result_count_bound_box_p", ITc_mv_face_detection_get_result_count_bound_box_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_facial_landmark_create_destroy_p", ITc_mv_facial_landmark_create_destroy_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_configure_prepare_p", ITc_mv_facial_landmark_configure_prepare_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_inference_p", ITc_mv_facial_landmark_inference_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_inference_async_p", ITc_mv_facial_landmark_inference_async_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_get_result_count_position_p", ITc_mv_facial_landmark_get_result_count_position_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_pose_landmark_create_destroy_p", ITc_mv_pose_landmark_create_destroy_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_configure_prepare_p", ITc_mv_pose_landmark_configure_prepare_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_inference_p", ITc_mv_pose_landmark_inference_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_inference_async_p", ITc_mv_pose_landmark_inference_async_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_get_result_count_position_p", ITc_mv_pose_landmark_get_result_count_position_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_object_detection_create_destroy_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_configure_prepare_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_inference_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_inference_async_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_get_result_count_bound_box_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, { NULL, NULL } }; diff --git a/src/itc/media-vision-dl/tct-media-vision-dl-native_tizeniot.h b/src/itc/media-vision-dl/tct-media-vision-dl-native_tizeniot.h index e1a9472cb..f50a71cd9 100644 --- a/src/itc/media-vision-dl/tct-media-vision-dl-native_tizeniot.h +++ b/src/itc/media-vision-dl/tct-media-vision-dl-native_tizeniot.h @@ -24,6 +24,17 @@ extern void ITs_media_vision_inference_cleanup(void); extern void ITs_media_vision_face_recognition_startup(void); extern void ITs_media_vision_face_recognition_cleanup(void); +extern void ITs_media_vision_image_classification_startup(void); +extern void ITs_media_vision_image_classification_cleanup(void); +extern void ITs_media_vision_face_detection_startup(void); +extern void ITs_media_vision_face_detection_cleanup(void); +extern void ITs_media_vision_facial_landmark_startup(void); +extern void ITs_media_vision_facial_landmark_cleanup(void); +extern void ITs_media_vision_pose_landmark_startup(void); +extern void ITs_media_vision_pose_landmark_cleanup(void); +extern void ITs_media_vision_object_detection_startup(void); +extern void ITs_media_vision_object_detection_cleanup(void); + extern int ITc_mediavision_mv_inference_create_destroy_p(void); extern int ITc_mediavision_mv_inference_configure_p(void); extern int ITc_mediavision_mv_inference_prepare_p(void); @@ -48,51 +59,83 @@ extern int ITc_mediavision_mv_pose_create_destroy_p(void); extern int ITc_mediavision_mv_pose_set_from_file_p(void); extern int ITc_mediavision_mv_pose_compare_p(void); +extern int ITc_mv_image_classification_create_destroy_p(void); +extern int ITc_mv_image_classification_configure_prepare_p(void); +extern int ITc_mv_image_classification_inference_p(void); +extern int ITc_mv_image_classification_inference_async_p(void); +extern int ITc_mv_image_classification_get_result_count_label_p(void); + +extern int ITc_mv_face_detection_create_destroy_p(void); +extern int ITc_mv_face_detection_configure_prepare_p(void); +extern int ITc_mv_face_detection_inference_p(void); +extern int ITc_mv_face_detection_inference_async_p(void); +extern int ITc_mv_face_detection_get_result_count_bound_box_p(void); + +extern int ITc_mv_facial_landmark_create_destroy_p(void); +extern int ITc_mv_facial_landmark_configure_prepare_p(void); +extern int ITc_mv_facial_landmark_inference_p(void); +extern int ITc_mv_facial_landmark_inference_async_p(void); +extern int ITc_mv_facial_landmark_get_result_count_position_p(void); + +extern int ITc_mv_pose_landmark_create_destroy_p(void); +extern int ITc_mv_pose_landmark_configure_prepare_p(void); +extern int ITc_mv_pose_landmark_inference_p(void); +extern int ITc_mv_pose_landmark_inference_async_p(void); +extern int ITc_mv_pose_landmark_get_result_count_position_p(void); + +extern int ITc_mv_object_detection_create_destroy_p(void); +extern int ITc_mv_object_detection_configure_prepare_p(void); +extern int ITc_mv_object_detection_inference_p(void); +extern int ITc_mv_object_detection_inference_async_p(void); +extern int ITc_mv_object_detection_get_result_count_bound_box_p(void); + testcase tc_array[] = { - { "ITc_mediavision_mv_inference_create_destroy_p", ITc_mediavision_mv_inference_create_destroy_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_configure_p", ITc_mediavision_mv_inference_configure_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_prepare_p", ITc_mediavision_mv_inference_prepare_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_foreach_supported_engine_p", - ITc_mediavision_mv_inference_foreach_supported_engine_p, ITs_media_vision_inference_startup, - ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_image_classify_p", ITc_mediavision_mv_inference_image_classify_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_object_detect_p", ITc_mediavision_mv_inference_object_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_face_detect_p", ITc_mediavision_mv_inference_face_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_facial_landmark_detect_p", ITc_mediavision_mv_inference_facial_landmark_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_pose_landmark_detect_p", ITc_mediavision_mv_inference_pose_landmark_detect_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_get_number_of_poses_p", ITc_mediavision_mv_inference_get_number_of_poses_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_get_number_of_landmarks_p", ITc_mediavision_mv_inference_get_number_of_landmarks_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_get_landmark_p", ITc_mediavision_mv_inference_get_landmark_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_inference_pose_get_label_p", ITc_mediavision_mv_inference_pose_get_label_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_engine_set_get_array_string_attribute_p", - ITc_mediavision_mv_engine_set_get_array_string_attribute_p, ITs_media_vision_inference_startup, - ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_pose_create_destroy_p", ITc_mediavision_mv_pose_create_destroy_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_pose_set_from_file_p", ITc_mediavision_mv_pose_set_from_file_p, - ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, - { "ITc_mediavision_mv_pose_compare_p", ITc_mediavision_mv_pose_compare_p, ITs_media_vision_inference_startup, - ITs_media_vision_inference_cleanup }, - { "ITc_mv_face_recognition_create_destroy_p", ITc_mv_face_recognition_create_destroy_p, - ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, - { "ITc_mv_face_recognition_prepare_p", ITc_mv_face_recognition_prepare_p, ITs_media_vision_face_recognition_startup, - ITs_media_vision_face_recognition_cleanup }, - { "ITc_mv_face_recognition_register_unregister_p", ITc_mv_face_recognition_register_unregister_p, - ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, - { "ITc_mv_face_recognition_inference_p", ITc_mv_face_recognition_inference_p, - ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mediavision_mv_inference_create_destroy_p", ITc_mediavision_mv_inference_create_destroy_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_configure_p", ITc_mediavision_mv_inference_configure_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_prepare_p", ITc_mediavision_mv_inference_prepare_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_foreach_supported_engine_p", ITc_mediavision_mv_inference_foreach_supported_engine_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_image_classify_p", ITc_mediavision_mv_inference_image_classify_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_object_detect_p", ITc_mediavision_mv_inference_object_detect_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_face_detect_p", ITc_mediavision_mv_inference_face_detect_p, ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_facial_landmark_detect_p", ITc_mediavision_mv_inference_facial_landmark_detect_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_pose_landmark_detect_p", ITc_mediavision_mv_inference_pose_landmark_detect_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_get_number_of_poses_p", ITc_mediavision_mv_inference_get_number_of_poses_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_get_number_of_landmarks_p", ITc_mediavision_mv_inference_get_number_of_landmarks_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_get_landmark_p", ITc_mediavision_mv_inference_get_landmark_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_inference_pose_get_label_p", ITc_mediavision_mv_inference_pose_get_label_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_engine_set_get_array_string_attribute_p",ITc_mediavision_mv_engine_set_get_array_string_attribute_p, ITs_media_vision_inference_startup,ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_pose_create_destroy_p", ITc_mediavision_mv_pose_create_destroy_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_pose_set_from_file_p", ITc_mediavision_mv_pose_set_from_file_p,ITs_media_vision_inference_startup, ITs_media_vision_inference_cleanup }, + { "ITc_mediavision_mv_pose_compare_p", ITc_mediavision_mv_pose_compare_p, ITs_media_vision_inference_startup,ITs_media_vision_inference_cleanup }, + { "ITc_mv_face_recognition_create_destroy_p", ITc_mv_face_recognition_create_destroy_p,ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_face_recognition_prepare_p", ITc_mv_face_recognition_prepare_p, ITs_media_vision_face_recognition_startup,ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_face_recognition_register_unregister_p", ITc_mv_face_recognition_register_unregister_p,ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_face_recognition_inference_p", ITc_mv_face_recognition_inference_p,ITs_media_vision_face_recognition_startup, ITs_media_vision_face_recognition_cleanup }, + { "ITc_mv_image_classification_create_destroy_p", ITc_mv_image_classification_create_destroy_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_configure_prepare_p", ITc_mv_image_classification_configure_prepare_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_inference_p", ITc_mv_image_classification_inference_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_inference_async_p", ITc_mv_image_classification_inference_async_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_image_classification_get_result_count_label_p", ITc_mv_image_classification_get_result_count_label_p,ITs_media_vision_image_classification_startup, ITs_media_vision_image_classification_cleanup }, + { "ITc_mv_face_detection_create_destroy_p", ITc_mv_face_detection_create_destroy_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_configure_prepare_p", ITc_mv_face_detection_configure_prepare_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_inference_p", ITc_mv_face_detection_inference_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_inference_async_p", ITc_mv_face_detection_inference_async_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_face_detection_get_result_count_bound_box_p", ITc_mv_face_detection_get_result_count_bound_box_p,ITs_media_vision_face_detection_startup, ITs_media_vision_face_detection_cleanup }, + { "ITc_mv_facial_landmark_create_destroy_p", ITc_mv_facial_landmark_create_destroy_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_configure_prepare_p", ITc_mv_facial_landmark_configure_prepare_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_inference_p", ITc_mv_facial_landmark_inference_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_inference_async_p", ITc_mv_facial_landmark_inference_async_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_facial_landmark_get_result_count_position_p", ITc_mv_facial_landmark_get_result_count_position_p,ITs_media_vision_facial_landmark_startup, ITs_media_vision_facial_landmark_cleanup }, + { "ITc_mv_pose_landmark_create_destroy_p", ITc_mv_pose_landmark_create_destroy_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_configure_prepare_p", ITc_mv_pose_landmark_configure_prepare_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_inference_p", ITc_mv_pose_landmark_inference_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_inference_async_p", ITc_mv_pose_landmark_inference_async_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_pose_landmark_get_result_count_position_p", ITc_mv_pose_landmark_get_result_count_position_p,ITs_media_vision_pose_landmark_startup, ITs_media_vision_pose_landmark_cleanup }, + { "ITc_mv_object_detection_create_destroy_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_configure_prepare_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_inference_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_inference_async_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, + { "ITc_mv_object_detection_get_result_count_bound_box_p", ITc_mv_object_detection_create_destroy_p,ITs_media_vision_object_detection_startup, ITs_media_vision_object_detection_cleanup }, { NULL, NULL } };