Commit a38e5111 authored by Kirill Kornyakov's avatar Kirill Kornyakov

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
parent ec7e9374
...@@ -40,23 +40,25 @@ ...@@ -40,23 +40,25 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuMeanShift : public CvTest class CV_GpuMeanShiftTest : public CvTest
{ {
public: public:
CV_GpuMeanShift(); CV_GpuMeanShiftTest();
protected:
void run(int); 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 spatialRad = 30;
int colorRad = 30; int colorRad = 30;
...@@ -107,4 +109,4 @@ void CV_GpuMeanShift::run(int) ...@@ -107,4 +109,4 @@ void CV_GpuMeanShift::run(int)
ts->set_failed_test_info((maxDiff == 0) ? CvTS::OK : CvTS::FAIL_GENERIC); ts->set_failed_test_info((maxDiff == 0) ? CvTS::OK : CvTS::FAIL_GENERIC);
} }
CV_GpuMeanShift CV_GpuMeanShift_test; CV_GpuMeanShiftTest CV_GpuMeanShift_test;
\ No newline at end of file \ No newline at end of file
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "gputest.hpp" #include "gputest.hpp"
#include "highgui.h" #include "highgui.h"
#include "cv.h" #include "cv.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -54,26 +55,24 @@ using namespace cv; ...@@ -54,26 +55,24 @@ using namespace cv;
using namespace std; using namespace std;
using namespace gpu; using namespace gpu;
class CV_GpuMatASyncCall : public CvTest class CV_GpuMatAsyncCallTest : public CvTest
{ {
public: public:
CV_GpuMatASyncCall(); CV_GpuMatAsyncCallTest();
~CV_GpuMatASyncCall(); ~CV_GpuMatAsyncCallTest();
protected:
protected:
void run(int);
template <typename T> template <typename T>
void print_mat(const T & mat, const std::string & name) const; void print_mat(const T & mat, const std::string & name) const;
bool compare_matrix(cv::Mat & cpumat);
void run(int);
bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
private: private:
int rows; int rows;
int cols; int cols;
}; };
CV_GpuMatASyncCall::CV_GpuMatASyncCall(): CvTest( "GPU-MatOperatorASyncCall", "async" ) CV_GpuMatAsyncCallTest::CV_GpuMatAsyncCallTest(): CvTest( "GPU-MatOperatorAsyncCall", "async" )
{ {
rows = 234; rows = 234;
cols = 123; cols = 123;
...@@ -81,15 +80,15 @@ CV_GpuMatASyncCall::CV_GpuMatASyncCall(): CvTest( "GPU-MatOperatorASyncCall", "a ...@@ -81,15 +80,15 @@ CV_GpuMatASyncCall::CV_GpuMatASyncCall(): CvTest( "GPU-MatOperatorASyncCall", "a
//#define PRINT_MATRIX //#define PRINT_MATRIX
} }
CV_GpuMatASyncCall::~CV_GpuMatASyncCall() {} CV_GpuMatAsyncCallTest::~CV_GpuMatAsyncCallTest() {}
template<typename T> 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); 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)); Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
GpuMat gmat0(cmat); GpuMat gmat0(cmat);
...@@ -132,19 +131,19 @@ bool CV_GpuMatASyncCall::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat) ...@@ -132,19 +131,19 @@ bool CV_GpuMatASyncCall::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
return true; return true;
else else
{ {
std::cout << "return : " << ret << "\n"; ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
return false; return false;
} }
} }
void CV_GpuMatASyncCall::run( int /* start_from */) void CV_GpuMatAsyncCallTest::run( int /* start_from */)
{ {
bool is_test_good = true; bool is_test_good = true;
Mat cpumat(rows, cols, CV_8U); Mat cpumat(rows, cols, CV_8U);
cpumat.setTo(Scalar::all(127)); 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) if (is_test_good == true)
ts->set_failed_test_info(CvTS::OK); ts->set_failed_test_info(CvTS::OK);
...@@ -152,4 +151,4 @@ void CV_GpuMatASyncCall::run( int /* start_from */) ...@@ -152,4 +151,4 @@ void CV_GpuMatASyncCall::run( int /* start_from */)
ts->set_failed_test_info(CvTS::FAIL_GENERIC); ts->set_failed_test_info(CvTS::FAIL_GENERIC);
} }
CV_GpuMatASyncCall CV_GpuMatASyncCall_test; CV_GpuMatAsyncCallTest CV_GpuMatAsyncCall_test;
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -51,19 +52,20 @@ using namespace cv; ...@@ -51,19 +52,20 @@ using namespace cv;
using namespace std; using namespace std;
using namespace gpu; using namespace gpu;
class CV_GpuMatOpConvertTo : public CvTest class CV_GpuMatOpConvertToTest : public CvTest
{ {
public: public:
CV_GpuMatOpConvertTo(); CV_GpuMatOpConvertToTest();
~CV_GpuMatOpConvertTo(); ~CV_GpuMatOpConvertToTest();
protected: protected:
void run(int); void run(int);
}; };
CV_GpuMatOpConvertTo::CV_GpuMatOpConvertTo(): CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {} CV_GpuMatOpConvertToTest::CV_GpuMatOpConvertToTest(): CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {}
CV_GpuMatOpConvertTo::~CV_GpuMatOpConvertTo() {} CV_GpuMatOpConvertToTest::~CV_GpuMatOpConvertToTest() {}
void CV_GpuMatOpConvertTo::run( int /* start_from */) void CV_GpuMatOpConvertToTest::run(int /* start_from */)
{ {
const Size img_size(67, 35); const Size img_size(67, 35);
...@@ -102,8 +104,9 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */) ...@@ -102,8 +104,9 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
double r = norm(cpumatdst, gpumatdst, NORM_INF); double r = norm(cpumatdst, gpumatdst, NORM_INF);
if (r > 1) 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; passed = false;
} }
} }
...@@ -112,9 +115,9 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */) ...@@ -112,9 +115,9 @@ void CV_GpuMatOpConvertTo::run( int /* start_from */)
} }
catch(cv::Exception& e) 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); ts->set_failed_test_info(passed ? CvTS::OK : CvTS::FAIL_GENERIC);
} }
CV_GpuMatOpConvertTo CV_GpuMatOpConvertTo_test; CV_GpuMatOpConvertToTest CV_GpuMatOpConvertTo_test;
\ No newline at end of file
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "gputest.hpp" #include "gputest.hpp"
#include "highgui.h" #include "highgui.h"
#include "cv.h" #include "cv.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -54,18 +55,16 @@ using namespace cv; ...@@ -54,18 +55,16 @@ using namespace cv;
using namespace std; using namespace std;
using namespace gpu; using namespace gpu;
class CV_GpuMatOpCopyTo : public CvTest class CV_GpuMatOpCopyToTest : public CvTest
{ {
public: public:
CV_GpuMatOpCopyTo(); CV_GpuMatOpCopyToTest();
~CV_GpuMatOpCopyTo(); ~CV_GpuMatOpCopyToTest();
protected:
protected:
void run(int);
template <typename T> template <typename T>
void print_mat(const T & mat, const std::string & name) const; 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, gpu::GpuMat & gpumat);
private: private:
...@@ -73,7 +72,7 @@ class CV_GpuMatOpCopyTo : public CvTest ...@@ -73,7 +72,7 @@ class CV_GpuMatOpCopyTo : public CvTest
int cols; int cols;
}; };
CV_GpuMatOpCopyTo::CV_GpuMatOpCopyTo(): CvTest( "GPU-MatOperatorCopyTo", "copyTo" ) CV_GpuMatOpCopyToTest::CV_GpuMatOpCopyToTest(): CvTest( "GPU-MatOperatorCopyTo", "copyTo" )
{ {
rows = 234; rows = 234;
cols = 123; cols = 123;
...@@ -81,15 +80,15 @@ CV_GpuMatOpCopyTo::CV_GpuMatOpCopyTo(): CvTest( "GPU-MatOperatorCopyTo", "copyTo ...@@ -81,15 +80,15 @@ CV_GpuMatOpCopyTo::CV_GpuMatOpCopyTo(): CvTest( "GPU-MatOperatorCopyTo", "copyTo
//#define PRINT_MATRIX //#define PRINT_MATRIX
} }
CV_GpuMatOpCopyTo::~CV_GpuMatOpCopyTo() {} CV_GpuMatOpCopyToTest::~CV_GpuMatOpCopyToTest() {}
template<typename T> 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); 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)); Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
GpuMat gmat(cmat); GpuMat gmat(cmat);
...@@ -128,12 +127,12 @@ bool CV_GpuMatOpCopyTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat) ...@@ -128,12 +127,12 @@ bool CV_GpuMatOpCopyTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
return true; return true;
else else
{ {
std::cout << "return : " << ret << "\n"; ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
return false; return false;
} }
} }
void CV_GpuMatOpCopyTo::run( int /* start_from */) void CV_GpuMatOpCopyToTest::run( int /* start_from */)
{ {
bool is_test_good = true; bool is_test_good = true;
...@@ -153,4 +152,4 @@ void CV_GpuMatOpCopyTo::run( int /* start_from */) ...@@ -153,4 +152,4 @@ void CV_GpuMatOpCopyTo::run( int /* start_from */)
ts->set_failed_test_info(CvTS::FAIL_GENERIC); ts->set_failed_test_info(CvTS::FAIL_GENERIC);
} }
CV_GpuMatOpCopyTo CV_GpuMatOpCopyTo_test; CV_GpuMatOpCopyToTest CV_GpuMatOpCopyTo_test;
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "gputest.hpp" #include "gputest.hpp"
#include "highgui.h" #include "highgui.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -53,25 +54,25 @@ using namespace cv; ...@@ -53,25 +54,25 @@ using namespace cv;
using namespace std; using namespace std;
using namespace gpu; using namespace gpu;
class CV_GpuMatOpSetTo : public CvTest class CV_GpuMatOpSetToTest : public CvTest
{ {
public: public:
CV_GpuMatOpSetTo(); CV_GpuMatOpSetToTest();
~CV_GpuMatOpSetTo(); ~CV_GpuMatOpSetToTest();
protected:
void print_mat(cv::Mat & mat, std::string name = "cpu mat"); protected:
void print_mat(gpu::GpuMat & mat, std::string name = "gpu mat"); void run(int);
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); bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
private: private:
int rows; int rows;
int cols; int cols;
Scalar s; Scalar s;
}; };
CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GPU-MatOperatorSetTo", "setTo" ) CV_GpuMatOpSetToTest::CV_GpuMatOpSetToTest(): CvTest( "GPU-MatOperatorSetTo", "setTo" )
{ {
rows = 256; rows = 256;
cols = 124; cols = 124;
...@@ -84,21 +85,21 @@ CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GPU-MatOperatorSetTo", "setTo" ) ...@@ -84,21 +85,21 @@ CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GPU-MatOperatorSetTo", "setTo" )
//#define PRINT_MATRIX //#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); 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; cv::Mat newmat;
mat.download(newmat); mat.download(newmat);
print_mat(newmat, name); 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(); //int64 time = getTickCount();
cpumat.setTo(s); cpumat.setTo(s);
...@@ -122,12 +123,12 @@ bool CV_GpuMatOpSetTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat) ...@@ -122,12 +123,12 @@ bool CV_GpuMatOpSetTo::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
return true; return true;
else else
{ {
std::cout << "return : " << ret << "\n"; ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", ret);
return false; return false;
} }
} }
void CV_GpuMatOpSetTo::run( int /* start_from */) void CV_GpuMatOpSetToTest::run( int /* start_from */)
{ {
bool is_test_good = true; bool is_test_good = true;
...@@ -144,4 +145,4 @@ void CV_GpuMatOpSetTo::run( int /* start_from */) ...@@ -144,4 +145,4 @@ void CV_GpuMatOpSetTo::run( int /* start_from */)
ts->set_failed_test_info(CvTS::FAIL_GENERIC); ts->set_failed_test_info(CvTS::FAIL_GENERIC);
} }
CV_GpuMatOpSetTo CV_GpuMatOpSetTo_test; CV_GpuMatOpSetToTest CV_GpuMatOpSetTo_test;
...@@ -40,28 +40,35 @@ ...@@ -40,28 +40,35 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuStereoBM : public CvTest class CV_GpuStereoBMTest : public CvTest
{ {
public: public:
CV_GpuStereoBM(); CV_GpuStereoBMTest();
protected: protected:
void run(int); 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_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_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); 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::GpuMat disp;
cv::gpu::StereoBM_GPU bm(0, 128, 19); cv::gpu::StereoBM_GPU bm(0, 128, 19);
...@@ -72,10 +79,11 @@ void CV_GpuStereoBM::run(int ) ...@@ -72,10 +79,11 @@ void CV_GpuStereoBM::run(int )
disp.convertTo(disp, img_template.type()); disp.convertTo(disp, img_template.type());
double norm = cv::norm(disp, img_template, cv::NORM_INF); 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); 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 @@ ...@@ -40,23 +40,24 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuStereoBP : public CvTest class CV_GpuStereoBPTest : public CvTest
{ {
public: public:
CV_GpuStereoBP(); CV_GpuStereoBPTest();
protected: protected:
void run(int); 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_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"); 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 ) ...@@ -78,10 +79,10 @@ void CV_GpuStereoBP::run(int )
disp.convertTo(disp, img_template.type()); disp.convertTo(disp, img_template.type());
double norm = cv::norm(disp, img_template, cv::NORM_INF); 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); ts->set_failed_test_info((norm < 0.5) ? CvTS::OK : CvTS::FAIL_GENERIC);
} }
CV_GpuStereoBP CV_GpuStereoBP_test; CV_GpuStereoBPTest CV_GpuStereoBP_test;
\ No newline at end of file
...@@ -40,28 +40,35 @@ ...@@ -40,28 +40,35 @@
//M*/ //M*/
#include "gputest.hpp" #include "gputest.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <opencv2/opencv.hpp>
#include <opencv2/gpu/gpu.hpp>
class CV_GpuCSStereoBP : public CvTest class CV_GpuStereoCSBPTest : public CvTest
{ {
public: public:
CV_GpuCSStereoBP(); CV_GpuStereoCSBPTest();
protected: protected:
void run(int); 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_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_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); 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::GpuMat disp;
cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4); cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
...@@ -72,9 +79,9 @@ void CV_GpuCSStereoBP::run(int ) ...@@ -72,9 +79,9 @@ void CV_GpuCSStereoBP::run(int )
disp.convertTo(disp, img_template.type()); disp.convertTo(disp, img_template.type());
double norm = cv::norm(disp, img_template, cv::NORM_INF); 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); ts->set_failed_test_info((norm < 0.5) ? CvTS::OK : CvTS::FAIL_GENERIC);
} }
CV_GpuStereoCSBPTest CV_GpuCSStereoBP_test;
CV_GpuCSStereoBP CV_GpuCSStereoBP_test; \ No newline at end of file
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