Skip to content

Commit

Permalink
Support ts legacy API
Browse files Browse the repository at this point in the history
  • Loading branch information
cv3d committed Sep 11, 2018
1 parent 142e8cd commit c9e86a3
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
89 changes: 89 additions & 0 deletions modules/ts/include/opencv2/ts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,62 @@ inline int clipInt( int val, int min_val, int max_val )
}

double getMinVal(ElemDepth depth);
#ifdef CV_TRANSNATIONAL_API
static inline double getMinVal(int depth)
{
CV_DEPRECATED_TYPE_WARNING(depth, int, ElemDepth);
return getMinVal(static_cast<ElemDepth>(depth));
}
#endif // CV_TRANSNATIONAL_API
double getMaxVal(ElemDepth depth);
#ifdef CV_TRANSNATIONAL_API
static inline double getMaxVal(int depth)
{
CV_DEPRECATED_TYPE_WARNING(depth, int, ElemDepth);
return getMaxVal(static_cast<ElemDepth>(depth));
}
#endif // CV_TRANSNATIONAL_API

Size randomSize(RNG& rng, double maxSizeLog);
void randomSize(RNG& rng, int minDims, int maxDims, double maxSizeLog, vector<int>& sz);
ElemType randomType(RNG& rng, cv::_OutputArray::DepthMask typeMask, int minChannels, int maxChannels);
Mat randomMat(RNG& rng, Size size, ElemType type, double minVal, double maxVal, bool useRoi);
#ifdef CV_TRANSNATIONAL_API
static inline Mat randomMat(RNG& rng, Size size, int type, double minVal, double maxVal, bool useRoi)
{
CV_DEPRECATED_TYPE_WARNING(type, int, ElemType);
return randomMat(rng, size, static_cast<ElemType>(type), minVal, maxVal, useRoi);
}
#endif // CV_TRANSNATIONAL_API
Mat randomMat(RNG& rng, const vector<int>& size, ElemType type, double minVal, double maxVal, bool useRoi);
#ifdef CV_TRANSNATIONAL_API
static inline Mat randomMat(RNG& rng, const vector<int>& size, int type, double minVal, double maxVal, bool useRoi)
{
CV_DEPRECATED_TYPE_WARNING(type, int, ElemType);
return randomMat(rng, size, static_cast<ElemType>(type), minVal, maxVal, useRoi);
}
#endif // CV_TRANSNATIONAL_API
void add(const Mat& a, double alpha, const Mat& b, double beta,
Scalar gamma, Mat& c, ElemType ctype, bool calcAbs=false);
#ifdef CV_TRANSNATIONAL_API
static inline void add(const Mat& a, double alpha, const Mat& b, double beta,
Scalar gamma, Mat& c, int ctype, bool calcAbs=false)
{
CV_DEPRECATED_TYPE_WARNING(ctype, int, ElemType);
return add(a, alpha, b, beta, gamma, c, static_cast<ElemType>(ctype), calcAbs);
}
#endif // CV_TRANSNATIONAL_API
void multiply(const Mat& a, const Mat& b, Mat& c, double alpha=1);
void divide(const Mat& a, const Mat& b, Mat& c, double alpha=1);

void convert(const Mat& src, cv::OutputArray dst, ElemDepth ddepth, double alpha=1, double beta=0);
#ifdef CV_TRANSNATIONAL_API
static inline void convert(const Mat& src, cv::OutputArray dst, int ddepth, double alpha=1, double beta=0)
{
CV_DEPRECATED_TYPE_WARNING(ddepth, int, ElemDepth);
return convert(src, dst, static_cast<ElemDepth>(ddepth), alpha, beta);
}
#endif // CV_TRANSNATIONAL_API
void copy(const Mat& src, Mat& dst, const Mat& mask=Mat(), bool invertMask=false);
void set(Mat& dst, const Scalar& gamma, const Mat& mask=Mat());

