From: Tae-Young Chung Date: Tue, 2 Nov 2021 09:01:08 +0000 (+0900) Subject: Apply changed DFS_DATA_TYPE_* enumeration and a case which a given source is single... X-Git-Tag: submit/tizen/20220701.002357~1^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6dbd919bac7298e7df15013ab536660ab9c7d14a;p=platform%2Fcore%2Fmultimedia%2Fdfs-opencv.git Apply changed DFS_DATA_TYPE_* enumeration and a case which a given source is single typed of side-by-side format Signed-off-by: Tae-Young Chung --- diff --git a/src/dfs_opencv.cpp b/src/dfs_opencv.cpp index 47d5dc0..93496ca 100644 --- a/src/dfs_opencv.cpp +++ b/src/dfs_opencv.cpp @@ -233,7 +233,9 @@ namespace DfsAdaptationImpl { LOGI("LEAVE"); switch (type) { - case DFS_DATA_TYPE_UINT8: + case DFS_DATA_TYPE_UINT8C1: + return CV_8UC1; + case DFS_DATA_TYPE_UINT8C3: return CV_8UC3; default: LOGE("Invalide type"); @@ -309,23 +311,51 @@ namespace DfsAdaptationImpl { LOGI("ENTER"); - if (!base.data || !extra.data) { + if (!base.data) { throw std::runtime_error("invalid data pointer"); } - if (cv::Size(base.width, base.height) != mImageSize || - cv::Size(extra.width, extra.height) != mImageSize) { - throw std::runtime_error("invalid size"); - } + int baseCvType = 1; + int extraCvType = -1; + cv::Mat baseMat, extraMat; - int baseCvType = ConvertDfsDataTypeToCV(base.type); - int extraCvType = ConvertDfsDataTypeToCV(extra.type); - if (baseCvType < 0 || extraCvType < 0) { - throw std::runtime_error("invalid data type"); - } + if (!extra.data) { + LOGI("side-by-side"); + if (cv::Size(base.width >> 1, base.height) != mImageSize) { + throw std::runtime_error("invalid size"); + } - cv::Mat baseMat(cv::Size(base.width, base.height), baseCvType, base.data); - cv::Mat extraMat(cv::Size(extra.width, extra.height), extraCvType, extra.data); + baseCvType = ConvertDfsDataTypeToCV(base.type); + if (baseCvType < 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); + baseMat = mat(cv::Rect(0, 0, + mImageSize.width, + mImageSize.height)).clone(); + extraMat = mat(cv::Rect(mImageSize.width, 0, + mImageSize.width, + mImageSize.height)).clone(); + } else { + if (cv::Size(base.width, base.height) != mImageSize || + cv::Size(extra.width, extra.height) != mImageSize) { + throw std::runtime_error("invalid size"); + } + baseCvType = ConvertDfsDataTypeToCV(base.type); + extraCvType = ConvertDfsDataTypeToCV(extra.type); + if (baseCvType < 0 || extraCvType < 0) { + 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); + } if (baseMat.size() != extraMat.size()) { throw std::runtime_error("base and extra should be the same size"); @@ -415,7 +445,7 @@ namespace DfsAdaptationImpl } mDepthData.data = mDispMat.ptr(); - mDepthData.type = DFS_DATA_TYPE_UINT8; + mDepthData.type = DFS_DATA_TYPE_UINT8C1; mDepthData.width = mDispMat.cols; mDepthData.height = mDispMat.rows; mDepthData.stride = mDispMat.elemSize() * mDispMat.cols;