Commit b556c2a7 authored by Alexander Alekhin's avatar Alexander Alekhin

build: migrate to traits::Type / traits::Depth

parent 62e77e99
...@@ -131,7 +131,7 @@ public: ...@@ -131,7 +131,7 @@ public:
flag(flag_), flag(flag_),
spaceWeights(spaceWeights_), spaceWeights(spaceWeights_),
expLut(expLut_) { expLut(expLut_) {
CV_DbgAssert(joint.type() == JointVec::type && confidence.type() == CV_32F && src.type() == dst.type() && src.type() == SrcVec::type); CV_DbgAssert(joint.type() == traits::Type<JointVec>::value && confidence.type() == CV_32F && src.type() == dst.type() && src.type() == traits::Type<SrcVec>::value);
CV_DbgAssert(joint.rows == src.rows && confidence.rows == src.rows && src.rows == dst.rows + 2 * radius); CV_DbgAssert(joint.rows == src.rows && confidence.rows == src.rows && src.rows == dst.rows + 2 * radius);
CV_DbgAssert(joint.cols == src.cols && confidence.cols == src.cols && src.cols == dst.cols + 2 * radius); CV_DbgAssert(joint.cols == src.cols && confidence.cols == src.cols && src.cols == dst.cols + 2 * radius);
} }
......
...@@ -69,7 +69,7 @@ DTFilterCPU* DTFilterCPU::create_p_(const Mat& guide, double sigmaSpatial, doubl ...@@ -69,7 +69,7 @@ DTFilterCPU* DTFilterCPU::create_p_(const Mat& guide, double sigmaSpatial, doubl
template<typename GuideVec> template<typename GuideVec>
void DTFilterCPU::init_(Mat& guide, double sigmaSpatial_, double sigmaColor_, int mode_, int numIters_) void DTFilterCPU::init_(Mat& guide, double sigmaSpatial_, double sigmaColor_, int mode_, int numIters_)
{ {
CV_Assert(guide.type() == cv::DataType<GuideVec>::type); CV_Assert(guide.type() == traits::Type<GuideVec>::value);
this->release(); this->release();
...@@ -123,7 +123,7 @@ template <typename SrcVec> ...@@ -123,7 +123,7 @@ template <typename SrcVec>
void DTFilterCPU::filter_(const Mat& src, Mat& dst, int dDepth) void DTFilterCPU::filter_(const Mat& src, Mat& dst, int dDepth)
{ {
typedef typename DataType<Vec<WorkType, SrcVec::channels> >::vec_type WorkVec; typedef typename DataType<Vec<WorkType, SrcVec::channels> >::vec_type WorkVec;
CV_Assert( src.type() == SrcVec::type ); CV_Assert( src.type() == traits::Type<SrcVec>::value );
if ( src.cols != w || src.rows != h ) if ( src.cols != w || src.rows != h )
{ {
CV_Error(Error::StsBadSize, "Size of filtering image must be equal to size of guide image"); CV_Error(Error::StsBadSize, "Size of filtering image must be equal to size of guide image");
...@@ -139,17 +139,17 @@ void DTFilterCPU::filter_(const Mat& src, Mat& dst, int dDepth) ...@@ -139,17 +139,17 @@ void DTFilterCPU::filter_(const Mat& src, Mat& dst, int dDepth)
if (dDepth == -1) dDepth = src.depth(); if (dDepth == -1) dDepth = src.depth();
//small optimization to avoid extra copying of data //small optimization to avoid extra copying of data
bool useDstAsRes = (dDepth == WorkVec::depth && (mode == DTF_NC || mode == DTF_RF)); bool useDstAsRes = (dDepth == traits::Depth<WorkVec>::value && (mode == DTF_NC || mode == DTF_RF));
if (useDstAsRes) if (useDstAsRes)
{ {
dst.create(h, w, WorkVec::type); dst.create(h, w, traits::Type<WorkVec>::value);
res = dst; res = dst;
} }
if (mode == DTF_NC) if (mode == DTF_NC)
{ {
Mat resT(src.cols, src.rows, WorkVec::type); Mat resT(src.cols, src.rows, traits::Type<WorkVec>::value);
src.convertTo(res, WorkVec::type); src.convertTo(res, traits::Type<WorkVec>::value);
FilterNC_horPass<WorkVec> horParBody(res, idistHor, resT); FilterNC_horPass<WorkVec> horParBody(res, idistHor, resT);
FilterNC_horPass<WorkVec> vertParBody(resT, idistVert, res); FilterNC_horPass<WorkVec> vertParBody(resT, idistVert, res);
...@@ -180,7 +180,7 @@ void DTFilterCPU::filter_(const Mat& src, Mat& dst, int dDepth) ...@@ -180,7 +180,7 @@ void DTFilterCPU::filter_(const Mat& src, Mat& dst, int dDepth)
} }
else if (mode == DTF_RF) else if (mode == DTF_RF)
{ {
src.convertTo(res, WorkVec::type); src.convertTo(res, traits::Type<WorkVec>::value);
for (int iter = 1; iter <= numIters; iter++) for (int iter = 1; iter <= numIters; iter++)
{ {
...@@ -237,13 +237,13 @@ void DTFilterCPU::integrateSparseRow(const SrcVec *src, const float *dist, SrcWo ...@@ -237,13 +237,13 @@ void DTFilterCPU::integrateSparseRow(const SrcVec *src, const float *dist, SrcWo
template<typename WorkVec> template<typename WorkVec>
void DTFilterCPU::prepareSrcImg_IC(const Mat& src, Mat& dst, Mat& dstT) void DTFilterCPU::prepareSrcImg_IC(const Mat& src, Mat& dst, Mat& dstT)
{ {
Mat dstOut(src.rows, src.cols + 2, WorkVec::type); Mat dstOut(src.rows, src.cols + 2, traits::Type<WorkVec>::value);
Mat dstOutT(src.cols, src.rows + 2, WorkVec::type); Mat dstOutT(src.cols, src.rows + 2, traits::Type<WorkVec>::value);
dst = dstOut(Range::all(), Range(1, src.cols+1)); dst = dstOut(Range::all(), Range(1, src.cols+1));
dstT = dstOutT(Range::all(), Range(1, src.rows+1)); dstT = dstOutT(Range::all(), Range(1, src.rows+1));
src.convertTo(dst, WorkVec::type); src.convertTo(dst, traits::Type<WorkVec>::value);
WorkVec *line; WorkVec *line;
int ri = dstOut.cols - 1; int ri = dstOut.cols - 1;
...@@ -270,7 +270,7 @@ template <typename WorkVec> ...@@ -270,7 +270,7 @@ template <typename WorkVec>
DTFilterCPU::FilterNC_horPass<WorkVec>::FilterNC_horPass(Mat& src_, Mat& idist_, Mat& dst_) DTFilterCPU::FilterNC_horPass<WorkVec>::FilterNC_horPass(Mat& src_, Mat& idist_, Mat& dst_)
: src(src_), idist(idist_), dst(dst_), radius(1.0f) : src(src_), idist(idist_), dst(dst_), radius(1.0f)
{ {
CV_DbgAssert(src.type() == WorkVec::type && dst.type() == WorkVec::type && dst.rows == src.cols && dst.cols == src.rows); CV_DbgAssert(src.type() == traits::Type<WorkVec>::value && dst.type() == traits::Type<WorkVec>::value && dst.rows == src.cols && dst.cols == src.rows);
} }
template <typename WorkVec> template <typename WorkVec>
...@@ -324,12 +324,12 @@ template <typename WorkVec> ...@@ -324,12 +324,12 @@ template <typename WorkVec>
DTFilterCPU::FilterIC_horPass<WorkVec>::FilterIC_horPass(Mat& src_, Mat& idist_, Mat& dist_, Mat& dst_) DTFilterCPU::FilterIC_horPass<WorkVec>::FilterIC_horPass(Mat& src_, Mat& idist_, Mat& dist_, Mat& dst_)
: src(src_), idist(idist_), dist(dist_), dst(dst_), radius(1.0f) : src(src_), idist(idist_), dist(dist_), dst(dst_), radius(1.0f)
{ {
CV_DbgAssert(src.type() == WorkVec::type && dst.type() == WorkVec::type && dst.rows == src.cols && dst.cols == src.rows); CV_DbgAssert(src.type() == traits::Type<WorkVec>::value && dst.type() == traits::Type<WorkVec>::value && dst.rows == src.cols && dst.cols == src.rows);
#ifdef CV_GET_NUM_THREAD_WORKS_PROPERLY #ifdef CV_GET_NUM_THREAD_WORKS_PROPERLY
isrcBuf.create(cv::getNumThreads(), src.cols + 1, WorkVec::type); isrcBuf.create(cv::getNumThreads(), src.cols + 1, traits::Type<WorkVec>::value);
#else #else
isrcBuf.create(src.rows, src.cols + 1, WorkVec::type); isrcBuf.create(src.rows, src.cols + 1, traits::Type<WorkVec>::value);
#endif #endif
} }
...@@ -384,8 +384,8 @@ template <typename WorkVec> ...@@ -384,8 +384,8 @@ template <typename WorkVec>
DTFilterCPU::FilterRF_horPass<WorkVec>::FilterRF_horPass(Mat& res_, Mat& alphaD_, int iteration_) DTFilterCPU::FilterRF_horPass<WorkVec>::FilterRF_horPass(Mat& res_, Mat& alphaD_, int iteration_)
: res(res_), alphaD(alphaD_), iteration(iteration_) : res(res_), alphaD(alphaD_), iteration(iteration_)
{ {
CV_DbgAssert(res.type() == WorkVec::type); CV_DbgAssert(res.type() == traits::Type<WorkVec>::value);
CV_DbgAssert(res.type() == WorkVec::type && res.size() == res.size()); CV_DbgAssert(res.type() == traits::Type<WorkVec>::value && res.size() == res.size());
} }
...@@ -421,8 +421,8 @@ template <typename WorkVec> ...@@ -421,8 +421,8 @@ template <typename WorkVec>
DTFilterCPU::FilterRF_vertPass<WorkVec>::FilterRF_vertPass(Mat& res_, Mat& alphaD_, int iteration_) DTFilterCPU::FilterRF_vertPass<WorkVec>::FilterRF_vertPass(Mat& res_, Mat& alphaD_, int iteration_)
: res(res_), alphaD(alphaD_), iteration(iteration_) : res(res_), alphaD(alphaD_), iteration(iteration_)
{ {
CV_DbgAssert(res.type() == WorkVec::type); CV_DbgAssert(res.type() == traits::Type<WorkVec>::value);
CV_DbgAssert(res.type() == WorkVec::type && res.size() == res.size()); CV_DbgAssert(res.type() == traits::Type<WorkVec>::value && res.size() == res.size());
} }
...@@ -470,7 +470,7 @@ template <typename GuideVec> ...@@ -470,7 +470,7 @@ template <typename GuideVec>
DTFilterCPU::ComputeIDTHor_ParBody<GuideVec>::ComputeIDTHor_ParBody(DTFilterCPU& dtf_, Mat& guide_, Mat& dst_) DTFilterCPU::ComputeIDTHor_ParBody<GuideVec>::ComputeIDTHor_ParBody(DTFilterCPU& dtf_, Mat& guide_, Mat& dst_)
: dtf(dtf_), guide(guide_), dst(dst_) : dtf(dtf_), guide(guide_), dst(dst_)
{ {
dst.create(guide.rows, guide.cols + 1, IDistVec::type); dst.create(guide.rows, guide.cols + 1, traits::Type<IDistVec>::value);
} }
template <typename GuideVec> template <typename GuideVec>
...@@ -497,8 +497,8 @@ template <typename GuideVec> ...@@ -497,8 +497,8 @@ template <typename GuideVec>
DTFilterCPU::ComputeDTandIDTHor_ParBody<GuideVec>::ComputeDTandIDTHor_ParBody(DTFilterCPU& dtf_, Mat& guide_, Mat& dist_, Mat& idist_) DTFilterCPU::ComputeDTandIDTHor_ParBody<GuideVec>::ComputeDTandIDTHor_ParBody(DTFilterCPU& dtf_, Mat& guide_, Mat& dist_, Mat& idist_)
: dtf(dtf_), guide(guide_), dist(dist_), idist(idist_) : dtf(dtf_), guide(guide_), dist(dist_), idist(idist_)
{ {
dist = getWExtendedMat(guide.rows, guide.cols, IDistVec::type, 1, 1); dist = getWExtendedMat(guide.rows, guide.cols, traits::Type<IDistVec>::value, 1, 1);
idist = getWExtendedMat(guide.rows, guide.cols + 1, IDistVec::type); idist = getWExtendedMat(guide.rows, guide.cols + 1, traits::Type<IDistVec>::value);
maxRadius = dtf.getIterRadius(1); maxRadius = dtf.getIterRadius(1);
} }
...@@ -535,7 +535,7 @@ template <typename GuideVec> ...@@ -535,7 +535,7 @@ template <typename GuideVec>
DTFilterCPU::ComputeA0DTHor_ParBody<GuideVec>::ComputeA0DTHor_ParBody(DTFilterCPU& dtf_, Mat& guide_) DTFilterCPU::ComputeA0DTHor_ParBody<GuideVec>::ComputeA0DTHor_ParBody(DTFilterCPU& dtf_, Mat& guide_)
: dtf(dtf_), guide(guide_) : dtf(dtf_), guide(guide_)
{ {
dtf.a0distHor.create(guide.rows, guide.cols - 1, DistVec::type); dtf.a0distHor.create(guide.rows, guide.cols - 1, traits::Type<DistVec>::value);
lna = std::log(dtf.getIterAlpha(1)); lna = std::log(dtf.getIterAlpha(1));
} }
...@@ -565,7 +565,7 @@ template <typename GuideVec> ...@@ -565,7 +565,7 @@ template <typename GuideVec>
DTFilterCPU::ComputeA0DTVert_ParBody<GuideVec>::ComputeA0DTVert_ParBody(DTFilterCPU& dtf_, Mat& guide_) DTFilterCPU::ComputeA0DTVert_ParBody<GuideVec>::ComputeA0DTVert_ParBody(DTFilterCPU& dtf_, Mat& guide_)
: dtf(dtf_), guide(guide_) : dtf(dtf_), guide(guide_)
{ {
dtf.a0distVert.create(guide.rows - 1, guide.cols, DistVec::type); dtf.a0distVert.create(guide.rows - 1, guide.cols, traits::Type<DistVec>::value);
lna = std::log(dtf.getIterAlpha(1)); lna = std::log(dtf.getIterAlpha(1));
} }
......
...@@ -148,16 +148,16 @@ void FastGlobalSmootherFilterImpl::init(InputArray guide,double _lambda,double _ ...@@ -148,16 +148,16 @@ void FastGlobalSmootherFilterImpl::init(InputArray guide,double _lambda,double _
num_iter = _num_iter; num_iter = _num_iter;
num_stripes = getNumThreads(); num_stripes = getNumThreads();
int num_levels = 3*256*256; int num_levels = 3*256*256;
weights_LUT.create(1,num_levels,WorkVec::type); weights_LUT.create(1,num_levels,traits::Type<WorkVec>::value);
WorkType* LUT = (WorkType*)weights_LUT.ptr(0); WorkType* LUT = (WorkType*)weights_LUT.ptr(0);
parallel_for_(Range(0,num_stripes),ComputeLUT_ParBody(*this,LUT,num_stripes,num_levels)); parallel_for_(Range(0,num_stripes),ComputeLUT_ParBody(*this,LUT,num_stripes,num_levels));
w = guide.cols(); w = guide.cols();
h = guide.rows(); h = guide.rows();
Chor. create(h,w,WorkVec::type); Chor. create(h,w,traits::Type<WorkVec>::value);
Cvert. create(h,w,WorkVec::type); Cvert. create(h,w,traits::Type<WorkVec>::value);
interD.create(h,w,WorkVec::type); interD.create(h,w,traits::Type<WorkVec>::value);
Mat guideMat = guide.getMat(); Mat guideMat = guide.getMat();
if(guide.channels() == 1) if(guide.channels() == 1)
...@@ -201,8 +201,8 @@ void FastGlobalSmootherFilterImpl::filter(InputArray src, OutputArray dst) ...@@ -201,8 +201,8 @@ void FastGlobalSmootherFilterImpl::filter(InputArray src, OutputArray dst)
{ {
lambda = lambda_ref; lambda = lambda_ref;
Mat cur_res = src_channels[i].clone(); Mat cur_res = src_channels[i].clone();
if(src.depth()!=WorkVec::type) if(src.depth()!=traits::Type<WorkVec>::value)
cur_res.convertTo(cur_res,WorkVec::type); cur_res.convertTo(cur_res,traits::Type<WorkVec>::value);
for(int n=0;n<num_iter;n++) for(int n=0;n<num_iter;n++)
{ {
...@@ -212,7 +212,7 @@ void FastGlobalSmootherFilterImpl::filter(InputArray src, OutputArray dst) ...@@ -212,7 +212,7 @@ void FastGlobalSmootherFilterImpl::filter(InputArray src, OutputArray dst)
} }
Mat dstMat; Mat dstMat;
if(src.depth()!=WorkVec::type) if(src.depth()!=traits::Type<WorkVec>::value)
cur_res.convertTo(dstMat,src.depth()); cur_res.convertTo(dstMat,src.depth());
else else
dstMat = cur_res; dstMat = cur_res;
......
...@@ -77,7 +77,7 @@ public: ...@@ -77,7 +77,7 @@ public:
joint(joint_), src(src_), dst(dst_), radius(radius_), maxk(maxk_), joint(joint_), src(src_), dst(dst_), radius(radius_), maxk(maxk_),
scaleIndex(scaleIndex_), spaceOfs(spaceOfs_), spaceWeights(spaceWeights_), expLUT(expLUT_) scaleIndex(scaleIndex_), spaceOfs(spaceOfs_), spaceWeights(spaceWeights_), expLUT(expLUT_)
{ {
CV_DbgAssert(joint.type() == JointVec::type && src.type() == dst.type() && src.type() == SrcVec::type); CV_DbgAssert(joint.type() == traits::Type<JointVec>::value && src.type() == dst.type() && src.type() == traits::Type<SrcVec>::value);
CV_DbgAssert(joint.rows == src.rows && src.rows == dst.rows + 2*radius); CV_DbgAssert(joint.rows == src.rows && src.rows == dst.rows + 2*radius);
CV_DbgAssert(joint.cols == src.cols && src.cols == dst.cols + 2*radius); CV_DbgAssert(joint.cols == src.cols && src.cols == dst.cols + 2*radius);
} }
...@@ -223,7 +223,7 @@ public: ...@@ -223,7 +223,7 @@ public:
joint(joint_), src(src_), dst(dst_), radius(radius_), maxk(maxk_), joint(joint_), src(src_), dst(dst_), radius(radius_), maxk(maxk_),
spaceOfs(spaceOfs_), spaceWeights(spaceWeights_), expLUT(expLUT_) spaceOfs(spaceOfs_), spaceWeights(spaceWeights_), expLUT(expLUT_)
{ {
CV_DbgAssert(joint.type() == JointVec::type && src.type() == dst.type() && src.type() == SrcVec::type); CV_DbgAssert(joint.type() == traits::Type<JointVec>::value && src.type() == dst.type() && src.type() == traits::Type<SrcVec>::value);
CV_DbgAssert(joint.rows == src.rows && src.rows == dst.rows + 2 * radius); CV_DbgAssert(joint.rows == src.rows && src.rows == dst.rows + 2 * radius);
CV_DbgAssert(joint.cols == src.cols && src.cols == dst.cols + 2 * radius); CV_DbgAssert(joint.cols == src.cols && src.cols == dst.cols + 2 * radius);
} }
......
...@@ -168,7 +168,7 @@ Mat getChessMat1px(Size sz, double whiteIntensity = 255) ...@@ -168,7 +168,7 @@ Mat getChessMat1px(Size sz, double whiteIntensity = 255)
{ {
typedef typename DataType<SrcVec>::channel_type SrcType; typedef typename DataType<SrcVec>::channel_type SrcType;
Mat dst(sz, DataType<SrcVec>::type); Mat dst(sz, traits::Type<SrcVec>::value);
SrcVec black = SrcVec::all(0); SrcVec black = SrcVec::all(0);
SrcVec white = SrcVec::all((SrcType)whiteIntensity); SrcVec white = SrcVec::all((SrcType)whiteIntensity);
......
...@@ -113,7 +113,7 @@ template<typename JointVec, typename SrcVec> ...@@ -113,7 +113,7 @@ template<typename JointVec, typename SrcVec>
void jointBilateralFilterNaive_(InputArray joint_, InputArray src_, OutputArray dst_, int d, double sigmaColor, double sigmaSpace, int borderType) void jointBilateralFilterNaive_(InputArray joint_, InputArray src_, OutputArray dst_, int d, double sigmaColor, double sigmaSpace, int borderType)
{ {
CV_Assert(joint_.size() == src_.size()); CV_Assert(joint_.size() == src_.size());
CV_Assert(joint_.type() == JointVec::type && src_.type() == SrcVec::type); CV_Assert(joint_.type() == traits::Type<JointVec>::value && src_.type() == traits::Type<SrcVec>::value);
typedef Vec<float, SrcVec::channels> SrcVecf; typedef Vec<float, SrcVec::channels> SrcVecf;
if (sigmaColor <= 0) if (sigmaColor <= 0)
......
...@@ -22,9 +22,9 @@ TEST(ximpgroc_StructuredEdgeDetection, regression) ...@@ -22,9 +22,9 @@ TEST(ximpgroc_StructuredEdgeDetection, regression)
cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 ); cv::String previousResultName = dir + cv::format( "results/%02d.png", i + 1 );
cv::Mat previousResult = cv::imread( previousResultName, 0 ); cv::Mat previousResult = cv::imread( previousResultName, 0 );
previousResult.convertTo( previousResult, cv::DataType<float>::type, 1/255.0 ); previousResult.convertTo( previousResult, CV_32F, 1/255.0 );
src.convertTo( src, cv::DataType<float>::type, 1/255.0 ); src.convertTo( src, CV_32F, 1/255.0 );
cv::Mat currentResult( src.size(), src.type() ); cv::Mat currentResult( src.size(), src.type() );
pDollar->detectEdges( src, currentResult ); pDollar->detectEdges( src, currentResult );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment