Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/cudaarithm/src/cuda/absdiff_mat.cu
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ namespace
void absDiffMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat&, double, Stream& stream, int)
{
typedef void (*func_t)(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream);
static const func_t funcs[] =
static const func_t funcs[CV_DEPTH_MAX] =
{
absDiffMat_v1<uchar>,
absDiffMat_v1<schar>,
Expand Down
2 changes: 1 addition & 1 deletion modules/cudaarithm/src/cuda/absdiff_scalar.cu
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ namespace
void absDiffScalar(const GpuMat& src, cv::Scalar val, bool, GpuMat& dst, const GpuMat&, double, Stream& stream, int)
{
typedef void (*func_t)(const GpuMat& src, cv::Scalar val, GpuMat& dst, Stream& stream);
static const func_t funcs[7][4] =
static const func_t funcs[CV_DEPTH_MAX][4] =
{
{
absDiffScalarImpl<uchar, float>, absDiffScalarImpl<uchar2, float>, absDiffScalarImpl<uchar3, float>, absDiffScalarImpl<uchar4, float>
Expand Down
2 changes: 1 addition & 1 deletion modules/cudaarithm/src/cuda/cmp_scalar.cu
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void cmpScalar(const GpuMat& src, cv::Scalar val, bool inv, GpuMat& dst, const G
const int depth = src.depth();
const int cn = src.channels();

CV_DbgAssert( depth <= CV_64F && cn <= 4 );
CV_Assert( depth <= CV_64F && cn <= 4 );

funcs[depth][cmpop][cn - 1](src, val, dst, stream);
}
Expand Down
4 changes: 1 addition & 3 deletions modules/cudaarithm/src/cuda/div_mat.cu
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace
void divMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat&, double scale, Stream& stream, int)
{
typedef void (*func_t)(const GpuMat& src1, const GpuMat& src2, const GpuMat& dst, double scale, Stream& stream);
static const func_t funcs[7][7] =
static const func_t funcs[CV_DEPTH_MAX][CV_DEPTH_MAX] =
{
{
divMatImpl<uchar, float, uchar>,
Expand Down Expand Up @@ -190,8 +190,6 @@ void divMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat&,
const int sdepth = src1.depth();
const int ddepth = dst.depth();

CV_DbgAssert( sdepth <= CV_64F && ddepth <= CV_64F );

GpuMat src1_ = src1.reshape(1);
GpuMat src2_ = src2.reshape(1);
GpuMat dst_ = dst.reshape(1);
Expand Down
8 changes: 6 additions & 2 deletions modules/cudaarithm/src/cuda/minmax.cu
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace
void cv::cuda::findMinMax(InputArray _src, OutputArray _dst, InputArray _mask, Stream& stream)
{
typedef void (*func_t)(const GpuMat& _src, const GpuMat& mask, GpuMat& _dst, Stream& stream);
static const func_t funcs[] =
static const func_t funcs[CV_DEPTH_MAX] =
{
minMaxImpl<uchar, int>,
minMaxImpl<schar, int>,
Expand All @@ -110,6 +110,8 @@ void cv::cuda::findMinMax(InputArray _src, OutputArray _dst, InputArray _mask, S
GpuMat dst = getOutputMat(_dst, 1, 2, dst_depth, stream);

const func_t func = funcs[src.depth()];
CV_Assert(func);

func(src, mask, dst, stream);

syncOutput(dst, _dst, stream);
Expand Down Expand Up @@ -158,7 +160,7 @@ namespace
void cv::cuda::device::findMaxAbs(InputArray _src, OutputArray _dst, InputArray _mask, Stream& stream)
{
typedef void (*func_t)(const GpuMat& _src, const GpuMat& mask, GpuMat& _dst, Stream& stream);
static const func_t funcs[] =
static const func_t funcs[CV_DEPTH_MAX] =
{
findMaxAbsImpl<uchar, int>,
findMaxAbsImpl<schar, int>,
Expand All @@ -181,6 +183,8 @@ void cv::cuda::device::findMaxAbs(InputArray _src, OutputArray _dst, InputArray
GpuMat dst = getOutputMat(_dst, 1, 1, dst_depth, stream);

const func_t func = funcs[src.depth()];
CV_Assert(func);

func(src, mask, dst, stream);

syncOutput(dst, _dst, stream);
Expand Down
17 changes: 8 additions & 9 deletions modules/cudaarithm/src/cuda/minmax_mat.cu
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ namespace
void minMaxMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat&, double, Stream& stream, int op)
{
typedef void (*func_t)(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream);
static const func_t funcs_v1[2][7] =
static const func_t funcs_v1[2][CV_DEPTH_MAX] =
{
{
minMaxMat_v1<minimum, uchar>,
Expand Down Expand Up @@ -161,8 +161,6 @@ void minMaxMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat

const int depth = src1.depth();

CV_DbgAssert( depth <= CV_64F );

GpuMat src1_ = src1.reshape(1);
GpuMat src2_ = src2.reshape(1);
GpuMat dst_ = dst.reshape(1);
Expand Down Expand Up @@ -191,6 +189,7 @@ void minMaxMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat
}

const func_t func = funcs_v1[op][depth];
CV_Assert(func);

func(src1_, src2_, dst_, stream);
}
Expand All @@ -209,8 +208,10 @@ namespace

void minMaxScalar(const GpuMat& src, cv::Scalar value, bool, GpuMat& dst, const GpuMat&, double, Stream& stream, int op)
{
CV_DbgAssert( src.channels() == 1 );

typedef void (*func_t)(const GpuMat& src, double value, GpuMat& dst, Stream& stream);
static const func_t funcs[2][7] =
static const func_t funcs[2][CV_DEPTH_MAX] =
{
{
minMaxScalar<minimum, uchar>,
Expand All @@ -232,12 +233,10 @@ void minMaxScalar(const GpuMat& src, cv::Scalar value, bool, GpuMat& dst, const
}
};

const int depth = src.depth();

CV_DbgAssert( depth <= CV_64F );
CV_DbgAssert( src.channels() == 1 );
auto f = funcs[op][src.depth()];
CV_Assert(f);

funcs[op][depth](src, value[0], dst, stream);
f(src, value[0], dst, stream);
}

#endif
3 changes: 2 additions & 1 deletion modules/cudaarithm/src/cuda/minmaxloc.cu
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace
void cv::cuda::findMinMaxLoc(InputArray _src, OutputArray _minMaxVals, OutputArray _loc, InputArray _mask, Stream& stream)
{
typedef void (*func_t)(const GpuMat& _src, const GpuMat& mask, GpuMat& _valBuf, GpuMat& _locBuf, Stream& stream);
static const func_t funcs[] =
static const func_t funcs[CV_DEPTH_MAX] =
{
minMaxLocImpl<uchar, int>,
minMaxLocImpl<schar, int>,
Expand All @@ -99,6 +99,7 @@ void cv::cuda::findMinMaxLoc(InputArray _src, OutputArray _minMaxVals, OutputArr
GpuMat locBuf(pool.getAllocator());

const func_t func = funcs[src_depth];
CV_Assert(func);
func(src, mask, valBuf, locBuf, stream);

GpuMat minMaxVals = valBuf.colRange(0, 1);
Expand Down
3 changes: 2 additions & 1 deletion modules/cudaarithm/src/cuda/norm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace
void cv::cuda::device::normL2(InputArray _src, OutputArray _dst, InputArray _mask, Stream& stream)
{
typedef void (*func_t)(const GpuMat& _src, const GpuMat& mask, GpuMat& _dst, Stream& stream);
static const func_t funcs[] =
static const func_t funcs[CV_DEPTH_MAX] =
{
normL2Impl<uchar, double>,
normL2Impl<schar, double>,
Expand All @@ -181,6 +181,7 @@ void cv::cuda::device::normL2(InputArray _src, OutputArray _dst, InputArray _mas
GpuMat dst = getOutputMat(_dst, 1, 1, CV_64FC1, stream);

const func_t func = funcs[src.depth()];
CV_Assert(func);
func(src, mask, dst, stream);

syncOutput(dst, _dst, stream);
Expand Down
6 changes: 4 additions & 2 deletions modules/cudaarithm/src/cuda/normalize.cu
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void cv::cuda::normalize(InputArray _src, OutputArray _dst, double a, double b,
typedef void (*func_minmax_t)(const GpuMat& _src, GpuMat& _dst, double a, double b, const GpuMat& mask, Stream& stream);
typedef void (*func_norm_t)(const GpuMat& _src, GpuMat& _dst, double a, int normType, const GpuMat& mask, Stream& stream);

static const func_minmax_t funcs_minmax[] =
static const func_minmax_t funcs_minmax[CV_DEPTH_MAX] =
{
normalizeMinMax<uchar, float, float>,
normalizeMinMax<schar, float, float>,
Expand All @@ -230,7 +230,7 @@ void cv::cuda::normalize(InputArray _src, OutputArray _dst, double a, double b,
normalizeMinMax<double, double, double>
};

static const func_norm_t funcs_norm[] =
static const func_norm_t funcs_norm[CV_DEPTH_MAX] =
{
normalizeNorm<uchar, float, float>,
normalizeNorm<schar, float, float>,
Expand Down Expand Up @@ -273,11 +273,13 @@ void cv::cuda::normalize(InputArray _src, OutputArray _dst, double a, double b,
if (normType == NORM_MINMAX)
{
const func_minmax_t func = funcs_minmax[src_depth];
CV_Assert(func);
func(src, dst, a, b, mask, stream);
}
else
{
const func_norm_t func = funcs_norm[src_depth];
CV_Assert(func);
func(src, dst, a, normType, mask, stream);
}

Expand Down
4 changes: 2 additions & 2 deletions modules/cudaarithm/src/cuda/reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void cv::cuda::reduce(InputArray _src, OutputArray _dst, int dim, int reduceOp,
if (dim == 0)
{
typedef void (*func_t)(const GpuMat& _src, GpuMat& _dst, int reduceOp, Stream& stream);
static const func_t funcs[7][7] =
static const func_t funcs[CV_DEPTH_MAX][CV_DEPTH_MAX] =
{
{
reduceToRowImpl<uchar, int, uchar>,
Expand Down Expand Up @@ -220,7 +220,7 @@ void cv::cuda::reduce(InputArray _src, OutputArray _dst, int dim, int reduceOp,
else
{
typedef void (*func_t)(const GpuMat& _src, GpuMat& _dst, int reduceOp, Stream& stream);
static const func_t funcs[7][7] =
static const func_t funcs[CV_DEPTH_MAX][CV_DEPTH_MAX] =
{
{
reduceToColumnImpl<uchar, int, uchar>,
Expand Down
2 changes: 1 addition & 1 deletion modules/cudaarithm/src/cuda/sub_mat.cu
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void subMat(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& m
const int sdepth = src1.depth();
const int ddepth = dst.depth();

CV_DbgAssert( sdepth <= CV_64F && ddepth <= CV_64F );
CV_Assert( sdepth <= CV_64F && ddepth <= CV_64F );

GpuMat src1_ = src1.reshape(1);
GpuMat src2_ = src2.reshape(1);
Expand Down
7 changes: 5 additions & 2 deletions modules/cudaarithm/src/cuda/threshold.cu
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ double cv::cuda::threshold(InputArray _src, OutputArray _dst, double thresh, dou
else
{
typedef void (*func_t)(const GpuMat& src, GpuMat& dst, double thresh, double maxVal, int type, Stream& stream);
static const func_t funcs[] =
static const func_t funcs[CV_DEPTH_MAX] =
{
thresholdImpl<uchar>,
thresholdImpl<schar>,
Expand All @@ -391,7 +391,10 @@ double cv::cuda::threshold(InputArray _src, OutputArray _dst, double thresh, dou
maxVal = cvRound(maxVal);
}

funcs[depth](src, dst, thresh, maxVal, type, stream);
auto f = funcs[depth];
CV_Assert(f);

f(src, dst, thresh, maxVal, type, stream);
}

syncOutput(dst, _dst, stream);
Expand Down
43 changes: 31 additions & 12 deletions modules/cudaarithm/test/test_element_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,13 +1570,16 @@ namespace
{
typedef void (*func_t)(const cv::Mat& src, cv::Mat& dst);

const func_t funcs[] =
const func_t funcs[CV_DEPTH_MAX] =
{
sqrtImpl<uchar>, sqrtImpl<schar>, sqrtImpl<ushort>, sqrtImpl<short>,
sqrtImpl<int>, sqrtImpl<float>
};

funcs[src.depth()](src, dst);
auto f = funcs[src.depth()];
CV_Assert(f);

f(src, dst);
}
}

Expand Down Expand Up @@ -1640,13 +1643,16 @@ namespace
{
typedef void (*func_t)(const cv::Mat& src, cv::Mat& dst);

const func_t funcs[] =
const func_t funcs[CV_DEPTH_MAX] =
{
logImpl<uchar>, logImpl<schar>, logImpl<ushort>, logImpl<short>,
logImpl<int>, logImpl<float>
};

funcs[src.depth()](src, dst);
auto f = funcs[src.depth()];
CV_Assert(f);

f(src, dst);
}
}

Expand Down Expand Up @@ -1720,13 +1726,16 @@ namespace
{
typedef void (*func_t)(const cv::Mat& src, cv::Mat& dst);

const func_t funcs[] =
const func_t funcs[CV_DEPTH_MAX] =
{
expImpl<uchar>, expImpl<schar>, expImpl<ushort>, expImpl<short>,
expImpl<int>, expImpl_float
};

funcs[src.depth()](src, dst);
auto f = funcs[src.depth()];
CV_Assert(f);

f(src, dst);
}
}

Expand Down Expand Up @@ -1921,8 +1930,10 @@ namespace

void compareScalarGold(const cv::Mat& src, cv::Scalar sc, cv::Mat& dst, int cmpop)
{
CV_Assert(cmpop < 6);

typedef void (*func_t)(const cv::Mat& src, cv::Scalar sc, cv::Mat& dst);
static const func_t funcs[7][6] =
static const func_t funcs[CV_DEPTH_MAX][6] =
{
{compareScalarImpl<std::equal_to, unsigned char> , compareScalarImpl<std::greater, unsigned char> , compareScalarImpl<std::greater_equal, unsigned char> , compareScalarImpl<std::less, unsigned char> , compareScalarImpl<std::less_equal, unsigned char> , compareScalarImpl<std::not_equal_to, unsigned char> },
{compareScalarImpl<std::equal_to, signed char> , compareScalarImpl<std::greater, signed char> , compareScalarImpl<std::greater_equal, signed char> , compareScalarImpl<std::less, signed char> , compareScalarImpl<std::less_equal, signed char> , compareScalarImpl<std::not_equal_to, signed char> },
Expand All @@ -1933,7 +1944,10 @@ namespace
{compareScalarImpl<std::equal_to, double> , compareScalarImpl<std::greater, double> , compareScalarImpl<std::greater_equal, double> , compareScalarImpl<std::less, double> , compareScalarImpl<std::less_equal, double> , compareScalarImpl<std::not_equal_to, double> }
};

funcs[src.depth()][cmpop](src, sc, dst);
auto f = funcs[src.depth()][cmpop];
CV_Assert(f);

f(src, sc, dst);
}
}

Expand Down Expand Up @@ -2164,12 +2178,14 @@ namespace
{
typedef void (*func_t)(const cv::Mat& src, cv::Scalar_<int> val, cv::Mat& dst);

const func_t funcs[] =
const func_t funcs[CV_DEPTH_MAX] =
{
rhiftImpl<uchar>, rhiftImpl<schar>, rhiftImpl<ushort>, rhiftImpl<short>, rhiftImpl<int>
};

funcs[src.depth()](src, val, dst);
auto f = funcs[src.depth()];
CV_Assert(f);
f(src, val, dst);
}
}

Expand Down Expand Up @@ -2244,12 +2260,15 @@ namespace
{
typedef void (*func_t)(const cv::Mat& src, cv::Scalar_<int> val, cv::Mat& dst);

const func_t funcs[] =
const func_t funcs[CV_DEPTH_MAX] =
{
lhiftImpl<uchar>, lhiftImpl<schar>, lhiftImpl<ushort>, lhiftImpl<short>, lhiftImpl<int>
};

funcs[src.depth()](src, val, dst);
auto f = funcs[src.depth()];
CV_Assert(f);

f(src, val, dst);
}
}

Expand Down
Loading
Loading