Remove unnecessary log printing while face detection 23/187023/1 accepted/tizen/unified/20180820.060207 submit/tizen/20180820.024928
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 17 Aug 2018 08:48:33 +0000 (17:48 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 17 Aug 2018 08:51:12 +0000 (17:51 +0900)
While face detection, check engine_config and print logs even though engine_config is null.
This patch modify those parts.

Change-Id: I07b664268b64d68d2638f61cc9d74be33827b3c5
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
mv_face/face/src/mv_face_open.cpp
packaging/capi-media-vision.spec

index 65313637ebc2ec9d8fdd002f09114cbeae718b8f..56571cbff8590feb6075abb3187e175a9cf3a9aa 100644 (file)
@@ -86,83 +86,86 @@ int mv_face_detect_open(
                return error;
        }
 
-       char *haarcascadeFilepath;
-       error = mv_engine_config_get_string_attribute_c(
-                                       engine_cfg,
-                                       "MV_FACE_DETECTION_MODEL_FILE_PATH",
-                                       &haarcascadeFilepath);
-
        /* default path */
+       cv::Size minSize(-1, -1);
+       cv::Rect roi(-1, -1, -1, -1);
        std::string haarcascadeFilePathStr =
                        "/usr/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml";
-
-       if (error == MEDIA_VISION_ERROR_NONE) {
-               LOGI("Haarcascade file was set as default");
-               haarcascadeFilePathStr = std::string(haarcascadeFilepath);
-
-               free(haarcascadeFilepath);
-               haarcascadeFilepath = NULL;
-       } else {
-               LOGE("Error occurred during face detection haarcascade file receiving."
+       if (engine_cfg) {
+               /* set face detection model */
+               char *haarcascadeFilepath;
+               error = mv_engine_config_get_string_attribute_c(
+                               engine_cfg,
+                               "MV_FACE_DETECTION_MODEL_FILE_PATH",
+                               &haarcascadeFilepath);
+               if (error == MEDIA_VISION_ERROR_NONE) {
+                       LOGI("Haarcascade file was set as default");
+                       haarcascadeFilePathStr = std::string(haarcascadeFilepath);
+
+                       free(haarcascadeFilepath);
+                       haarcascadeFilepath = NULL;
+               } else {
+                       LOGE("Error occurred during face detection haarcascade file receiving."
                                " (%i)", error);
-       }
-
-       static FaceDetector faceDetector;
-
-       if (!faceDetector.loadHaarcascade(haarcascadeFilePathStr)) {
-               LOGE("Loading Haarcascade failed");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+               }
 
-       cv::Rect roi(-1, -1, -1, -1);
-       error = mv_engine_config_get_int_attribute_c(
+               /* Ser roi to be detected */
+               error = mv_engine_config_get_int_attribute_c(
                                engine_cfg,
                                MV_FACE_DETECTION_ROI_X,
                                &roi.x);
-       if (error != MEDIA_VISION_ERROR_NONE)
-               LOGE("Error occurred during face detection roi (x) receiving."
+               if (error != MEDIA_VISION_ERROR_NONE)
+                       LOGE("Error occurred during face detection roi (x) receiving."
                                " (%i)", error);
 
-       error = mv_engine_config_get_int_attribute_c(
-                               engine_cfg,
-                               MV_FACE_DETECTION_ROI_Y,
-                               &roi.y);
-       if (error != MEDIA_VISION_ERROR_NONE)
-               LOGE("Error occurred during face detection roi (y) receiving."
-                               " (%i)", error);
+               error = mv_engine_config_get_int_attribute_c(
+                                       engine_cfg,
+                                       MV_FACE_DETECTION_ROI_Y,
+                                       &roi.y);
+               if (error != MEDIA_VISION_ERROR_NONE)
+                       LOGE("Error occurred during face detection roi (y) receiving."
+                                       " (%i)", error);
 
-       error = mv_engine_config_get_int_attribute_c(
-                               engine_cfg,
-                               MV_FACE_DETECTION_ROI_WIDTH,
-                               &roi.width);
-       if (error != MEDIA_VISION_ERROR_NONE)
-               LOGE("Error occurred during face detection roi (width) receiving."
-                               " (%i)", error);
+               error = mv_engine_config_get_int_attribute_c(
+                                       engine_cfg,
+                                       MV_FACE_DETECTION_ROI_WIDTH,
+                                       &roi.width);
+               if (error != MEDIA_VISION_ERROR_NONE)
+                       LOGE("Error occurred during face detection roi (width) receiving."
+                                       " (%i)", error);
 
-       error = mv_engine_config_get_int_attribute_c(
-                               engine_cfg,
-                               MV_FACE_DETECTION_ROI_HEIGHT,
-                               &roi.height);
-       if (error != MEDIA_VISION_ERROR_NONE)
-               LOGE("Error occurred during face detection roi (height) receiving."
-                               " (%i)", error);
+               error = mv_engine_config_get_int_attribute_c(
+                                       engine_cfg,
+                                       MV_FACE_DETECTION_ROI_HEIGHT,
+                                       &roi.height);
+               if (error != MEDIA_VISION_ERROR_NONE)
+                       LOGE("Error occurred during face detection roi (height) receiving."
+                                       " (%i)", error);
+
+               /* Set minimum size to be detected */
+               error = mv_engine_config_get_int_attribute_c(
+                                       engine_cfg,
+                                       MV_FACE_DETECTION_MIN_SIZE_WIDTH,
+                                       &minSize.width);
+               if (error != MEDIA_VISION_ERROR_NONE)
+                       LOGE("Error occurred during face detection minimum width receiving."
+                                       " (%i)", error);
 
-       cv::Size minSize(-1, -1);
-       error = mv_engine_config_get_int_attribute_c(
-                               engine_cfg,
-                               MV_FACE_DETECTION_MIN_SIZE_WIDTH,
-                               &minSize.width);
-       if (error != MEDIA_VISION_ERROR_NONE)
-               LOGE("Error occurred during face detection minimum width receiving."
-                               " (%i)", error);
+               error = mv_engine_config_get_int_attribute_c(
+                                       engine_cfg,
+                                       MV_FACE_DETECTION_MIN_SIZE_HEIGHT,
+                                       &minSize.height);
+               if (error != MEDIA_VISION_ERROR_NONE)
+                       LOGE("Error occurred during face detection minimum height receiving."
+                                       " (%i)", error);
+       }
 
-       error = mv_engine_config_get_int_attribute_c(
-                               engine_cfg,
-                               MV_FACE_DETECTION_MIN_SIZE_HEIGHT,
-                               &minSize.height);
-       if (error != MEDIA_VISION_ERROR_NONE)
-               LOGE("Error occurred during face detection minimum height receiving."
-                               " (%i)", error);
+       static FaceDetector faceDetector;
+
+       if (!faceDetector.loadHaarcascade(haarcascadeFilePathStr)) {
+               LOGE("Loading Haarcascade failed");
+               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+       }
 
        std::vector<cv::Rect> faceLocations;
        if (!faceDetector.detectFaces(image, roi, minSize, faceLocations)) {
index 5a00d3d08e6c15e0346b73c7a326667811ed4eb4..0724a003a3eda1a22293ccac7a8b785a2bdc8c94 100644 (file)
@@ -1,7 +1,7 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.4.1
-Release:     3
+Version:     0.4.2
+Release:     4
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-3-Clause
 Source0:     %{name}-%{version}.tar.gz