Commit 30669702 authored by Maksim Shabunin's avatar Maksim Shabunin

Merge pull request #1352 from alalek:type_traits_issue_7599

parents 5472ac07 e242e87e
...@@ -194,7 +194,7 @@ private: ...@@ -194,7 +194,7 @@ private:
String name_; String name_;
Mat_<int> nfeatures_; Mat_<int> nfeatures_;
Mat_<unsigned int> colors_; Mat_<int> colors_;
Mat_<float> weights_; Mat_<float> weights_;
Mat buf_; Mat buf_;
...@@ -223,7 +223,7 @@ void BackgroundSubtractorGMGImpl::initialize(Size frameSize, double minVal, doub ...@@ -223,7 +223,7 @@ void BackgroundSubtractorGMGImpl::initialize(Size frameSize, double minVal, doub
nfeatures_.setTo(Scalar::all(0)); nfeatures_.setTo(Scalar::all(0));
} }
static float findFeature(unsigned int color, const unsigned int* colors, const float* weights, int nfeatures) static float findFeature(int color, const int* colors, const float* weights, int nfeatures)
{ {
for (int i = 0; i < nfeatures; ++i) for (int i = 0; i < nfeatures; ++i)
{ {
...@@ -248,7 +248,7 @@ static void normalizeHistogram(float* weights, int nfeatures) ...@@ -248,7 +248,7 @@ static void normalizeHistogram(float* weights, int nfeatures)
} }
} }
static bool insertFeature(unsigned int color, float weight, unsigned int* colors, float* weights, int& nfeatures, int maxFeatures) static bool insertFeature(int color, float weight, int* colors, float* weights, int& nfeatures, int maxFeatures)
{ {
int idx = -1; int idx = -1;
for (int i = 0; i < nfeatures; ++i) for (int i = 0; i < nfeatures; ++i)
...@@ -266,7 +266,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors ...@@ -266,7 +266,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
{ {
// move feature to beginning of list // move feature to beginning of list
::memmove(colors + 1, colors, idx * sizeof(unsigned int)); ::memmove(colors + 1, colors, idx * sizeof(int));
::memmove(weights + 1, weights, idx * sizeof(float)); ::memmove(weights + 1, weights, idx * sizeof(float));
colors[0] = color; colors[0] = color;
...@@ -276,7 +276,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors ...@@ -276,7 +276,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
{ {
// discard oldest feature // discard oldest feature
::memmove(colors + 1, colors, (nfeatures - 1) * sizeof(unsigned int)); ::memmove(colors + 1, colors, (nfeatures - 1) * sizeof(int));
::memmove(weights + 1, weights, (nfeatures - 1) * sizeof(float)); ::memmove(weights + 1, weights, (nfeatures - 1) * sizeof(float));
colors[0] = color; colors[0] = color;
...@@ -297,7 +297,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors ...@@ -297,7 +297,7 @@ static bool insertFeature(unsigned int color, float weight, unsigned int* colors
template <typename T> struct Quantization template <typename T> struct Quantization
{ {
static unsigned int apply(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels) static int apply(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels)
{ {
const T* src = static_cast<const T*>(src_); const T* src = static_cast<const T*>(src_);
src += x * cn; src += x * cn;
...@@ -313,7 +313,7 @@ template <typename T> struct Quantization ...@@ -313,7 +313,7 @@ template <typename T> struct Quantization
class GMG_LoopBody : public ParallelLoopBody class GMG_LoopBody : public ParallelLoopBody
{ {
public: public:
GMG_LoopBody(const Mat& frame, const Mat& fgmask, const Mat_<int>& nfeatures, const Mat_<unsigned int>& colors, const Mat_<float>& weights, GMG_LoopBody(const Mat& frame, const Mat& fgmask, const Mat_<int>& nfeatures, const Mat_<int>& colors, const Mat_<float>& weights,
int maxFeatures, double learningRate, int numInitializationFrames, int quantizationLevels, double backgroundPrior, double decisionThreshold, int maxFeatures, double learningRate, int numInitializationFrames, int quantizationLevels, double backgroundPrior, double decisionThreshold,
double maxVal, double minVal, int frameNum, bool updateBackgroundModel) : double maxVal, double minVal, int frameNum, bool updateBackgroundModel) :
frame_(frame), fgmask_(fgmask), nfeatures_(nfeatures), colors_(colors), weights_(weights), frame_(frame), fgmask_(fgmask), nfeatures_(nfeatures), colors_(colors), weights_(weights),
...@@ -331,7 +331,7 @@ private: ...@@ -331,7 +331,7 @@ private:
mutable Mat_<uchar> fgmask_; mutable Mat_<uchar> fgmask_;
mutable Mat_<int> nfeatures_; mutable Mat_<int> nfeatures_;
mutable Mat_<unsigned int> colors_; mutable Mat_<int> colors_;
mutable Mat_<float> weights_; mutable Mat_<float> weights_;
int maxFeatures_; int maxFeatures_;
...@@ -349,7 +349,7 @@ private: ...@@ -349,7 +349,7 @@ private:
void GMG_LoopBody::operator() (const Range& range) const void GMG_LoopBody::operator() (const Range& range) const
{ {
typedef unsigned int (*func_t)(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels); typedef int (*func_t)(const void* src_, int x, int cn, double minVal, double maxVal, int quantizationLevels);
static const func_t funcs[] = static const func_t funcs[] =
{ {
Quantization<uchar>::apply, Quantization<uchar>::apply,
...@@ -375,10 +375,10 @@ void GMG_LoopBody::operator() (const Range& range) const ...@@ -375,10 +375,10 @@ void GMG_LoopBody::operator() (const Range& range) const
for (int x = 0; x < frame_.cols; ++x, ++featureIdx) for (int x = 0; x < frame_.cols; ++x, ++featureIdx)
{ {
int nfeatures = nfeatures_row[x]; int nfeatures = nfeatures_row[x];
unsigned int* colors = colors_[featureIdx]; int* colors = colors_[featureIdx];
float* weights = weights_[featureIdx]; float* weights = weights_[featureIdx];
unsigned int newFeatureColor = func(frame_row, x, cn, minVal_, maxVal_, quantizationLevels_); int newFeatureColor = func(frame_row, x, cn, minVal_, maxVal_, quantizationLevels_);
bool isForeground = false; bool isForeground = false;
......
...@@ -71,7 +71,7 @@ public: ...@@ -71,7 +71,7 @@ public:
bool isInitialized(); bool isInitialized();
void getPatternPoints(OutputArray original_points); void getPatternPoints(std::vector<KeyPoint>& original_points);
/**< /**<
Returns a vector<Point> of the original points. Returns a vector<Point> of the original points.
*/ */
......
...@@ -405,9 +405,9 @@ bool CustomPattern::findPattern(InputArray image, OutputArray matched_features, ...@@ -405,9 +405,9 @@ bool CustomPattern::findPattern(InputArray image, OutputArray matched_features,
return (!m_ftrs.empty()); return (!m_ftrs.empty());
} }
void CustomPattern::getPatternPoints(OutputArray original_points) void CustomPattern::getPatternPoints(std::vector<KeyPoint>& original_points)
{ {
return Mat(keypoints).copyTo(original_points); original_points = keypoints;
} }
double CustomPattern::getPixelSize() double CustomPattern::getPixelSize()
......
...@@ -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);
} }
......
...@@ -80,7 +80,7 @@ struct CV_EXPORTS_W_SIMPLE Template ...@@ -80,7 +80,7 @@ struct CV_EXPORTS_W_SIMPLE Template
CV_PROP int width; CV_PROP int width;
CV_PROP int height; CV_PROP int height;
CV_PROP int pyramid_level; CV_PROP int pyramid_level;
CV_PROP std::vector<Feature> features; std::vector<Feature> features; // FIXIT: CV_PROP
void read(const FileNode& fn); void read(const FileNode& fn);
void write(FileStorage& fs) const; void write(FileStorage& fs) const;
......
...@@ -47,19 +47,22 @@ namespace cv ...@@ -47,19 +47,22 @@ namespace cv
namespace saliency namespace saliency
{ {
typedef int64_t TIG_TYPE;
typedef double MAT_TIG_TYPE; // cv::Mat has no native support for int64/uint64
struct TIGbits struct TIGbits
{ {
TIGbits() : bc0(0), bc1(0) {} TIGbits() : bc0(0), bc1(0) {}
inline void accumulate(int64_t tig, int64_t tigMask0, int64_t tigMask1, uchar shift) inline void accumulate(TIG_TYPE tig, TIG_TYPE tigMask0, TIG_TYPE tigMask1, uchar shift)
{ {
bc0 += ((POPCNT64(tigMask0 & tig) << 1) - POPCNT64(tig)) << shift; bc0 += ((POPCNT64(tigMask0 & tig) << 1) - POPCNT64(tig)) << shift;
bc1 += ((POPCNT64(tigMask1 & tig) << 1) - POPCNT64(tig)) << shift; bc1 += ((POPCNT64(tigMask1 & tig) << 1) - POPCNT64(tig)) << shift;
} }
int64_t bc0; TIG_TYPE bc0;
int64_t bc1; TIG_TYPE bc1;
}; };
float ObjectnessBING::FilterTIG::dot( int64_t tig1, int64_t tig2, int64_t tig4, int64_t tig8 ) float ObjectnessBING::FilterTIG::dot( TIG_TYPE tig1, TIG_TYPE tig2, TIG_TYPE tig4, TIG_TYPE tig8 )
{ {
TIGbits x; TIGbits x;
x.accumulate(tig1, _bTIGs[0], _bTIGs[1], 0); x.accumulate(tig1, _bTIGs[0], _bTIGs[1], 0);
...@@ -111,22 +114,22 @@ Mat ObjectnessBING::FilterTIG::matchTemplate( const Mat &mag1u ) ...@@ -111,22 +114,22 @@ Mat ObjectnessBING::FilterTIG::matchTemplate( const Mat &mag1u )
{ {
const int H = mag1u.rows, W = mag1u.cols; const int H = mag1u.rows, W = mag1u.cols;
const Size sz( W + 1, H + 1 ); // Expand original size to avoid dealing with boundary conditions const Size sz( W + 1, H + 1 ); // Expand original size to avoid dealing with boundary conditions
Mat_<int64_t> Tig1 = Mat_<int64_t>::zeros( sz ), Tig2 = Mat_<int64_t>::zeros( sz ); Mat_<MAT_TIG_TYPE> Tig1 = Mat_<MAT_TIG_TYPE>::zeros( sz ), Tig2 = Mat_<MAT_TIG_TYPE>::zeros( sz );
Mat_<int64_t> Tig4 = Mat_<int64_t>::zeros( sz ), Tig8 = Mat_<int64_t>::zeros( sz ); Mat_<MAT_TIG_TYPE> Tig4 = Mat_<MAT_TIG_TYPE>::zeros( sz ), Tig8 = Mat_<MAT_TIG_TYPE>::zeros( sz );
Mat_<BYTE> Row1 = Mat_<BYTE>::zeros( sz ), Row2 = Mat_<BYTE>::zeros( sz ); Mat_<BYTE> Row1 = Mat_<BYTE>::zeros( sz ), Row2 = Mat_<BYTE>::zeros( sz );
Mat_<BYTE> Row4 = Mat_<BYTE>::zeros( sz ), Row8 = Mat_<BYTE>::zeros( sz ); Mat_<BYTE> Row4 = Mat_<BYTE>::zeros( sz ), Row8 = Mat_<BYTE>::zeros( sz );
Mat_<float> scores( sz ); Mat_<float> scores( sz );
for ( int y = 1; y <= H; y++ ) for ( int y = 1; y <= H; y++ )
{ {
const BYTE* G = mag1u.ptr<BYTE>( y - 1 ); const BYTE* G = mag1u.ptr<BYTE>( y - 1 );
int64_t* T1 = Tig1.ptr<int64_t>( y ); // Binary TIG of current row TIG_TYPE* T1 = Tig1.ptr<TIG_TYPE>( y ); // Binary TIG of current row
int64_t* T2 = Tig2.ptr<int64_t>( y ); TIG_TYPE* T2 = Tig2.ptr<TIG_TYPE>( y );
int64_t* T4 = Tig4.ptr<int64_t>( y ); TIG_TYPE* T4 = Tig4.ptr<TIG_TYPE>( y );
int64_t* T8 = Tig8.ptr<int64_t>( y ); TIG_TYPE* T8 = Tig8.ptr<TIG_TYPE>( y );
int64_t* Tu1 = Tig1.ptr<int64_t>( y - 1 ); // Binary TIG of upper row TIG_TYPE* Tu1 = Tig1.ptr<TIG_TYPE>( y - 1 ); // Binary TIG of upper row
int64_t* Tu2 = Tig2.ptr<int64_t>( y - 1 ); TIG_TYPE* Tu2 = Tig2.ptr<TIG_TYPE>( y - 1 );
int64_t* Tu4 = Tig4.ptr<int64_t>( y - 1 ); TIG_TYPE* Tu4 = Tig4.ptr<TIG_TYPE>( y - 1 );
int64_t* Tu8 = Tig8.ptr<int64_t>( y - 1 ); TIG_TYPE* Tu8 = Tig8.ptr<TIG_TYPE>( y - 1 );
BYTE* R1 = Row1.ptr<BYTE>( y ); BYTE* R1 = Row1.ptr<BYTE>( y );
BYTE* R2 = Row2.ptr<BYTE>( y ); BYTE* R2 = Row2.ptr<BYTE>( y );
BYTE* R4 = Row4.ptr<BYTE>( y ); BYTE* R4 = Row4.ptr<BYTE>( y );
......
...@@ -78,7 +78,7 @@ class CV_EXPORTS_W StructuredLightPattern : public virtual Algorithm ...@@ -78,7 +78,7 @@ class CV_EXPORTS_W StructuredLightPattern : public virtual Algorithm
@note All the images must be at the same resolution. @note All the images must be at the same resolution.
*/ */
CV_WRAP CV_WRAP
virtual bool decode( InputArrayOfArrays patternImages, OutputArray disparityMap, virtual bool decode( const std::vector< std::vector<Mat> >& patternImages, OutputArray disparityMap,
InputArrayOfArrays blackImages = noArray(), InputArrayOfArrays blackImages = noArray(),
InputArrayOfArrays whiteImages = noArray(), InputArrayOfArrays whiteImages = noArray(),
int flags = DECODE_3D_UNDERWORLD ) const = 0; int flags = DECODE_3D_UNDERWORLD ) const = 0;
......
...@@ -56,7 +56,7 @@ class CV_EXPORTS_W GrayCodePattern_Impl : public GrayCodePattern ...@@ -56,7 +56,7 @@ class CV_EXPORTS_W GrayCodePattern_Impl : public GrayCodePattern
bool generate( OutputArrayOfArrays patternImages ); bool generate( OutputArrayOfArrays patternImages );
// Decodes the gray code pattern, computing the disparity map // Decodes the gray code pattern, computing the disparity map
bool decode( InputArrayOfArrays patternImages, OutputArray disparityMap, InputArrayOfArrays blackImages = noArray(), bool decode( const std::vector< std::vector<Mat> >& patternImages, OutputArray disparityMap, InputArrayOfArrays blackImages = noArray(),
InputArrayOfArrays whiteImages = noArray(), int flags = DECODE_3D_UNDERWORLD ) const; InputArrayOfArrays whiteImages = noArray(), int flags = DECODE_3D_UNDERWORLD ) const;
// Returns the number of pattern images for the graycode pattern // Returns the number of pattern images for the graycode pattern
...@@ -209,10 +209,10 @@ bool GrayCodePattern_Impl::generate( OutputArrayOfArrays pattern ) ...@@ -209,10 +209,10 @@ bool GrayCodePattern_Impl::generate( OutputArrayOfArrays pattern )
return true; return true;
} }
bool GrayCodePattern_Impl::decode( InputArrayOfArrays patternImages, OutputArray disparityMap, bool GrayCodePattern_Impl::decode( const std::vector< std::vector<Mat> >& patternImages, OutputArray disparityMap,
InputArrayOfArrays blackImages, InputArrayOfArrays whitheImages, int flags ) const InputArrayOfArrays blackImages, InputArrayOfArrays whitheImages, int flags ) const
{ {
std::vector<std::vector<Mat> >& acquired_pattern = *( std::vector<std::vector<Mat> >* ) patternImages.getObj(); const std::vector<std::vector<Mat> >& acquired_pattern = patternImages;
if( flags == DECODE_3D_UNDERWORLD ) if( flags == DECODE_3D_UNDERWORLD )
{ {
......
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
// Generate sinusoidal patterns // Generate sinusoidal patterns
bool generate( OutputArrayOfArrays patternImages ); bool generate( OutputArrayOfArrays patternImages );
bool decode( InputArrayOfArrays patternImages, OutputArray disparityMap, bool decode( const std::vector< std::vector<Mat> >& patternImages, OutputArray disparityMap,
InputArrayOfArrays blackImages = noArray(), InputArrayOfArrays whiteImages = InputArrayOfArrays blackImages = noArray(), InputArrayOfArrays whiteImages =
noArray(), int flags = 0 ) const; noArray(), int flags = 0 ) const;
...@@ -258,7 +258,7 @@ bool SinusoidalPatternProfilometry_Impl::generate( OutputArrayOfArrays pattern ) ...@@ -258,7 +258,7 @@ bool SinusoidalPatternProfilometry_Impl::generate( OutputArrayOfArrays pattern )
return true; return true;
} }
bool SinusoidalPatternProfilometry_Impl::decode( InputArrayOfArrays patternImages, bool SinusoidalPatternProfilometry_Impl::decode(const std::vector< std::vector<Mat> >& patternImages,
OutputArray disparityMap, OutputArray disparityMap,
InputArrayOfArrays blackImages, InputArrayOfArrays blackImages,
InputArrayOfArrays whiteImages, int flags ) const InputArrayOfArrays whiteImages, int flags ) const
......
...@@ -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