From 5a09007b39e3e4da88402af2ae9b6b2c427cf0fe Mon Sep 17 00:00:00 2001 From: Inki Dae Date: Wed, 12 Feb 2020 13:35:44 +0900 Subject: [PATCH] mv_inference: Pass a generic channel value to backend engine 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 --- mv_inference/inference/src/Inference.cpp | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/mv_inference/inference/src/Inference.cpp b/mv_inference/inference/src/Inference.cpp index a378dd8..b3273c7 100755 --- a/mv_inference/inference/src/Inference.cpp +++ b/mv_inference/inference/src/Inference.cpp @@ -488,6 +488,27 @@ int Inference::Load(void) return ConvertEngineErrorToVisionError(ret); } + tensor_t inputData; + std::vector 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().swap(models); + return MEDIA_VISION_ERROR_INTERNAL; + } + //get type and allocate memory to mInputBuffer; InputAttrType attrType = static_cast(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 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().swap(models); - return MEDIA_VISION_ERROR_INTERNAL; - } - mInputBuffer = cv::Mat(mInputSize.height, mInputSize.width, mMatType, dataPtr); mCanRun = true; -- 2.7.4