From: Inki Dae Date: Mon, 20 Nov 2023 07:25:55 +0000 (+0900) Subject: [ITC][UTC][media_vision][ACR-1803] change feature key for face recognition X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=235be53e08f708b8f9ea0c9594dba4845b4cfd57;p=test%2Ftct%2Fnative%2Fapi.git [ITC][UTC][media_vision][ACR-1803] change feature key for face recognition Change-Id: I6b836caddd432226978d379a751b10f8750f1c82 Signed-off-by: Inki Dae --- diff --git a/src/itc/media-vision/ITs-media-vision-common.h b/src/itc/media-vision/ITs-media-vision-common.h index e06b63037..f88210903 100755 --- a/src/itc/media-vision/ITs-media-vision-common.h +++ b/src/itc/media-vision/ITs-media-vision-common.h @@ -62,8 +62,10 @@ #define BARCODEDETFEATURE "http://tizen.org/feature/vision.barcode_detection" #define BARCODEGENFEATURE "http://tizen.org/feature/vision.barcode_generation" -#define VISIONINFERENCEFEATURE "http://tizen.org/feature/vision.inference" -#define VISIONINFERENCEFACEFEATURE "http://tizen.org/feature/vision.inference.face" +#define VISIONINFERENCEFEATURE "http://tizen.org/feature/vision.inference" +#define VISIONTRAININGFEATURE "http://tizen.org/feature/vision.training" +#define VISIONINFERENCEFACERECOGNITIONFEATURE "http://tizen.org/feature/vision.inference.face_recognition" +#define VISIONTRAININGFACERECOGNITIONFEATURE "http://tizen.org/feature/vision.training.face_recognition" #define VISIONROITRACKINGFEATURE "http://tizen.org/feature/vision.roi_tracking" #define PATHLEN 1024 diff --git a/src/itc/media-vision/ITs-media-vision-face-recognition.c b/src/itc/media-vision/ITs-media-vision-face-recognition.c index e5c9081c6..46d1365d1 100644 --- a/src/itc/media-vision/ITs-media-vision-face-recognition.c +++ b/src/itc/media-vision/ITs-media-vision-face-recognition.c @@ -1,17 +1,17 @@ -/** -* Copyright (c) 2022 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. +/** +* Copyright (c) 2022 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" @@ -23,20 +23,20 @@ * @{ */ -#define gMaxLabelCount 2 +#define gMaxLabelCount 2 #define gMaxImageCount 10 static mv_face_recognition_h g_hFaceRecognitionHandle = NULL; static mv_source_h gSourceHandle = NULL; const char *gFaceRecognitionExampleDir1 = NULL; const char *gFaceRecognitionExampleDir2 = NULL; -static const char *image_file_names[gMaxImageCount] = { - "00.jpg", "01.jpg", "02.jpg", "03.jpg", "04.jpg", - "05.jpg", "06.jpg", "07.jpg", "08.jpg", "09.jpg" -}; - -static const char *label_names[gMaxLabelCount] = { - "p1", "p2" +static const char *image_file_names[gMaxImageCount] = { + "00.jpg", "01.jpg", "02.jpg", "03.jpg", "04.jpg", + "05.jpg", "06.jpg", "07.jpg", "08.jpg", "09.jpg" +}; + +static const char *label_names[gMaxLabelCount] = { + "p1", "p2" }; /** @@ -58,17 +58,20 @@ void ITs_media_vision_face_recognition_startup(void) g_bMediavisionFaceRecognitionModelCreation = false; g_bMismatch = false; - g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFACEFEATURE, API_NAMESPACE); + g_bIsFaceRecognitionFeatureSupported = TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFEATURE, API_NAMESPACE) && + TCTCheckSystemInfoFeatureSupported(VISIONTRAININGFEATURE, API_NAMESPACE) && + TCTCheckSystemInfoFeatureSupported(VISIONINFERENCEFACERECOGNITIONFEATURE, API_NAMESPACE) && + TCTCheckSystemInfoFeatureSupported(VISIONTRAININGFACERECOGNITIONFEATURE, 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); - gFaceRecognitionExampleDir1 = (char*)calloc(strlen(pszValue) + strlen("/res/res/face_recognition/images/P1") + 1, sizeof(char)); - snprintf(gFaceRecognitionExampleDir1, strlen(pszValue) + strlen("/res/res/face_recognition/images/P1") + 1, "%s/res/res/face_recognition/images/P1", pszValue); - - gFaceRecognitionExampleDir2 = (char*)calloc(strlen(pszValue) + strlen("/res/res/face_recognition/images/P2") + 1, sizeof(char)); + gFaceRecognitionExampleDir1 = (char*)calloc(strlen(pszValue) + strlen("/res/res/face_recognition/images/P1") + 1, sizeof(char)); + snprintf(gFaceRecognitionExampleDir1, strlen(pszValue) + strlen("/res/res/face_recognition/images/P1") + 1, "%s/res/res/face_recognition/images/P1", pszValue); + + gFaceRecognitionExampleDir2 = (char*)calloc(strlen(pszValue) + strlen("/res/res/face_recognition/images/P2") + 1, sizeof(char)); snprintf(gFaceRecognitionExampleDir2, strlen(pszValue) + strlen("/res/res/face_recognition/images/P2") + 1, "%s/res/res/face_recognition/images/P2", pszValue); } else @@ -207,42 +210,42 @@ int ITc_mv_face_recognition_prepare_p(void) //& type: auto //& purpose: To test mv_create_source, image_load, mv_face_recognition_register, mv_destroy_source, mv_face_recognition_unregister API -int ITc_mv_face_recognition_register_unregister_p(void) -{ +int ITc_mv_face_recognition_register_unregister_p(void) +{ START_TEST_FACE_RECOGNITION; int nRet = mv_face_recognition_prepare(g_hFaceRecognitionHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_prepare", MediaVisionGetError(nRet)); - - for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { - for (unsigned int img_idx = 0; img_idx < gMaxImageCount / 2; ++img_idx) { - char pszImageFileName[PATHLEN] = ""; - - nRet = mv_create_source(&gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); - - if (label_idx == 0) - snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]); - else - snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]); - - nRet = image_load(pszImageFileName, gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); - - nRet = mv_face_recognition_register(g_hFaceRecognitionHandle, gSourceHandle, label_names[label_idx]); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_register", MediaVisionGetError(nRet)); - - nRet = mv_destroy_source(gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet)); - } - } - - for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { - nRet = mv_face_recognition_unregister(g_hFaceRecognitionHandle, label_names[label_idx]); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_unregister", MediaVisionGetError(nRet)); - } - - return 0; + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_prepare", MediaVisionGetError(nRet)); + + for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { + for (unsigned int img_idx = 0; img_idx < gMaxImageCount / 2; ++img_idx) { + char pszImageFileName[PATHLEN] = ""; + + nRet = mv_create_source(&gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + + if (label_idx == 0) + snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]); + else + snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]); + + nRet = image_load(pszImageFileName, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_face_recognition_register(g_hFaceRecognitionHandle, gSourceHandle, label_names[label_idx]); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_register", MediaVisionGetError(nRet)); + + nRet = mv_destroy_source(gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet)); + } + } + + for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { + nRet = mv_face_recognition_unregister(g_hFaceRecognitionHandle, label_names[label_idx]); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_unregister", MediaVisionGetError(nRet)); + } + + return 0; } /** @@ -267,58 +270,58 @@ int ITc_mv_face_recognition_inference_p(void) START_TEST_FACE_RECOGNITION; int nRet = mv_face_recognition_prepare(g_hFaceRecognitionHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_prepare", MediaVisionGetError(nRet)); - //register - for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { - for (unsigned int img_idx = 0; img_idx < gMaxImageCount / 2; ++img_idx) { - char pszImageFileName[PATHLEN] = ""; - - nRet = mv_create_source(&gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); - - if (label_idx == 0) - snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]); - else - snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]); - - nRet = image_load(pszImageFileName, gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); - - nRet = mv_face_recognition_register(g_hFaceRecognitionHandle, gSourceHandle, label_names[label_idx]); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_register", MediaVisionGetError(nRet)); - - nRet = mv_destroy_source(gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet)); - } + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_prepare", MediaVisionGetError(nRet)); + //register + for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { + for (unsigned int img_idx = 0; img_idx < gMaxImageCount / 2; ++img_idx) { + char pszImageFileName[PATHLEN] = ""; + + nRet = mv_create_source(&gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + + if (label_idx == 0) + snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]); + else + snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]); + + nRet = image_load(pszImageFileName, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_face_recognition_register(g_hFaceRecognitionHandle, gSourceHandle, label_names[label_idx]); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_register", MediaVisionGetError(nRet)); + + nRet = mv_destroy_source(gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet)); + } } //inference & get_label - for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { - for (unsigned int img_idx = 5; img_idx < gMaxImageCount; ++img_idx) { - char pszImageFileName[PATHLEN] = ""; - const char *out_label = NULL; - - nRet = mv_create_source(&gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); - - if (label_idx == 0) - snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]); - else - snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]); - - nRet = image_load(pszImageFileName, gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); - - nRet = mv_face_recognition_inference(g_hFaceRecognitionHandle, gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_inference", MediaVisionGetError(nRet)); - - nRet = mv_face_recognition_get_label(g_hFaceRecognitionHandle, &out_label); - if (nRet != MEDIA_VISION_ERROR_NO_DATA) - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_get_label", MediaVisionGetError(nRet)); - - nRet = mv_destroy_source(gSourceHandle); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet)); - } - } - + for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) { + for (unsigned int img_idx = 5; img_idx < gMaxImageCount; ++img_idx) { + char pszImageFileName[PATHLEN] = ""; + const char *out_label = NULL; + + nRet = mv_create_source(&gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet)); + + if (label_idx == 0) + snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]); + else + snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]); + + nRet = image_load(pszImageFileName, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + + nRet = mv_face_recognition_inference(g_hFaceRecognitionHandle, gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_inference", MediaVisionGetError(nRet)); + + nRet = mv_face_recognition_get_label(g_hFaceRecognitionHandle, &out_label); + if (nRet != MEDIA_VISION_ERROR_NO_DATA) + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_get_label", MediaVisionGetError(nRet)); + + nRet = mv_destroy_source(gSourceHandle); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet)); + } + } + return 0; } diff --git a/src/utc/capi-media-vision/utc-mv_face_recognition.c b/src/utc/capi-media-vision/utc-mv_face_recognition.c index 304f2536d..6c1d38b2d 100755 --- a/src/utc/capi-media-vision/utc-mv_face_recognition.c +++ b/src/utc/capi-media-vision/utc-mv_face_recognition.c @@ -92,14 +92,20 @@ _LOAD_IMAGE_FAIL: static bool is_face_recognition_feature_supported(void) { - bool isFaceRecognitionSupported =false; + bool isInferenceSupported =false; + bool isTrainingSupported =false; + bool isInferenceFaceRecognitionSupported =false; + bool isTrainingFaceRecognitionSupported =false; - system_info_get_platform_bool("http://tizen.org/feature/vision.inference.face", &isFaceRecognitionSupported); + system_info_get_platform_bool("http://tizen.org/feature/vision.inference", &isInferenceSupported); + system_info_get_platform_bool("http://tizen.org/feature/vision.training", &isTrainingSupported); + system_info_get_platform_bool("http://tizen.org/feature/vision.inference.face_recognition", &isInferenceFaceRecognitionSupported); + system_info_get_platform_bool("http://tizen.org/feature/vision.training.face_recognition", &isTrainingFaceRecognitionSupported); - if (!is_face_recognition_feature_supported) + if (!isInferenceSupported || !isTrainingSupported || !isInferenceFaceRecognitionSupported || !isTrainingFaceRecognitionSupported) printf("Not support face recognition feature."); - return isFaceRecognitionSupported; + return (isInferenceSupported && isTrainingSupported && isInferenceFaceRecognitionSupported && isTrainingFaceRecognitionSupported); } /**