GPU module code cleaning

* tests do not crash without test data
* test files renamed in systematic way
* added Test suffix for test classes names
* ts->printf used instead of some cout
pull/13383/head
Kirill Kornyakov 15 years ago
parent ec7e937481
commit a38e511188
  1. 0
      tests/gpu/src/gputest_main.cpp
  2. 22
      tests/gpu/src/meanshift.cpp
  3. 33
      tests/gpu/src/operator_async_call.cpp
  4. 23
      tests/gpu/src/operator_convert_to.cpp
  5. 27
      tests/gpu/src/operator_copy_to.cpp
  6. 47
      tests/gpu/src/operator_set_to.cpp
  7. 24
      tests/gpu/src/stereo_bm.cpp
  8. 19
      tests/gpu/src/stereo_bp.cpp
  9. 25
      tests/gpu/src/stereo_csbp.cpp

@ -40,23 +40,25 @@
//M*/
#include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuMeanShift : public CvTest
class CV_GpuMeanShiftTest : public CvTest
{
public:
CV_GpuMeanShift();
protected:
void run(int);
public:
CV_GpuMeanShiftTest();
protected:
void run(int);
};
CV_GpuMeanShift::CV_GpuMeanShift(): CvTest( "GPU-MeanShift", "MeanShift" ){}
CV_GpuMeanShiftTest::CV_GpuMeanShiftTest(): CvTest( "GPU-MeanShift", "MeanShift" ){}
void CV_GpuMeanShift::run(int)
void CV_GpuMeanShiftTest::run(int)
{
int spatialRad = 30;
int colorRad = 30;
@ -107,4 +109,4 @@ void CV_GpuMeanShift::run(int)
ts->set_failed_test_info((maxDiff == 0) ? CvTS::OK : CvTS::FAIL_GENERIC);
}
CV_GpuMeanShift CV_GpuMeanShift_test;
CV_GpuMeanShiftTest CV_GpuMeanShift_test;

