From b9c2a1bb6968b2f6c8818230b1a9121791b2cbaf Mon Sep 17 00:00:00 2001 From: Tae-Young Chung Date: Fri, 12 Aug 2022 10:25:37 +0900 Subject: [PATCH] Use DfsInputData and DfsOutputData instead of DfsData [Version] 1.0.7-0 [Issue type] update Apply changes of https://review.tizen.org/gerrit/#/c/platform/core/multimedia/dfs-adaptation/+/279576/ Use DfsInputData and DfsOutputData instead of DfsData and Define new DFS_DATA_INPUT_FORMAT enumeration Change-Id: I8e8724ac08704fc420ff96f5c4b238881176110d --- packaging/dfs-opencv.spec | 2 +- src/dfs_opencv.cpp | 50 ++++++++++++++++++--------------------- src/dfs_opencv_private.h | 6 ++--- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/packaging/dfs-opencv.spec b/packaging/dfs-opencv.spec index db501b0..5a310ea 100644 --- a/packaging/dfs-opencv.spec +++ b/packaging/dfs-opencv.spec @@ -1,6 +1,6 @@ Name: dfs-opencv Summary: OpenCV based Depth-from-Stereo implementation -Version: 1.0.6 +Version: 1.0.7 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 diff --git a/src/dfs_opencv.cpp b/src/dfs_opencv.cpp index d72f0b2..d429bc9 100644 --- a/src/dfs_opencv.cpp +++ b/src/dfs_opencv.cpp @@ -316,30 +316,29 @@ namespace DfsAdaptationImpl return results; } - void DfsOCV::Run(DfsData& base, DfsData& extra) + void DfsOCV::Run(DfsInputData& data) { LOGI("ENTER"); - if (!base.data) { + if (!data.data) { throw std::runtime_error("invalid data pointer"); } - int baseCvType = 1; - int extraCvType = -1; + int dataCvType = 1; cv::Mat baseMat, extraMat; - if (!extra.data) { + if (data.inputFormat == DFS_DATA_INPUT_FORMAT_COUPLED_SBS) { LOGI("side-by-side"); - if (cv::Size(base.width >> 1, base.height) != mImageSize) { + if (cv::Size(data.width >> 1, data.height) != mImageSize) { throw std::runtime_error("invalid size"); } - baseCvType = ConvertDfsDataTypeToCV(base.type); - if (baseCvType < 0) { + dataCvType = ConvertDfsDataTypeToCV(data.type); + if (dataCvType < 0) { throw std::runtime_error("invalid data type"); } - cv::Mat mat(cv::Size(base.width, base.height), baseCvType, base.data); - LOGI("%zd x %zd", base.width, base.height); + cv::Mat mat(cv::Size(data.width, data.height), dataCvType, data.data); + LOGI("%zd x %zd", data.width, data.height); baseMat = mat(cv::Rect(0, 0, mImageSize.width, mImageSize.height)).clone(); @@ -347,24 +346,24 @@ namespace DfsAdaptationImpl mImageSize.width, mImageSize.height)).clone(); } else { - if (cv::Size(base.width, base.height) != mImageSize || - cv::Size(extra.width, extra.height) != mImageSize) { + if (cv::Size(data.width, data.height) != mImageSize || + cv::Size(data.width, data.height) != mImageSize) { + LOGE("%zd x %zd but image size is %d x %d", + data.width, data.height, mImageSize.width, mImageSize.height); throw std::runtime_error("invalid size"); } - baseCvType = ConvertDfsDataTypeToCV(base.type); - extraCvType = ConvertDfsDataTypeToCV(extra.type); - if (baseCvType < 0 || extraCvType < 0) { - LOGE("baseCvType: %d, extraCvType:%d", baseCvType, extraCvType); + dataCvType = ConvertDfsDataTypeToCV(data.type); + if (dataCvType < 0) { + LOGE("dataCvType: %d", dataCvType); throw std::runtime_error("invalid data type"); } - baseMat = cv::Mat(cv::Size(base.width, base.height), - baseCvType, - base.data);; - extraMat = cv::Mat(cv::Size(extra.width, - extra.height), - extraCvType, - extra.data); + baseMat = cv::Mat(cv::Size(data.width, data.height), + dataCvType, + data.data);; + extraMat = cv::Mat(cv::Size(data.width, data.height), + dataCvType, + data.extraData); } if (baseMat.size() != extraMat.size()) { @@ -472,13 +471,10 @@ namespace DfsAdaptationImpl mDepthData.height = mDepthMat.rows; mDepthData.stride = mDepthMat.elemSize() * mDepthMat.cols; - mDepthData.pointCloudData = nullptr; - mDepthData.pointCloudSize = 0; - LOGI("LEAVE"); } - DfsData& DfsOCV::GetDepthData() + DfsOutputData& DfsOCV::GetDepthData() { LOGI("ENTER"); diff --git a/src/dfs_opencv_private.h b/src/dfs_opencv_private.h index e6da346..b20ce4d 100644 --- a/src/dfs_opencv_private.h +++ b/src/dfs_opencv_private.h @@ -97,7 +97,7 @@ namespace DfsAdaptationImpl cv::Mat mDepthMat; cv::Mat mDisp2DepthMat; cv::Mat mDispOffsetMat; - DfsData mDepthData; + DfsOutputData mDepthData; StereoParam mStereoParam; bool mIsStereoCalibrated; @@ -134,9 +134,9 @@ namespace DfsAdaptationImpl void Initialize(DfsParameter& param, size_t width, size_t height, size_t minDisp, size_t maxDisp, std::string stereoConfigPath) override; - void Run(DfsData& base, DfsData& extra) override; + void Run(DfsInputData& data) override; - DfsData& GetDepthData() override; + DfsOutputData& GetDepthData() override; }; } -- 2.34.1