From 186b1fc6ef60101207f7ab120ab4d5911ed85d91 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Wed, 19 Jan 2011 12:47:34 +0000 Subject: [PATCH] refactored gpu module --- modules/gpu/src/initialization.cpp | 51 ++++++++++++++---------------- tests/gpu/src/match_template.cpp | 12 +++---- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/modules/gpu/src/initialization.cpp b/modules/gpu/src/initialization.cpp index bb613319f4..4831fc1e17 100644 --- a/modules/gpu/src/initialization.cpp +++ b/modules/gpu/src/initialization.cpp @@ -57,6 +57,9 @@ CV_EXPORTS int cv::gpu::getNumberOfSMs(int /*device*/) { throw_nogpu(); return 0 CV_EXPORTS void cv::gpu::getGpuMemInfo(size_t& /*free*/, size_t& /*total*/) { throw_nogpu(); } CV_EXPORTS bool cv::gpu::hasNativeDoubleSupport(int /*device*/) { throw_nogpu(); return false; } CV_EXPORTS bool cv::gpu::hasAtomicsSupport(int /*device*/) { throw_nogpu(); return false; } +CV_EXPORTS bool cv::gpu::ptxVersionIs(int major, int minor) { throw_nogpu(); return false; } +CV_EXPORTS bool cv::gpu::ptxVersionIsLessOrEqual(int major, int minor) { throw_nogpu(); return false; } +CV_EXPORTS bool cv::gpu::ptxVersionIsGreaterOrEqual(int major, int minor) { throw_nogpu(); return false; } #else /* !defined (HAVE_CUDA) */ @@ -133,33 +136,6 @@ CV_EXPORTS bool cv::gpu::hasAtomicsSupport(int device) namespace { - struct ComparerEqual - { - bool operator()(int lhs1, int lhs2, int rhs1, int rhs2) const - { - return lhs1 == rhs1 && lhs2 == rhs2; - } - }; - - - struct ComparerLessOrEqual - { - bool operator()(int lhs1, int lhs2, int rhs1, int rhs2) const - { - return lhs1 < rhs1 || (lhs1 == rhs1 && lhs2 <= rhs2); - } - }; - - - struct ComparerGreaterOrEqual - { - bool operator()(int lhs1, int lhs2, int rhs1, int rhs2) const - { - return lhs1 > rhs1 || (lhs1 == rhs1 && lhs2 >= rhs2); - } - }; - - template bool checkPtxVersion(int major, int minor, Comparer cmp) { @@ -194,18 +170,39 @@ namespace CV_EXPORTS bool cv::gpu::ptxVersionIs(int major, int minor) { + struct ComparerEqual + { + bool operator()(int lhs1, int lhs2, int rhs1, int rhs2) const + { + return lhs1 == rhs1 && lhs2 == rhs2; + } + }; return checkPtxVersion(major, minor, ComparerEqual()); } CV_EXPORTS bool cv::gpu::ptxVersionIsLessOrEqual(int major, int minor) { + struct ComparerLessOrEqual + { + bool operator()(int lhs1, int lhs2, int rhs1, int rhs2) const + { + return lhs1 < rhs1 || (lhs1 == rhs1 && lhs2 <= rhs2); + } + }; return checkPtxVersion(major, minor, ComparerLessOrEqual()); } CV_EXPORTS bool cv::gpu::ptxVersionIsGreaterOrEqual(int major, int minor) { + struct ComparerGreaterOrEqual + { + bool operator()(int lhs1, int lhs2, int rhs1, int rhs2) const + { + return lhs1 > rhs1 || (lhs1 == rhs1 && lhs2 >= rhs2); + } + }; return checkPtxVersion(major, minor, ComparerGreaterOrEqual()); } diff --git a/tests/gpu/src/match_template.cpp b/tests/gpu/src/match_template.cpp index 2adafdc309..eb9116bc6d 100644 --- a/tests/gpu/src/match_template.cpp +++ b/tests/gpu/src/match_template.cpp @@ -234,21 +234,21 @@ struct CV_GpuMatchTemplateFindPatternInBlackTest: CvTest { try { - Mat image = imread(std::string(ts->get_data_path()) + "matchtemplate/black.jpg"); + Mat image = imread(std::string(ts->get_data_path()) + "matchtemplate/black.png"); if (image.empty()) { ts->printf(CvTS::CONSOLE, "can't open file '%s'", (std::string(ts->get_data_path()) - + "matchtemplate/black.jpg").c_str()); - ts->set_failed_test_info(CvTS::FAIL_INVALID_TEST_DATA); + + "matchtemplate/black.png").c_str()); + ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA); return; } - Mat pattern = imread(std::string(ts->get_data_path()) + "matchtemplate/cat.jpg"); + Mat pattern = imread(std::string(ts->get_data_path()) + "matchtemplate/cat.png"); if (pattern.empty()) { ts->printf(CvTS::CONSOLE, "can't open file '%s'", (std::string(ts->get_data_path()) - + "matchtemplate/cat.jpg").c_str()); - ts->set_failed_test_info(CvTS::FAIL_INVALID_TEST_DATA); + + "matchtemplate/cat.png").c_str()); + ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA); return; }