Commit 07fa62f0 authored by Alexander Reshetnikov's avatar Alexander Reshetnikov

some design code changes in new tests

parent ea5d0155
This diff is collapsed.
...@@ -18,14 +18,14 @@ const int INT_TYPE [5] = {CV_8U, CV_8S, CV_16U, CV_16S, CV_32S}; ...@@ -18,14 +18,14 @@ const int INT_TYPE [5] = {CV_8U, CV_8S, CV_16U, CV_16S, CV_32S};
class CV_CountNonZeroTest: public cvtest::BaseTest class CV_CountNonZeroTest: public cvtest::BaseTest
{ {
public: public:
CV_CountNonZeroTest(); CV_CountNonZeroTest();
~CV_CountNonZeroTest(); ~CV_CountNonZeroTest();
protected: protected:
void run (int); void run (int);
private: private:
float eps_32; float eps_32;
double eps_64; double eps_64;
Mat src; Mat src;
...@@ -47,8 +47,8 @@ void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type) ...@@ -47,8 +47,8 @@ void CV_CountNonZeroTest::generate_src_data(cv::Size size, int type)
{ {
src.create(size, CV_MAKETYPE(type, 1)); src.create(size, CV_MAKETYPE(type, 1));
for (size_t j = 0; j < size.width; ++j) for (int j = 0; j < size.width; ++j)
for (size_t i = 0; i < size.height; ++i) for (int i = 0; i < size.height; ++i)
switch (type) switch (type)
{ {
case CV_8U: { src.at<uchar>(i, j) = cv::randu<uchar>(); break; } case CV_8U: { src.at<uchar>(i, j) = cv::randu<uchar>(); break; }
...@@ -107,8 +107,8 @@ int CV_CountNonZeroTest::get_count_non_zero() ...@@ -107,8 +107,8 @@ int CV_CountNonZeroTest::get_count_non_zero()
{ {
int result = 0; int result = 0;
for (size_t i = 0; i < src.rows; ++i) for (int i = 0; i < src.rows; ++i)
for (size_t j = 0; j < src.cols; ++j) for (int j = 0; j < src.cols; ++j)
if (current_type == CV_8U) result += (src.at<uchar>(i, j) > 0); if (current_type == CV_8U) result += (src.at<uchar>(i, j) > 0);
......
This diff is collapsed.
#include "test_precomp.hpp" #include "test_precomp.hpp"
#include <time.h> #include <time.h>
#include <iostream>
#define IMGPROC_BOUNDINGRECT_ERROR_DIFF 1 #define IMGPROC_BOUNDINGRECT_ERROR_DIFF 1
...@@ -11,36 +10,36 @@ using namespace std; ...@@ -11,36 +10,36 @@ using namespace std;
class CV_BoundingRectTest: public cvtest::ArrayTest class CV_BoundingRectTest: public cvtest::ArrayTest
{ {
public: public:
CV_BoundingRectTest(); CV_BoundingRectTest();
~CV_BoundingRectTest(); ~CV_BoundingRectTest();
protected: protected:
void run (int); void run (int);
private: private:
template <class T> void generate_src_points(vector <Point_<T> >& src, int n); template <typename T> void generate_src_points(vector <Point_<T> >& src, int n);
template <class T> cv::Rect get_bounding_rect(const vector <Point_<T> > src); template <typename T> cv::Rect get_bounding_rect(const vector <Point_<T> > src);
template <class T> bool checking_function_work(vector <Point_<T> >& src, int type); template <typename T> bool checking_function_work(vector <Point_<T> >& src, int type);
}; };
CV_BoundingRectTest::CV_BoundingRectTest() {} CV_BoundingRectTest::CV_BoundingRectTest() {}
CV_BoundingRectTest::~CV_BoundingRectTest() {} CV_BoundingRectTest::~CV_BoundingRectTest() {}
template <class T> void CV_BoundingRectTest::generate_src_points(vector <Point_<T> >& src, int n) template <typename T> void CV_BoundingRectTest::generate_src_points(vector <Point_<T> >& src, int n)
{ {
src.clear(); src.clear();
for (size_t i = 0; i < n; ++i) for (int i = 0; i < n; ++i)
src.push_back(Point_<T>(cv::randu<T>(), cv::randu<T>())); src.push_back(Point_<T>(cv::randu<T>(), cv::randu<T>()));
} }
template <class T> cv::Rect CV_BoundingRectTest::get_bounding_rect(const vector <Point_<T> > src) template <typename T> cv::Rect CV_BoundingRectTest::get_bounding_rect(const vector <Point_<T> > src)
{ {
int n = src.size(); int n = src.size();
T min_w = std::numeric_limits<T>::max(), max_w = std::numeric_limits<T>::min(); T min_w = std::numeric_limits<T>::max(), max_w = std::numeric_limits<T>::min();
T min_h = min_w, max_h = max_w; T min_h = min_w, max_h = max_w;
for (size_t i = 0; i < n; ++i) for (int i = 0; i < n; ++i)
{ {
min_w = std::min<T>(src.at(i).x, min_w); min_w = std::min<T>(src.at(i).x, min_w);
max_w = std::max<T>(src.at(i).x, max_w); max_w = std::max<T>(src.at(i).x, max_w);
...@@ -51,7 +50,7 @@ template <class T> cv::Rect CV_BoundingRectTest::get_bounding_rect(const vector ...@@ -51,7 +50,7 @@ template <class T> cv::Rect CV_BoundingRectTest::get_bounding_rect(const vector
return Rect((int)min_w, (int)min_h, (int)(floor(1.0*(max_w-min_w)) + 1), (int)(floor(1.0*(max_h-min_h)) + 1)); return Rect((int)min_w, (int)min_h, (int)(floor(1.0*(max_w-min_w)) + 1), (int)(floor(1.0*(max_h-min_h)) + 1));
} }
template <class T> bool CV_BoundingRectTest::checking_function_work(vector <Point_<T> >& src, int type) template <typename T> bool CV_BoundingRectTest::checking_function_work(vector <Point_<T> >& src, int type)
{ {
const int MAX_COUNT_OF_POINTS = 1000; const int MAX_COUNT_OF_POINTS = 1000;
const int N = 10000; const int N = 10000;
...@@ -77,7 +76,6 @@ template <class T> bool CV_BoundingRectTest::checking_function_work(vector <Poin ...@@ -77,7 +76,6 @@ template <class T> bool CV_BoundingRectTest::checking_function_work(vector <Poin
{ {
case 0: {cout << "INT"; break;} case 0: {cout << "INT"; break;}
case 1: {cout << "FLOAT"; break;} case 1: {cout << "FLOAT"; break;}
case 2: {cout << "DOUBLE"; break;}
default: break; default: break;
} }
cout << endl; cout << endl;
......
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