Expand All @@ -203,6 +246,15 @@ void dilate(const Mat& src, Mat& dst, const Mat& _kernel, Point anchor=Point(-1,
void filter2D(const Mat& src, Mat& dst, ElemDepth ddepth, const Mat& kernel,
Point anchor, double delta, int borderType,
const Scalar& borderValue=Scalar());
#ifdef CV_TRANSNATIONAL_API
static inline void filter2D(const Mat& src, Mat& dst, int ddepth, const Mat& kernel,
Point anchor, double delta, int borderType,
const Scalar& borderValue=Scalar())
{
CV_DEPRECATED_TYPE_WARNING(ddepth, int, ElemDepth);
return filter2D(src, dst, static_cast<ElemDepth>(ddepth), kernel, anchor, delta, borderType, borderValue);
}
#endif // CV_TRANSNATIONAL_API
void copyMakeBorder(const Mat& src, Mat& dst, int top, int bottom, int left, int right,
int borderType, const Scalar& borderValue=Scalar());
Mat calcSobelKernel2D( int dx, int dy, int apertureSize, int origin=0 );
Expand Down Expand Up @@ -519,6 +571,27 @@ class TS
* Subclass of BaseTest for testing functions that process dense arrays *
\*****************************************************************************************/

#ifdef CV_TRANSNATIONAL_API
struct ToElemType : public std::unary_function<int, ElemType>
{
ElemType operator()(const int& type) const
{
return static_cast<ElemType>(type);
}
};

struct ToElemTypeVec : public std::unary_function<vector<int>, vector<ElemType>>
{
vector<ElemType> operator()(const vector<int>& _types) const
{
vector<ElemType> types;
types.reserve(_types.size());
std::transform(_types.begin(), _types.end(), std::back_inserter(types), ToElemType());
return types;
}
};
#endif // CV_TRANSNATIONAL_API

class ArrayTest : public BaseTest
{
public:
Expand All @@ -536,8 +609,24 @@ class ArrayTest : public BaseTest

virtual void prepare_to_validation(int test_case_idx);
virtual void get_test_array_types_and_sizes(int test_case_idx, vector<vector<Size> >& sizes, vector<vector<ElemType> >& types);
#ifdef CV_TRANSNATIONAL_API
inline virtual void get_test_array_types_and_sizes(int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& _types)
{
vector<vector<ElemType> > types;
types.reserve(_types.size());
std::transform(_types.begin(), _types.end(), std::back_inserter(types), ToElemTypeVec());
return get_test_array_types_and_sizes(test_case_idx, sizes, types);
}
#endif // CV_TRANSNATIONAL_API
virtual void fill_array(int test_case_idx, int i, int j, Mat& arr);
virtual void get_minmax_bounds(int i, int j, ElemDepth depth, Scalar& low, Scalar& high);
#ifdef CV_TRANSNATIONAL_API
inline virtual void get_minmax_bounds(int i, int j, int depth, Scalar& low, Scalar& high)
{
CV_DEPRECATED_TYPE_WARNING(depth, int, ElemDepth);
return get_minmax_bounds(i, j, static_cast<ElemDepth>(depth), low, high);
}
#endif // CV_TRANSNATIONAL_API
virtual double get_success_error_level(int test_case_idx, int i, int j);

bool cvmat_allowed;
Expand Down
21 changes: 21 additions & 0 deletions modules/ts/include/opencv2/ts/ocl_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,19 @@ struct TestUtils
return cvtest::randomMat(dataRng, size, type, minVal, maxVal, useRoi);
}

#ifdef CV_TRANSNATIONAL_API
inline Mat randomMat(Size size, int type, double minVal, double maxVal, bool useRoi = false)
{
CV_DEPRECATED_TYPE_WARNING(type, int, ElemType);
return randomMat(size, static_cast<ElemType>(type), minVal, maxVal, useRoi);
}
inline Mat randomMat(Size size, ElemDepth type, double minVal, double maxVal, bool useRoi = false)
{
CV_DEPRECATED_TYPE_WARNING(type, ElemDepth, ElemType);
return randomMat(size, static_cast<ElemType>(type), minVal, maxVal, useRoi);
}
#endif // CV_TRANSNATIONAL_API

struct Border
{
int top, bot, lef, rig;
Expand All @@ -292,6 +305,14 @@ struct TestUtils
subMat = whole(Rect(border.lef, border.top, roiSize.width, roiSize.height));
}

#ifdef CV_TRANSNATIONAL_API
inline void randomSubMat(Mat& whole, Mat& subMat, const Size& roiSize, const Border& border, int type, double minVal, double maxVal)
{
CV_DEPRECATED_TYPE_WARNING(type, int, ElemType);
return randomSubMat(whole, subMat, roiSize, border, static_cast<ElemType>(type), minVal, maxVal);
}
#endif // CV_TRANSNATIONAL_API

// If the two vectors are not equal, it will return the difference in vector size
// Else it will return (total diff of each 1 and 2 rects covered pixels)/(total 1 rects covered pixels)
// The smaller, the better matched
Expand Down

0 comments on commit c9e86a3

Please sign in to comment.