mv_inference: Pass a generic channel value to backend engine
authorInki Dae <inki.dae@samsung.com>
Wed, 12 Feb 2020 04:35:44 +0000 (13:35 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 14 Apr 2020 00:40:31 +0000 (09:40 +0900)
mMatType has OpenCV specific value so we shouldn't pass
the specific value to a backend engine but a generic one, mCh, instead.

Change-Id: I3d92a0f636b55c2529202d57f7ded63c6225e37b
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_inference/inference/src/Inference.cpp

index a378dd895ef79b80e17cdb18bbe1102c0fe59cd4..b3273c7ad7e5a291107cee1348e054b2a505ba35 100755 (executable)
@@ -488,6 +488,27 @@ int Inference::Load(void)
                return ConvertEngineErrorToVisionError(ret);
        }
 
+       tensor_t inputData;
+       std::vector<int> info{1, mCh, mInputSize.height, mInputSize.width};
+       inputData.dimInfo.push_back(info);
+
+       // some plug-in (opencv) doesn't allocate memory for input while loading models
+       // But, others (tflite) allcate memory while loading.
+       // Thus, the SetInputData() will be implemented in plug-in such as OpenCV, but
+       // just leave empty in plug-in such as tflite.
+       ret = mBackend->SetInputDataBuffer(inputData);
+       if (ret != INFERENCE_ENGINE_ERROR_NONE) {
+               LOGE("Fail to SetInputData");
+               return ConvertEngineErrorToVisionError(ret);;
+       }
+
+       void *dataPtr = mBackend->GetInputDataPtr();
+       if (dataPtr == nullptr) {
+               LOGE("input data address is null");
+               std::vector<std::string>().swap(models);
+               return MEDIA_VISION_ERROR_INTERNAL;
+       }
+
        //get type and allocate memory to mInputBuffer;
        InputAttrType attrType = static_cast<InputAttrType>(mBackend->GetInputLayerAttrType());
        if (attrType == InputAttrUInt8) {
@@ -520,27 +541,6 @@ int Inference::Load(void)
                return MEDIA_VISION_ERROR_NOT_SUPPORTED_FORMAT;
        }
 
-       tensor_t inputData;
-       std::vector<int> info{1, mMatType, mInputSize.height, mInputSize.width};
-       inputData.dimInfo.push_back(info);
-
-       // some plug-in (opencv) doesn't allocate memory for input while loading models
-       // But, others (tflite) allcate memory while loading.
-       // Thus, the SetInputData() will be implemented in plug-in such as OpenCV, but
-       // just leave empty in plug-in such as tflite.
-       ret = mBackend->SetInputDataBuffer(inputData);
-       if (ret != INFERENCE_ENGINE_ERROR_NONE) {
-               LOGE("Fail to SetInputData");
-               return ConvertEngineErrorToVisionError(ret);;
-       }
-
-       void *dataPtr = mBackend->GetInputDataPtr();
-       if (dataPtr == nullptr) {
-               LOGE("input data address is null");
-               std::vector<std::string>().swap(models);
-               return MEDIA_VISION_ERROR_INTERNAL;
-       }
-
        mInputBuffer = cv::Mat(mInputSize.height, mInputSize.width, mMatType, dataPtr);
 
        mCanRun = true;