Avoid throwing OpenCV's exception 78/101778/1 accepted/tizen/common/20161207.184503 accepted/tizen/ivi/20161208.012159 accepted/tizen/mobile/20161208.011802 accepted/tizen/tv/20161208.012006 accepted/tizen/wearable/20161208.012106 submit/tizen/20161207.075356
authorTae-Young Chung <ty83.chung@samsung.com>
Fri, 2 Dec 2016 06:39:59 +0000 (15:39 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Fri, 2 Dec 2016 06:40:15 +0000 (15:40 +0900)
Change-Id: I3b5acaa4c8559e30a9775e56e819a0e5da4c0ab9
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
mv_face/face/src/FaceRecognitionModel.cpp
packaging/capi-media-vision.spec

index a0754a7..2b33312 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 #include <unistd.h>
+#include <fstream>
 
 namespace MediaVision {
 namespace Face {
@@ -31,15 +32,41 @@ namespace {
 unsigned int DefaultUnisizeWidth = 200;
 unsigned int DefaultUnisizeHeight = 200;
 
+bool isEmptyAlgorithmParam(const std::string& path)
+{
+       char valid[256] = "";
+       std::ifstream ifs;
+
+       ifs.open(path.c_str());
+
+       if (!ifs.is_open()) {
+               LOGE("[%s] Can't open file.", path.c_str());
+               return true;
+       }
+
+       ifs.getline(valid, 256);
+       ifs.close();
+
+       LOGD("Validation string: %s", valid);
+       if (strlen(valid) <= 0) {
+               LOGE("algorithm params is empty.");
+               return true;
+       }
+
+       return false;
+}
+
 int CopyOpenCVAlgorithmParameters(const cv::Ptr<cv::FaceRecognizer>& srcAlg,
                cv::Ptr<cv::FaceRecognizer>& dstAlg)
 {
-       char tempPath[1024];
+       char tempPath[1024] = "";
 
        snprintf(tempPath, 1024, "/tmp/alg_copy_%p_%p", srcAlg.obj, dstAlg.obj);
 
        srcAlg->save(tempPath);
-       dstAlg->load(tempPath);
+
+       if (!isEmptyAlgorithmParam(tempPath))
+               dstAlg->load(tempPath);
 
        if (0 != remove(tempPath))
                LOGW("Error removing serialized FaceRecognizer in %s", tempPath);
index 59c1217..2f44fe3 100644 (file)
@@ -1,6 +1,6 @@
 Name:        capi-media-vision
 Summary:     Media Vision library for Tizen Native API
-Version:     0.3.22
+Version:     0.3.23
 Release:     1
 Group:       Multimedia/Framework
 License:     Apache-2.0 and BSD-2.0