[ITC][UTC][media_vision][ACR-1803] change feature key for face recognition 70/301970/1
authorInki Dae <inki.dae@samsung.com>
Mon, 20 Nov 2023 07:25:55 +0000 (16:25 +0900)
committerInki Dae <inki.dae@samsung.com>
Wed, 29 Nov 2023 00:08:50 +0000 (09:08 +0900)
Change-Id: I6b836caddd432226978d379a751b10f8750f1c82
Signed-off-by: Inki Dae <inki.dae@samsung.com>
src/itc/media-vision/ITs-media-vision-common.h
src/itc/media-vision/ITs-media-vision-face-recognition.c
src/utc/capi-media-vision/utc-mv_face_recognition.c

index e06b63037b4e68027c222b5acefca3e87a5bd3c5..f88210903f44408f03fb347df47886db73e6c354 100755 (executable)
 
 #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
index e5c9081c67226e2ae8928f258b643d7e7015ad69..46d1365d100e4fd4d6c3b6f9af6667e08706678b 100644 (file)
@@ -1,17 +1,17 @@
-/**\r
-* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved\r
-*\r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
-* you may not use this file except in compliance with the License.\r
-* You may obtain a copy of the License at\r
-*\r
-* http://www.apache.org/licenses/LICENSE-2.0\r
-*\r
-* Unless required by applicable law or agreed to in writing, software\r
-* distributed under the License is distributed on an "AS IS" BASIS,\r
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-* See the License for the specific language governing permissions and\r
-* limitations under the License.\r
+/**
+* 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"
 *  @{
 */
 
-#define gMaxLabelCount 2\r
+#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] = {\r
-       "00.jpg", "01.jpg", "02.jpg", "03.jpg", "04.jpg",\r
-       "05.jpg", "06.jpg", "07.jpg", "08.jpg", "09.jpg"\r
-};\r
-\r
-static const char *label_names[gMaxLabelCount] = {\r
-       "p1", "p2"\r
+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));\r
-               snprintf(gFaceRecognitionExampleDir1, strlen(pszValue) + strlen("/res/res/face_recognition/images/P1") + 1, "%s/res/res/face_recognition/images/P1", pszValue);\r
-\r
-               gFaceRecognitionExampleDir2 = (char*)calloc(strlen(pszValue) + strlen("/res/res/face_recognition/images/P2") + 1, sizeof(char));\r
+               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)\r
-{\r
+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));\r
-\r
-       for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) {\r
-               for (unsigned int img_idx = 0; img_idx < gMaxImageCount / 2; ++img_idx) {\r
-                       char pszImageFileName[PATHLEN] = "";\r
-\r
-                       nRet = mv_create_source(&gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet));\r
-\r
-                       if (label_idx == 0)\r
-                               snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]);\r
-                       else\r
-                               snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]);\r
-\r
-                       nRet = image_load(pszImageFileName, gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_face_recognition_register(g_hFaceRecognitionHandle, gSourceHandle, label_names[label_idx]);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_register", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_destroy_source(gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet));\r
-               }\r
-       }\r
-\r
-       for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) {\r
-               nRet = mv_face_recognition_unregister(g_hFaceRecognitionHandle, label_names[label_idx]);\r
-               PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_unregister", MediaVisionGetError(nRet));\r
-       }\r
-\r
-       return 0;\r
+       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));\r
-       //register\r
-       for (unsigned int label_idx = 0; label_idx < gMaxLabelCount; ++label_idx) {\r
-               for (unsigned int img_idx = 0; img_idx < gMaxImageCount / 2; ++img_idx) {\r
-                       char pszImageFileName[PATHLEN] = "";\r
-\r
-                       nRet = mv_create_source(&gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet));\r
-\r
-                       if (label_idx == 0)\r
-                               snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]);\r
-                       else\r
-                               snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]);\r
-\r
-                       nRet = image_load(pszImageFileName, gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_face_recognition_register(g_hFaceRecognitionHandle, gSourceHandle, label_names[label_idx]);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_register", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_destroy_source(gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet));\r
-               }\r
+       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) {\r
-               for (unsigned int img_idx = 5; img_idx < gMaxImageCount; ++img_idx) {\r
-                       char pszImageFileName[PATHLEN] = "";\r
-                       const char *out_label = NULL;\r
-\r
-                       nRet = mv_create_source(&gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_create_source", MediaVisionGetError(nRet));\r
-\r
-                       if (label_idx == 0)\r
-                               snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir1, image_file_names[img_idx]);\r
-                       else\r
-                               snprintf(pszImageFileName, PATHLEN, "%s/%s", gFaceRecognitionExampleDir2, image_file_names[img_idx]);\r
-\r
-                       nRet = image_load(pszImageFileName, gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_face_recognition_inference(g_hFaceRecognitionHandle, gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_inference", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_face_recognition_get_label(g_hFaceRecognitionHandle, &out_label);\r
-                       if (nRet != MEDIA_VISION_ERROR_NO_DATA)\r
-                               PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_face_recognition_get_label", MediaVisionGetError(nRet));\r
-\r
-                       nRet = mv_destroy_source(gSourceHandle);\r
-                       PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "mv_destroy_source", MediaVisionGetError(nRet));\r
-               }\r
-       }\r
-\r
+       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;
 }
index 304f2536dea673b66ac6989db7caf0538a7e37f9..6c1d38b2db911db1bc9f483f90d2027879440359 100755 (executable)
@@ -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);
 }
 
 /**