@ -42,6 +42,7 @@
#include "gputest.hpp"
#include "highgui.h"
#include "cv.h"
#include <string>
#include <iostream>
#include <fstream>
@ -54,26 +55,24 @@ using namespace cv;
using namespace std;
using namespace gpu;
class CV_GpuMatASyncCall : public CvTest
class CV_GpuMatAsyncCallTest : public CvTest
{
public:
CV_GpuMatASyncCall();
~CV_GpuMatASyncCall();
protected:
CV_GpuMatAsyncCallTest();
~CV_GpuMatAsyncCallTest();
protected:
void run(int);
template <typename T>
void print_mat(const T & mat, const std::string & name) const;
void run(int);
bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
bool compare_matrix(cv::Mat & cpumat);
private:
int rows;
int cols;
};
CV_GpuMatASyncCall::CV_GpuMatASyncCall(): CvTest( "GPU-MatOperatorASyncCall", "async" )
CV_GpuMatAsyncCallTest::CV_GpuMatAsyncCallTest(): CvTest( "GPU-MatOperatorAsyncCall", "async" )
{
rows = 234;
cols = 123;
@ -81,15 +80,15 @@ CV_GpuMatASyncCall::CV_GpuMatASyncCall(): CvTest( "GPU-MatOperatorASyncCall", "a
//#define PRINT_MATRIX
}
CV_GpuMatASyncCall::~CV_GpuMatASyncCall() {}
CV_GpuMatAsyncCallTest::~CV_GpuMatAsyncCallTest() {}
template<typename T>
void CV_GpuMatASyncCall::print_mat(const T & mat, const std::string & name) const
void CV_GpuMatAsyncCallTest::print_mat(const T & mat, const std::string & name) const
{
cv::imshow(name, mat);
}
bool CV_GpuMatASyncCall::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
bool CV_GpuMatAsyncCallTest::compare_matrix(cv::Mat & cpumat)
{
Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
GpuMat gmat0(cmat);
@ -132,19 +131,19 @@ bool CV_GpuMatASyncCall::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
return true;
else
{
std::cout << "return : " << ret << "\n";
ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
return false;
}
}
void CV_GpuMatASyncCall::run( int /* start_from */)
void CV_GpuMatAsyncCallTest::run( int /* start_from */)
{
bool is_test_good = true;
Mat cpumat(rows, cols, CV_8U);
cpumat.setTo(Scalar::all(127));
GpuMat gpumat(cpumat);
is_test_good &= compare_matrix(cpumat, gpumat);
is_test_good &= compare_matrix(cpumat);
if (is_test_good == true)
ts->set_failed_test_info(CvTS::OK);
@ -152,4 +151,4 @@ void CV_GpuMatASyncCall::run( int /* start_from */)
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
}
CV_GpuMatASyncCall CV_GpuMatASyncCall_test;
CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;

@ -40,6 +40,7 @@
//M*/
#include "gputest.hpp"
#include <string>
#include <iostream>
#include <fstream>
@ -51,19 +52,20 @@ using namespace cv;
using namespace std;
using namespace gpu;
class CV_GpuMatOpConvertTo : public CvTest
class CV_GpuMatOpConvertToTest : public CvTest
{
public:
CV_GpuMatOpConvertTo();
~CV_GpuMatOpConvertTo();
CV_GpuMatOpConvertToTest();
~CV_GpuMatOpConvertToTest();
protected:
void run(int);
};
CV_GpuMatOpConvertTo::CV_GpuMatOpConvertTo(): CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {}
CV_GpuMatOpConvertTo::~CV_GpuMatOpConvertTo() {}
CV_GpuMatOpConvertToTest::CV_GpuMatOpConvertToTest(): CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {}
CV_GpuMatOpConvertToTest::~CV_GpuMatOpConvertToTest() {}
void CV_GpuMatOpConvertTo::run( int /* start_from */)
void CV_GpuMatOpConvertToTest::run(int /* start_from */)
{
const Size img_size(67, 35);
@ -102,8 +104,9 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
double r = norm(cpumatdst, gpumatdst, NORM_INF);
if (r > 1)
{
cout << "FAILED: " << "SRC_TYPE=" << types_str[i] << "C" << c << " DST_TYPE=" << types_str[j] << " NORM = " << r << endl;
ts->printf(CvTS::CONSOLE,
"\nFAILED: SRC_TYPE=%sC%d DST_TYPE=%s NORM = %d\n",
types_str[i], c, types_str[j], r);
passed = false;
}
}
@ -112,9 +115,9 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
}
catch(cv::Exception& e)
{
cout << "ERROR: " << e.err << endl;
ts->printf(CvTS::CONSOLE, "\nERROR: %s\n", e.err);
}
ts->set_failed_test_info(passed ? CvTS::OK : CvTS::FAIL_GENERIC);
}
CV_GpuMatOpConvertTo CV_GpuMatOpConvertTo_test;
CV_GpuMatOpConvertToTest CV_GpuMatOpConvertTo_test;

