Implementation of inheritance relationship. 31/212531/5 accepted/tizen/unified/20190916.111636 submit/tizen/20190905.022044 submit/tizen/20190905.073548
authorHyunsoo Park <hance.park@samsung.com>
Thu, 22 Aug 2019 11:21:30 +0000 (20:21 +0900)
committerHyunsoo Park <hance.park@samsung.com>
Tue, 3 Sep 2019 07:57:00 +0000 (16:57 +0900)
IInferenceEngineCommon class should be parent of IInferenceEngineVision class.
So i implemented inheritance relationship between two classes.

Change-Id: I9a4e572dbba9d4e8fd118ec73305f46a912015fa
Signed-off-by: Hyunsoo Park <hance.park@samsung.com>
common/inference_engine_common_impl.cpp
include/inference_engine_common.h
include/inference_engine_common_impl.h
include/inference_engine_vision.h
include/inference_engine_vision_impl.h
packaging/inference-engine-interface.spec
vision/inference_engine_vision_impl.cpp

index ccd43351cadc184b47d7066db883ea54b46b513e..def2ace7949e1c426463b15ffae3b2ea07547c08 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#include <inference_engine_error.h>
-#include <inference_engine_common_impl.h>
+#include "inference_engine_error.h"
+#include "inference_engine_common_impl.h"
 
 #include <fstream>
 #include <iostream>
@@ -95,15 +95,6 @@ int InferenceEngineCommon::SetInputTensorParam()
     return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
 }
 
-int InferenceEngineCommon::SetInputTensorParamNode(std::string node)
-{
-    int ret = engine->SetInputTensorParamNode(node);
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to SetInputTensorParamNode");
-
-    return ret;
-}
-
 int InferenceEngineCommon::SetOutputTensorParam()
 {
     return INFERENCE_ENGINE_ERROR_NOT_SUPPORTED;
@@ -111,10 +102,11 @@ int InferenceEngineCommon::SetOutputTensorParam()
 
 int InferenceEngineCommon::SetOutputTensorParamNodes(std::vector<std::string> nodes)
 {
+    LOGI("ENTER");
     int ret = engine->SetOutputTensorParamNodes(nodes);
     if (ret != INFERENCE_ENGINE_ERROR_NONE)
         LOGE("Fail to SetOutputTensorParamNodes");
-
+    LOGI("LEAVE");
     return ret;
 }
 
@@ -127,7 +119,7 @@ int InferenceEngineCommon::SetTargetDevice(inference_target_type_e type)
     return ret;
 }
 
-int InferenceEngineCommon::Load()
+int InferenceEngineCommon::Load(inference_input_type_e type)
 {
     int ret = engine->Load();
     if (ret != INFERENCE_ENGINE_ERROR_NONE)
@@ -138,7 +130,7 @@ int InferenceEngineCommon::Load()
         LOGE("Fail to load CreateInputLayerPassage");
 
 
-    ret = engine->PrepareInputLayerPassage();
+    ret = engine->PrepareInputLayerPassage(type);
     if (ret != INFERENCE_ENGINE_ERROR_NONE)
         LOGE("Fail to load PrepareInputLayerPassage");
 
@@ -155,13 +147,24 @@ int InferenceEngineCommon::Run(std::vector<float> tensor)
     return ret;
 }
 
+int InferenceEngineCommon::SetInputTensorParamNode(std::string node)
+{
+    LOGE("ENTER");
+    int ret = engine->SetInputTensorParamNode(node);
+    if (ret != INFERENCE_ENGINE_ERROR_NONE)
+        LOGE("Fail to SetInputTensorParamNode");
+    LOGE("LEAVE");
+    return ret;
+}
+
 int InferenceEngineCommon::GetInferenceResult(std::vector<std::vector<int>>& dimInfo, std::vector<float*>& results)
 {
+    LOGE("ENTER");
     int ret = engine->GetInferenceResult(dimInfo, results);
 
     if (ret != INFERENCE_ENGINE_ERROR_NONE)
         LOGE("Fail to GetInferenceResult");
-
+    LOGE("LEAVE");
     return ret;
 }
 } /* Common */