@ -42,6 +42,7 @@
#include "gputest.hpp"
#include "highgui.h"
#include "cv.h"
#include <string>
#include <iostream>
#include <fstream>
@ -54,18 +55,16 @@ using namespace cv;
using namespace std;
using namespace gpu;
class CV_GpuMatOpCopyTo : public CvTest
class CV_GpuMatOpCopyToTest : public CvTest
{
public:
CV_GpuMatOpCopyTo();
~CV_GpuMatOpCopyTo();
protected:
CV_GpuMatOpCopyToTest();
~CV_GpuMatOpCopyToTest();
protected:
void run(int);
template <typename T>
void print_mat(const T & mat, const std::string & name) const;
void run(int);
bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
private:
@ -73,7 +72,7 @@ class CV_GpuMatOpCopyTo : public CvTest
int cols;
};
CV_GpuMatOpCopyTo::CV_GpuMatOpCopyTo(): CvTest( "GPU-MatOperatorCopyTo", "copyTo" )
CV_GpuMatOpCopyToTest::CV_GpuMatOpCopyToTest(): CvTest( "GPU-MatOperatorCopyTo", "copyTo" )
{
rows = 234;
cols = 123;
@ -81,15 +80,15 @@ CV_GpuMatOpCopyTo::CV_GpuMatOpCopyTo(): CvTest( "GPU-MatOperatorCopyTo", "copyTo
//#define PRINT_MATRIX
}
CV_GpuMatOpCopyTo::~CV_GpuMatOpCopyTo() {}
CV_GpuMatOpCopyToTest::~CV_GpuMatOpCopyToTest() {}
template<typename T>
void CV_GpuMatOpCopyTo::print_mat(const T & mat, const std::string & name) const
void CV_GpuMatOpCopyToTest::print_mat(const T & mat, const std::string & name) const
{
cv::imshow(name, mat);
}
bool CV_GpuMatOpCopyTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
bool CV_GpuMatOpCopyToTest::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
{
Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
GpuMat gmat(cmat);
@ -128,12 +127,12 @@ bool CV_GpuMatOpCopyTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
return true;
else
{
std::cout << "return : " << ret << "\n";
ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
return false;
}
}
void CV_GpuMatOpCopyTo::run( int /* start_from */)
void CV_GpuMatOpCopyToTest::run( int /* start_from */)
{
bool is_test_good = true;
@ -153,4 +152,4 @@ void CV_GpuMatOpCopyTo::run( int /* start_from */)
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
}
CV_GpuMatOpCopyTo CV_GpuMatOpCopyTo_test;
CV_GpuMatOpCopyToTest CV_GpuMatOpCopyTo_test;

@ -41,6 +41,7 @@
#include "gputest.hpp"
#include "highgui.h"
#include <string>
#include <iostream>
#include <fstream>
@ -53,25 +54,25 @@ using namespace cv;
using namespace std;
using namespace gpu;
class CV_GpuMatOpSetTo : public CvTest
class CV_GpuMatOpSetToTest : public CvTest
{
public:
CV_GpuMatOpSetTo();
~CV_GpuMatOpSetTo();
protected:
void print_mat(cv::Mat & mat, std::string name = "cpu mat");
void print_mat(gpu::GpuMat & mat, std::string name = "gpu mat");
void run(int);
bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
private:
int rows;
int cols;
Scalar s;
public:
CV_GpuMatOpSetToTest();
~CV_GpuMatOpSetToTest();
protected:
void run(int);
void print_mat(cv::Mat & mat, std::string name = "cpu mat");
void print_mat(gpu::GpuMat & mat, std::string name = "gpu mat");
bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
private:
int rows;
int cols;
Scalar s;
};
CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GPU-MatOperatorSetTo", "setTo" )
CV_GpuMatOpSetToTest::CV_GpuMatOpSetToTest(): CvTest( "GPU-MatOperatorSetTo", "setTo" )
{
rows = 256;
cols = 124;
@ -84,21 +85,21 @@ CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GPU-MatOperatorSetTo", "setTo" )
//#define PRINT_MATRIX
}
CV_GpuMatOpSetTo::~CV_GpuMatOpSetTo() {}
CV_GpuMatOpSetToTest::~CV_GpuMatOpSetToTest() {}
void CV_GpuMatOpSetTo::print_mat(cv::Mat & mat, std::string name )
void CV_GpuMatOpSetToTest::print_mat(cv::Mat & mat, std::string name )
{
cv::imshow(name, mat);
}
void CV_GpuMatOpSetTo::print_mat(gpu::GpuMat & mat, std::string name)
void CV_GpuMatOpSetToTest::print_mat(gpu::GpuMat & mat, std::string name)
{
cv::Mat newmat;
mat.download(newmat);
print_mat(newmat, name);
}
bool CV_GpuMatOpSetTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
bool CV_GpuMatOpSetToTest::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
{
//int64 time = getTickCount();
cpumat.setTo(s);
@ -122,12 +123,12 @@ bool CV_GpuMatOpSetTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
return true;
else
{
std::cout << "return : " << ret << "\n";
ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
return false;
}
}
void CV_GpuMatOpSetTo::run( int /* start_from */)
void CV_GpuMatOpSetToTest::run( int /* start_from */)
{
bool is_test_good = true;
@ -144,4 +145,4 @@ void CV_GpuMatOpSetTo::run( int /* start_from */)
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
}
CV_GpuMatOpSetTo CV_GpuMatOpSetTo_test;
CV_GpuMatOpSetToTest CV_GpuMatOpSetTo_test;

@ -40,28 +40,35 @@
//M*/
#include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuStereoBM : public CvTest
class CV_GpuStereoBMTest : public CvTest
{
public:
CV_GpuStereoBM();
CV_GpuStereoBMTest();
protected:
void run(int);
};
CV_GpuStereoBM::CV_GpuStereoBM(): CvTest( "GPU-StereoBM", "StereoBM" ){}
CV_GpuStereoBMTest::CV_GpuStereoBMTest(): CvTest( "GPU-StereoBM", "StereoBM" ){}
void CV_GpuStereoBM::run(int )
void CV_GpuStereoBMTest::run(int )
{
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-L.png", 0);
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-R.png", 0);
cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
if (img_l.empty() || img_r.empty() || img_template.empty())
{
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
return;
}
cv::gpu::GpuMat disp;
cv::gpu::StereoBM_GPU bm(0, 128, 19);
@ -72,10 +79,11 @@ void CV_GpuStereoBM::run(int )
disp.convertTo(disp, img_template.type());
double norm = cv::norm(disp, img_template, cv::NORM_INF);
if (norm >= 100) std::cout << "StereoBM norm = " << norm << std::endl;
if (norm >= 100)
ts->printf(CvTS::CONSOLE, "\nStereoBM norm = %f\n", norm);
ts->set_failed_test_info((norm < 100) ? CvTS::OK : CvTS::FAIL_GENERIC);
}
CV_GpuStereoBM CV_GpuStereoBM_test;
CV_GpuStereoBMTest CV_GpuStereoBM_test;

@ -40,23 +40,24 @@
//M*/
#include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuStereoBP : public CvTest
class CV_GpuStereoBPTest : public CvTest
{
public:
CV_GpuStereoBP();
CV_GpuStereoBPTest();
protected:
void run(int);
};
CV_GpuStereoBP::CV_GpuStereoBP(): CvTest( "GPU-StereoBP", "StereoBP" ){}
CV_GpuStereoBPTest::CV_GpuStereoBPTest(): CvTest( "GPU-StereoBP", "StereoBP" ){}
void CV_GpuStereoBP::run(int )
void CV_GpuStereoBPTest::run(int )
{
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");
@ -78,10 +79,10 @@ void CV_GpuStereoBP::run(int )
disp.convertTo(disp, img_template.type());
double norm = cv::norm(disp, img_template, cv::NORM_INF);
if (norm >= 0.5) std::cout << "StereoBP norm = " << norm << std::endl;
if (norm >= 0.5)
ts->printf(CvTS::CONSOLE, "\nStereoBP norm = %f\n", norm);
ts->set_failed_test_info((norm < 0.5) ? CvTS::OK : CvTS::FAIL_GENERIC);
}
CV_GpuStereoBP CV_GpuStereoBP_test;
CV_GpuStereoBPTest CV_GpuStereoBP_test;

@ -40,28 +40,35 @@
//M*/
#include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream>
#include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuCSStereoBP : public CvTest
class CV_GpuStereoCSBPTest : public CvTest
{
public:
CV_GpuCSStereoBP();
CV_GpuStereoCSBPTest();
protected:
void run(int);
};
CV_GpuCSStereoBP::CV_GpuCSStereoBP(): CvTest( "GPU-CSStereoBP", "ConstantSpaceStereoBP" ){}
CV_GpuStereoCSBPTest::CV_GpuStereoCSBPTest(): CvTest( "GPU-StereoCSBP", "ConstantSpaceStereoBP" ){}
void CV_GpuCSStereoBP::run(int )
void CV_GpuStereoCSBPTest::run(int )
{
cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-L.png");
cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-R.png");
cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", 0);
if (img_l.empty() || img_r.empty() || img_template.empty())
{
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
return;
}
cv::gpu::GpuMat disp;
cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
@ -72,9 +79,9 @@ void CV_GpuCSStereoBP::run(int )
disp.convertTo(disp, img_template.type());
double norm = cv::norm(disp, img_template, cv::NORM_INF);
if (norm >= 0.5) std::cout << "ConstantSpaceStereoBP norm = " << norm << std::endl;
if (norm >= 0.5)
ts->printf(CvTS::CONSOLE, "\nConstantSpaceStereoBP norm = %f\n", norm);
ts->set_failed_test_info((norm < 0.5) ? CvTS::OK : CvTS::FAIL_GENERIC);
}
CV_GpuCSStereoBP CV_GpuCSStereoBP_test;
CV_GpuStereoCSBPTest CV_GpuCSStereoBP_test;
Loading…
Cancel
Save