index 985e8d96f434cd8ffa3f61e4b679b9055dcd6c13..f7fc23e0226464aa6bd13b00fd6cd28833d78f3b 100644 (file)
@@ -35,7 +35,6 @@ public:
 
     virtual int SetInputTensorParamNode(std::string node) = 0;
 
-
     // OutputTensor
     virtual int SetOutputTensorParam() = 0;
 
@@ -48,8 +47,7 @@ public:
 
     virtual int CreateInputLayerPassage() = 0;
 
-    virtual int PrepareInputLayerPassage() = 0;
-
+    virtual int PrepareInputLayerPassage(inference_input_type_e type) = 0;
 
     virtual int Run(std::vector<float> tensor) = 0;
 
index 6b37b1555d179cad84c61c67dce697450871c5c9..ab78c912bea62d13dabc09b471325e71d2b9250d 100644 (file)
@@ -20,8 +20,8 @@
 #include <vector>
 #include <string>
 
-#include <inference_engine_common.h>
-#include <inference_engine_type.h>
+#include "inference_engine_common.h"
+#include "inference_engine_type.h"
 
 namespace InferenceEngineInterface {
 namespace Common {
@@ -43,7 +43,6 @@ public:
 
     int SetInputTensorParamNode(std::string node);
 
-
     // OutputTensor
     int SetOutputTensorParam();
 
@@ -52,22 +51,18 @@ public:
     int SetTargetDevice(inference_target_type_e type);
 
     // Load and Run
-    int Load();
-
-    int CreateInputLayerPassage();
-
-    int PrepareInputLayerPassage();
-
+    int Load(inference_input_type_e type);
 
     int Run(std::vector<float> tensor);
 
     int GetInferenceResult(std::vector<std::vector<int>>& dimInfo, std::vector<float*>& results);
 
 private:
-    void *handle;
-    IInferenceEngineCommon *engine;
     std::string mBackendLibName;
     std::vector<std::string> mUserListName;
+protected:
+    void *handle;
+    IInferenceEngineCommon *engine;
 
 };
 
index 6b143baaf44508eac4952c815a3ceb9299cef6fa..26f4f89a1a1236d9826360ef143e2b05e7087f12 100644 (file)
 #include <string>
 
 #include "inference_engine_type.h"
+#include "inference_engine_common.h"
 #include <opencv2/core.hpp>
 
 namespace InferenceEngineInterface {
 namespace Vision {
 
-class IInferenceEngineVision {
+class IInferenceEngineVision : public virtual Common::IInferenceEngineCommon {
 public:
-
+    using Common::IInferenceEngineCommon::GetInferenceResult;
     virtual ~IInferenceEngineVision() {};
 
     // InputTensor
-    virtual int SetInputTensorParam() = 0;
 
     virtual int SetInputTensorParamInput(int width, int height, int dim, int ch) = 0;
 
     virtual int SetInputTensorParamNorm(double deviation, double mean) = 0;
 
-    virtual int SetInputTensorParamNode(std::string node) = 0;
-
-
     // OutputTensor
-    virtual int SetOutputTensorParam() = 0;
 
     virtual int SetOutputTensorParamThresHold(double threshold) = 0;
 
@@ -50,21 +46,10 @@ public:
 
     virtual int SetOutputTensorParamType(int type) = 0;
 
-    virtual int SetOutputTensorParamNodes(std::vector<std::string> nodes) = 0;
-
-    virtual int SetTargetDevice(inference_target_type_e type) = 0;
-
     // Load and Run
-    virtual int Load() = 0;
-
-    virtual int CreateInputLayerPassage() = 0;
-
-    virtual int PrepareInputLayerPassage(inference_input_type_e type) = 0;
  
     virtual int Run(cv::Mat tensor) = 0;
 
-    virtual int Run(std::vector<float> tensor) = 0;
-
     virtual int GetInferenceResult(ImageClassificationResults& results) = 0;
 
     virtual int GetInferenceResult(ObjectDetectionResults& results) = 0;
@@ -73,8 +58,6 @@ public:
 
     virtual int GetInferenceResult(FacialLandMarkDetectionResults& results) = 0;
 
-    virtual int GetInferenceResult(std::vector<std::vector<int>>& dimInfo, std::vector<float*>& results) = 0;
-
     virtual int GetNumberOfOutputs() = 0;
     
     virtual void SetUserListName(std::string userlist) = 0;
index 12304f9b8427adb1738b6ad228eefd8e8a934b12..89a1c131116fa7b186d67881a7808bc6b0494ef9 100644 (file)
 
 #include <vector>
 #include <string>
-
-#include <inference_engine_vision.h>
-#include <inference_engine_type.h>
+#include "inference_engine_common_impl.h"
+#include "inference_engine_vision.h"
+#include "inference_engine_type.h"
 #include <opencv2/core.hpp>
 
 
 namespace InferenceEngineInterface {
 namespace Vision {
 
-class InferenceEngineVision {
+class InferenceEngineVision : public Common::InferenceEngineCommon {
 public:
+    using Common::InferenceEngineCommon::GetInferenceResult;
     InferenceEngineVision(std::string backend);
 
     ~InferenceEngineVision();
@@ -44,8 +45,6 @@ public:
 
     int SetInputTensorParamNorm(double deviation, double mean);
 
-    int SetInputTensorParamNode(std::string node);
-
     // Output Tensor parameters
     int SetOutputTensorParamThresHold(double threshold);
 
@@ -53,13 +52,6 @@ public:
 
     int SetOutputTensorParamType(int type);
 
-    int SetOutputTensorParamNodes(std::vector<std::string> nodes);
-
-    // Set target device
-    int SetTargetDevice(inference_target_type_e device);
-
-    int Load();
-
     int Run(cv::Mat tensor);
 
     int GetInferenceResult(ImageClassificationResults& results);
@@ -70,18 +62,16 @@ public:
 
     int GetInferenceResult(FacialLandMarkDetectionResults& results);
 
-    int GetInferenceResult(std::vector<std::vector<int>>& dimInfo, std::vector<float*>& results);
-
     int GetNumberOfOutputs();
 
     void SetUserListName(std::string userlist);
 
 private:
-    void *handle;
-    IInferenceEngineVision *engine;
     std::string mBackendLibName;
     std::vector<std::string> mUserListName;
-
+protected:
+    void *handle;
+    IInferenceEngineVision *engine;
 };
 
 } /* Vision */
index d4ce9f31a43fe898c369d6afb93cc227189e5dfa..52a667a4e750aa706771430e8fdd93d57340b2e6 100644 (file)
@@ -1,7 +1,7 @@
 Name:        inference-engine-interface
 Summary:     Interface of inference engines
 Version:     0.0.1
-Release:     3
+Release:     4
 Group:       Multimedia/Framework
 License:     Apache-2.0
 Source0:     %{name}-%{version}.tar.gz
index cb29c60f82725087306c4f2f8c5e53dbfa397c0e..e383f4e34d457d28910734090d343af6cb4a2c4a 100644 (file)
@@ -14,8 +14,8 @@
  * limitations under the License.
  */
 
-#include <inference_engine_error.h>
-#include <inference_engine_vision_impl.h>
+#include "inference_engine_error.h"
+#include "inference_engine_vision_impl.h"
 
 
 #include <fstream>
@@ -37,8 +37,7 @@ extern "C" {
 
 namespace InferenceEngineInterface {
 namespace Vision {
-
-InferenceEngineVision::InferenceEngineVision(std::string backend)
+InferenceEngineVision::InferenceEngineVision(std::string backend) : Common::InferenceEngineCommon(backend)
 {
     LOGE("ENTER");
     mBackendLibName = "libinference-engine-" + backend + ".so";
@@ -62,7 +61,8 @@ int InferenceEngineVision::Init(std::string configFile,
     LOGW("ENTER");
     char *error = NULL;
     handle = dlopen(mBackendLibName.c_str(), RTLD_LAZY);
-    LOGE("dlopen %s", mBackendLibName.c_str());
+    LOGI("HANDLE : [%p]", handle);
+
     if (!handle) {
         LOGE("Fail to dlopen %s", mBackendLibName.c_str());
         LOGE("Error: %s\n", dlerror());
@@ -77,12 +77,18 @@ int InferenceEngineVision::Init(std::string configFile,
     }
 
     engine = EngineInit(configFile, weightFile, userFile);
+    LOGI("dlopen %s", mBackendLibName.c_str());
+
     if (engine == NULL) {
         LOGE("Fail to EngineInit");
         dlclose(handle);
         return INFERENCE_ENGINE_ERROR_INTERNAL;
     }
 
+    Common::InferenceEngineCommon::handle = handle;
+
+    Common::InferenceEngineCommon::engine = engine;
+
     LOGW("LEAVE");
     return INFERENCE_ENGINE_ERROR_NONE;
 }
@@ -110,24 +116,6 @@ int InferenceEngineVision::SetInputTensorParamNorm(double deviation, double mean
     return ret;
 }
 
-int InferenceEngineVision::SetInputTensorParamNode(std::string node)
-{
-    int ret = engine->SetInputTensorParamNode(node);
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to SetInputTensorParamNode");
-
-    return ret;
-}
-
-int InferenceEngineVision::SetOutputTensorParamNodes(std::vector<std::string> nodes)
-{
-    int ret = engine->SetOutputTensorParamNodes(nodes);
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to SetOutputTensorParamNodes");
-
-    return ret;
-}
-
 int InferenceEngineVision::SetOutputTensorParamThresHold(double threshold)
 {
     int ret = engine->SetOutputTensorParamThresHold(threshold);
@@ -155,32 +143,6 @@ int InferenceEngineVision::SetOutputTensorParamType(int type)
     return ret;
 }
 
-int InferenceEngineVision::SetTargetDevice(inference_target_type_e type)
-{
-    int ret = engine->SetTargetDevice(type);
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to SetTargetDevice");
-
-    return ret;
-}
-
-int InferenceEngineVision::Load()
-{
-    int ret = engine->Load();
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to load InferenceEngineVision");
-
-    ret = engine->CreateInputLayerPassage();
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to load CreateInputLayerPassage");
-
-    ret = engine->PrepareInputLayerPassage(INFERENCE_INPUT_IMAGE);
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to load PrepareInputLayerPassage");
-
-    return ret;
-}
-
 int InferenceEngineVision::Run(cv::Mat tensor)
 {
     int ret = engine->Run(tensor);
@@ -230,16 +192,6 @@ int InferenceEngineVision::GetInferenceResult(FacialLandMarkDetectionResults& re
     return ret;
 }
 
-int InferenceEngineVision::GetInferenceResult(std::vector<std::vector<int>>& dimInfo, std::vector<float*>& results)
-{
-    int ret = engine->GetInferenceResult(dimInfo, results);
-
-    if (ret != INFERENCE_ENGINE_ERROR_NONE)
-        LOGE("Fail to GetInferenceResult");
-
-    return ret;
-}
-
 int InferenceEngineVision::GetNumberOfOutputs()
 {
     return engine->GetNumberOfOutputs();
@@ -249,6 +201,5 @@ void InferenceEngineVision::SetUserListName(std::string userlist)
 {
     ;
 }
-
 } /* Vision */
 } /* InferenceEngineInterface */