+++ /dev/null
-# ----------------------------------------------------------------------------
-# CMake file for gputest. See root CMakeLists.txt
-# ----------------------------------------------------------------------------
-project(opencv_test_gpu)
-
-set(the_target "opencv_test_gpu")
-
-file(GLOB test_srcs "src/*.cpp")
-file(GLOB test_hdrs "src/*.h*")
-source_group("Src" FILES ${test_srcs})
-source_group("Include" FILES ${test_hdrs})
-
-
-
-
-include_directories (
- "${CMAKE_SOURCE_DIR}/include/opencv"
- "${CMAKE_SOURCE_DIR}/modules/core/include"
- "${CMAKE_SOURCE_DIR}/modules/imgproc/include"
- "${CMAKE_SOURCE_DIR}/modules/features2d/include"
- "${CMAKE_SOURCE_DIR}/modules/flann/include"
- "${CMAKE_SOURCE_DIR}/modules/calib3d/include"
- "${CMAKE_SOURCE_DIR}/modules/highgui/include"
- "${CMAKE_SOURCE_DIR}/modules/objdetect/include"
- "${CMAKE_SOURCE_DIR}/modules/video/include"
- "${CMAKE_SOURCE_DIR}/modules/legacy/include"
- "${CMAKE_SOURCE_DIR}/modules/contrib/include"
- "${CMAKE_SOURCE_DIR}/modules/gpu/include"
- "${CMAKE_SOURCE_DIR}/modules/ml/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/src"
- "${CMAKE_CURRENT_BINARY_DIR}"
- "${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia"
- "${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core"
- )
-
-include_directories(../cxts)
-
-if(HAVE_CUDA)
- include_directories(${CUDA_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/NPP_staging)
-
- file(GLOB nvidia "src/nvidia/*.*")
- source_group("Src\\nvidia" FILES ${nvidia})
-endif()
-
-add_executable(${the_target} ${test_srcs} ${test_hdrs} ${nvidia})
-
-# Additional target properties
-set_target_properties(${the_target} PROPERTIES
- DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
- )
-
-add_dependencies(${the_target} opencv_ts opencv_gpu opencv_highgui opencv_imgproc opencv_calib3d)
-
-# Add the required libraries for linking:
-target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_ts opencv_gpu opencv_highgui opencv_imgproc opencv_calib3d)
-
-enable_testing()
-get_target_property(LOC ${the_target} LOCATION)
-add_test(${the_target} "${LOC}")
-
-if(WIN32)
- install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)
-endif()
-
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <cmath>\r
-#include <limits>\r
-#include "gputest.hpp"\r
-\r
-using namespace cv;\r
-using namespace std;\r
-using namespace gpu;\r
-\r
-#define CHECK(pred, err) if (!(pred)) { \\r
- ts->printf(CvTS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \\r
- ts->set_failed_test_info(err); \\r
- return; }\r
-\r
-class CV_GpuArithmTest : public CvTest\r
-{\r
-public:\r
- CV_GpuArithmTest(const char* test_name, const char* test_funcs) : CvTest(test_name, test_funcs) {}\r
- virtual ~CV_GpuArithmTest() {}\r
-\r
-protected:\r
- void run(int);\r
-\r
- int test(int type);\r
-\r
- virtual int test(const Mat& mat1, const Mat& mat2) = 0;\r
-\r
- int CheckNorm(const Mat& m1, const Mat& m2, double eps = 1e-5);\r
- int CheckNorm(const Scalar& s1, const Scalar& s2, double eps = 1e-5);\r
- int CheckNorm(double d1, double d2, double eps = 1e-5);\r
-};\r
-\r
-int CV_GpuArithmTest::test(int type)\r
-{\r
- cv::Size sz(200, 200);\r
- cv::Mat mat1(sz, type), mat2(sz, type);\r
- \r
- cv::RNG rng(*ts->get_rng());\r
-\r
- if (type != CV_32FC1)\r
- {\r
- rng.fill(mat1, cv::RNG::UNIFORM, cv::Scalar::all(1), cv::Scalar::all(20));\r
- rng.fill(mat2, cv::RNG::UNIFORM, cv::Scalar::all(1), cv::Scalar::all(20));\r
- }\r
- else\r
- {\r
- rng.fill(mat1, cv::RNG::UNIFORM, cv::Scalar::all(0.1), cv::Scalar::all(1.0));\r
- rng.fill(mat2, cv::RNG::UNIFORM, cv::Scalar::all(0.1), cv::Scalar::all(1.0));\r
- }\r
-\r
- return test(mat1, mat2);\r
-}\r
-\r
-int CV_GpuArithmTest::CheckNorm(const Mat& m1, const Mat& m2, double eps)\r
-{\r
- double ret = norm(m1, m2, NORM_INF);\r
-\r
- if (ret < eps)\r
- return CvTS::OK;\r
-\r
- ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);\r
- return CvTS::FAIL_GENERIC;\r
-}\r
-\r
-int CV_GpuArithmTest::CheckNorm(const Scalar& s1, const Scalar& s2, double eps)\r
-{\r
- int ret0 = CheckNorm(s1[0], s2[0], eps), \r
- ret1 = CheckNorm(s1[1], s2[1], eps), \r
- ret2 = CheckNorm(s1[2], s2[2], eps), \r
- ret3 = CheckNorm(s1[3], s2[3], eps);\r
-\r
- return (ret0 == CvTS::OK && ret1 == CvTS::OK && ret2 == CvTS::OK && ret3 == CvTS::OK) ? CvTS::OK : CvTS::FAIL_GENERIC;\r
-}\r
-\r
-int CV_GpuArithmTest::CheckNorm(double d1, double d2, double eps)\r
-{\r
- double ret = ::fabs(d1 - d2);\r
-\r
- if (ret < eps)\r
- return CvTS::OK;\r
-\r
- ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);\r
- return CvTS::FAIL_GENERIC;\r
-}\r
-\r
-void CV_GpuArithmTest::run( int )\r
-{\r
- int testResult = CvTS::OK;\r
- try\r
- {\r
- const int types[] = {CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1};\r
- const char* type_names[] = {"CV_8UC1 ", "CV_8UC3 ", "CV_8UC4 ", "CV_32FC1"};\r
- const int type_count = sizeof(types)/sizeof(types[0]);\r
-\r
- //run tests\r
- for (int t = 0; t < type_count; ++t)\r
- {\r
- ts->printf(CvTS::LOG, "Start testing %s", type_names[t]);\r
-\r
- if (CvTS::OK == test(types[t]))\r
- ts->printf(CvTS::LOG, "SUCCESS\n");\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "FAIL\n");\r
- testResult = CvTS::FAIL_MISMATCH;\r
- }\r
- }\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(testResult);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Add\r
-\r
-struct CV_GpuNppImageAddTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageAddTest() : CV_GpuArithmTest( "GPU-NppImageAdd", "add" ) {}\r
-\r
- virtual int test(const Mat& mat1, const Mat& mat2)\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::add(mat1, mat2, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::add(gpu1, gpu2, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Sub\r
-struct CV_GpuNppImageSubtractTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageSubtractTest() : CV_GpuArithmTest( "GPU-NppImageSubtract", "subtract" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::subtract(mat1, mat2, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::subtract(gpu1, gpu2, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// multiply\r
-struct CV_GpuNppImageMultiplyTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageMultiplyTest() : CV_GpuArithmTest( "GPU-NppImageMultiply", "multiply" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::multiply(mat1, mat2, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::multiply(gpu1, gpu2, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// divide\r
-struct CV_GpuNppImageDivideTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageDivideTest() : CV_GpuArithmTest( "GPU-NppImageDivide", "divide" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::divide(mat1, mat2, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::divide(gpu1, gpu2, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes, 1.01f);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// transpose\r
-struct CV_GpuNppImageTransposeTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageTransposeTest() : CV_GpuArithmTest( "GPU-NppImageTranspose", "transpose" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::transpose(mat1, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpuRes;\r
- cv::gpu::transpose(gpu1, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// absdiff\r
-struct CV_GpuNppImageAbsdiffTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageAbsdiffTest() : CV_GpuArithmTest( "GPU-NppImageAbsdiff", "absdiff" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4 && mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::absdiff(mat1, mat2, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::absdiff(gpu1, gpu2, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// compare\r
-struct CV_GpuNppImageCompareTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageCompareTest() : CV_GpuArithmTest( "GPU-NppImageCompare", "compare" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- int cmp_codes[] = {CMP_EQ, CMP_GT, CMP_GE, CMP_LT, CMP_LE, CMP_NE};\r
- const char* cmp_str[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};\r
- int cmp_num = sizeof(cmp_codes) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < cmp_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nCompare operation: %s\n", cmp_str[i]);\r
-\r
- cv::Mat cpuRes;\r
- cv::compare(mat1, mat2, cpuRes, cmp_codes[i]);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::compare(gpu1, gpu2, gpuRes, cmp_codes[i]);\r
-\r
- if (CheckNorm(cpuRes, gpuRes) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// meanStdDev\r
-struct CV_GpuNppImageMeanStdDevTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageMeanStdDevTest() : CV_GpuArithmTest( "GPU-NppImageMeanStdDev", "meanStdDev" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& )\r
- {\r
- if (mat1.type() != CV_8UC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- Scalar cpumean;\r
- Scalar cpustddev;\r
- cv::meanStdDev(mat1, cpumean, cpustddev);\r
-\r
- GpuMat gpu1(mat1);\r
- Scalar gpumean;\r
- Scalar gpustddev;\r
- cv::gpu::meanStdDev(gpu1, gpumean, gpustddev);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- if (CheckNorm(cpumean, gpumean) != CvTS::OK)\r
- {\r
- ts->printf(CvTS::LOG, "\nMean FAILED\n");\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- if (CheckNorm(cpustddev, gpustddev) != CvTS::OK)\r
- {\r
- ts->printf(CvTS::LOG, "\nStdDev FAILED\n");\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// norm\r
-struct CV_GpuNppImageNormTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageNormTest() : CV_GpuArithmTest( "GPU-NppImageNorm", "norm" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_8UC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- int norms[] = {NORM_INF, NORM_L1, NORM_L2};\r
- const char* norms_str[] = {"NORM_INF", "NORM_L1", "NORM_L2"};\r
- int norms_num = sizeof(norms) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < norms_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nNorm type: %s\n", norms_str[i]);\r
-\r
- double cpu_norm = cv::norm(mat1, mat2, norms[i]);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- double gpu_norm = cv::gpu::norm(gpu1, gpu2, norms[i]);\r
-\r
- if (CheckNorm(cpu_norm, gpu_norm) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// flip\r
-struct CV_GpuNppImageFlipTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageFlipTest() : CV_GpuArithmTest( "GPU-NppImageFlip", "flip" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC4)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- int flip_codes[] = {0, 1, -1};\r
- const char* flip_axis[] = {"X", "Y", "Both"};\r
- int flip_codes_num = sizeof(flip_codes) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < flip_codes_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nFlip Axis: %s\n", flip_axis[i]);\r
-\r
- Mat cpu_res;\r
- cv::flip(mat1, cpu_res, flip_codes[i]);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu_res;\r
- cv::gpu::flip(gpu1, gpu_res, flip_codes[i]);\r
-\r
- if (CheckNorm(cpu_res, gpu_res) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// LUT\r
-struct CV_GpuNppImageLUTTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageLUTTest() : CV_GpuArithmTest( "GPU-NppImageLUT", "LUT" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& )\r
- {\r
- if (mat1.type() != CV_8UC1 && mat1.type() != CV_8UC3)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat lut(1, 256, CV_8UC1);\r
- cv::RNG rng(*ts->get_rng());\r
- rng.fill(lut, cv::RNG::UNIFORM, cv::Scalar::all(100), cv::Scalar::all(200));\r
-\r
- cv::Mat cpuRes;\r
- cv::LUT(mat1, lut, cpuRes);\r
-\r
- cv::gpu::GpuMat gpuRes;\r
- cv::gpu::LUT(GpuMat(mat1), lut, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// exp\r
-struct CV_GpuNppImageExpTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageExpTest() : CV_GpuArithmTest( "GPU-NppImageExp", "exp" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::exp(mat1, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpuRes;\r
- cv::gpu::exp(gpu1, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// log\r
-struct CV_GpuNppImageLogTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageLogTest() : CV_GpuArithmTest( "GPU-NppImageLog", "log" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::log(mat1, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpuRes;\r
- cv::gpu::log(gpu1, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// magnitude\r
-struct CV_GpuNppImageMagnitudeTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageMagnitudeTest() : CV_GpuArithmTest( "GPU-NppImageMagnitude", "magnitude" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::magnitude(mat1, mat2, cpuRes);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::magnitude(gpu1, gpu2, gpuRes);\r
-\r
- return CheckNorm(cpuRes, gpuRes);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// phase\r
-struct CV_GpuNppImagePhaseTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImagePhaseTest() : CV_GpuArithmTest( "GPU-NppImagePhase", "phase" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuRes;\r
- cv::phase(mat1, mat2, cpuRes, true);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuRes;\r
- cv::gpu::phase(gpu1, gpu2, gpuRes, true);\r
-\r
- return CheckNorm(cpuRes, gpuRes, 0.3f);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// cartToPolar\r
-struct CV_GpuNppImageCartToPolarTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImageCartToPolarTest() : CV_GpuArithmTest( "GPU-NppImageCartToPolar", "cartToPolar" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuMag, cpuAngle;\r
- cv::cartToPolar(mat1, mat2, cpuMag, cpuAngle);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuMag, gpuAngle;\r
- cv::gpu::cartToPolar(gpu1, gpu2, gpuMag, gpuAngle);\r
-\r
- int magRes = CheckNorm(cpuMag, gpuMag);\r
- int angleRes = CheckNorm(cpuAngle, gpuAngle, 0.005f);\r
-\r
- return magRes == CvTS::OK && angleRes == CvTS::OK ? CvTS::OK : CvTS::FAIL_GENERIC;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// polarToCart\r
-struct CV_GpuNppImagePolarToCartTest : public CV_GpuArithmTest\r
-{\r
- CV_GpuNppImagePolarToCartTest() : CV_GpuArithmTest( "GPU-NppImagePolarToCart", "polarToCart" ) {}\r
-\r
- int test( const Mat& mat1, const Mat& mat2 )\r
- {\r
- if (mat1.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\tUnsupported type\t");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::Mat cpuX, cpuY;\r
- cv::polarToCart(mat1, mat2, cpuX, cpuY);\r
-\r
- GpuMat gpu1(mat1);\r
- GpuMat gpu2(mat2);\r
- GpuMat gpuX, gpuY;\r
- cv::gpu::polarToCart(gpu1, gpu2, gpuX, gpuY);\r
-\r
- int xRes = CheckNorm(cpuX, gpuX);\r
- int yRes = CheckNorm(cpuY, gpuY);\r
-\r
- return xRes == CvTS::OK && yRes == CvTS::OK ? CvTS::OK : CvTS::FAIL_GENERIC;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Min max\r
-\r
-struct CV_GpuMinMaxTest: public CvTest\r
-{\r
- CV_GpuMinMaxTest(): CvTest("GPU-MinMaxTest", "minMax") {}\r
-\r
- cv::gpu::GpuMat buf;\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- int depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (int depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- for (int i = 0; i < 3; ++i)\r
- {\r
- int rows = 1 + rand() % 1000;\r
- int cols = 1 + rand() % 1000;\r
- test(rows, cols, 1, depth);\r
- test_masked(rows, cols, 1, depth);\r
- }\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void test(int rows, int cols, int cn, int depth)\r
- {\r
- cv::Mat src(rows, cols, CV_MAKE_TYPE(depth, cn));\r
- cv::RNG rng(*ts->get_rng());\r
- rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-\r
- double minVal, maxVal;\r
- cv::Point minLoc, maxLoc;\r
-\r
- if (depth != CV_8S)\r
- {\r
- cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc);\r
- }\r
- else \r
- {\r
- minVal = std::numeric_limits<double>::max();\r
- maxVal = -std::numeric_limits<double>::max();\r
- for (int i = 0; i < src.rows; ++i)\r
- for (int j = 0; j < src.cols; ++j)\r
- {\r
- signed char val = src.at<signed char>(i, j);\r
- if (val < minVal) minVal = val;\r
- if (val > maxVal) maxVal = val;\r
- }\r
- }\r
-\r
- double minVal_, maxVal_;\r
- cv::gpu::minMax(cv::gpu::GpuMat(src), &minVal_, &maxVal_, cv::gpu::GpuMat(), buf);\r
- \r
- if (abs(minVal - minVal_) > 1e-3f)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nfail: minVal=%f minVal_=%f rows=%d cols=%d depth=%d cn=%d\n", minVal, minVal_, rows, cols, depth, cn);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- if (abs(maxVal - maxVal_) > 1e-3f)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nfail: maxVal=%f maxVal_=%f rows=%d cols=%d depth=%d cn=%d\n", maxVal, maxVal_, rows, cols, depth, cn);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- } \r
-\r
- void test_masked(int rows, int cols, int cn, int depth)\r
- {\r
- cv::Mat src(rows, cols, CV_MAKE_TYPE(depth, cn));\r
- cv::RNG rng(*ts->get_rng());\r
- rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-\r
- cv::Mat mask(src.size(), CV_8U);\r
- rng.fill(mask, RNG::UNIFORM, Scalar(0), Scalar(2));\r
-\r
- double minVal, maxVal;\r
- cv::Point minLoc, maxLoc;\r
-\r
- Mat src_ = src.reshape(1);\r
- if (depth != CV_8S)\r
- {\r
- cv::minMaxLoc(src_, &minVal, &maxVal, &minLoc, &maxLoc, mask);\r
- }\r
- else \r
- {\r
- // OpenCV's minMaxLoc doesn't support CV_8S type \r
- minVal = std::numeric_limits<double>::max();\r
- maxVal = -std::numeric_limits<double>::max();\r
- for (int i = 0; i < src_.rows; ++i)\r
- for (int j = 0; j < src_.cols; ++j)\r
- {\r
- char val = src_.at<char>(i, j);\r
- if (mask.at<unsigned char>(i, j)) { if (val < minVal) minVal = val; }\r
- if (mask.at<unsigned char>(i, j)) { if (val > maxVal) maxVal = val; }\r
- }\r
- }\r
-\r
- double minVal_, maxVal_;\r
- cv::Point minLoc_, maxLoc_; \r
- cv::gpu::minMax(cv::gpu::GpuMat(src), &minVal_, &maxVal_, cv::gpu::GpuMat(mask), buf);\r
- \r
- if (abs(minVal - minVal_) > 1e-3f)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nfail: minVal=%f minVal_=%f rows=%d cols=%d depth=%d cn=%d\n", minVal, minVal_, rows, cols, depth, cn);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- if (abs(maxVal - maxVal_) > 1e-3f)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nfail: maxVal=%f maxVal_=%f rows=%d cols=%d depth=%d cn=%d\n", maxVal, maxVal_, rows, cols, depth, cn);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- } \r
-};\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Min max loc\r
-\r
-struct CV_GpuMinMaxLocTest: public CvTest\r
-{\r
- CV_GpuMinMaxLocTest(): CvTest("GPU-MinMaxLocTest", "minMaxLoc") {}\r
-\r
- GpuMat valbuf, locbuf;\r
-\r
- void run(int)\r
- {\r
- try \r
- {\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- int depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (int depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- int rows = 1, cols = 3;\r
- test(rows, cols, depth);\r
- for (int i = 0; i < 4; ++i)\r
- {\r
- int rows = 1 + rand() % 1000;\r
- int cols = 1 + rand() % 1000;\r
- test(rows, cols, depth);\r
- }\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void test(int rows, int cols, int depth)\r
- {\r
- cv::Mat src(rows, cols, depth);\r
- cv::RNG rng(*ts->get_rng());\r
- rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(255));\r
-\r
- cv::Mat mask(src.size(), CV_8U);\r
- rng.fill(mask, RNG::UNIFORM, Scalar(0), Scalar(2));\r
-\r
- // At least one of the mask elements must be non zero as OpenCV returns 0\r
- // in such case, when our implementation returns maximum or minimum value\r
- mask.at<unsigned char>(0, 0) = 1;\r
-\r
- double minVal, maxVal;\r
- cv::Point minLoc, maxLoc;\r
-\r
- if (depth != CV_8S) \r
- cv::minMaxLoc(src, &minVal, &maxVal, &minLoc, &maxLoc, mask);\r
- else \r
- {\r
- // OpenCV's minMaxLoc doesn't support CV_8S type \r
- minVal = std::numeric_limits<double>::max();\r
- maxVal = -std::numeric_limits<double>::max();\r
- for (int i = 0; i < src.rows; ++i)\r
- for (int j = 0; j < src.cols; ++j)\r
- {\r
- char val = src.at<char>(i, j);\r
- if (mask.at<unsigned char>(i, j))\r
- {\r
- if (val < minVal) { minVal = val; minLoc = cv::Point(j, i); }\r
- if (val > maxVal) { maxVal = val; maxLoc = cv::Point(j, i); }\r
- }\r
- }\r
- }\r
-\r
- double minVal_, maxVal_;\r
- cv::Point minLoc_, maxLoc_; \r
- cv::gpu::minMaxLoc(cv::gpu::GpuMat(src), &minVal_, &maxVal_, &minLoc_, &maxLoc_, cv::gpu::GpuMat(mask), valbuf, locbuf);\r
-\r
- CHECK(minVal == minVal_, CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(maxVal == maxVal_, CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(0 == memcmp(src.ptr(minLoc.y) + minLoc.x * src.elemSize(), src.ptr(minLoc_.y) + minLoc_.x * src.elemSize(), src.elemSize()), \r
- CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(0 == memcmp(src.ptr(maxLoc.y) + maxLoc.x * src.elemSize(), src.ptr(maxLoc_.y) + maxLoc_.x * src.elemSize(), src.elemSize()), \r
- CvTS::FAIL_INVALID_OUTPUT);\r
- } \r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////\r
-// Count non zero\r
-struct CV_GpuCountNonZeroTest: CvTest \r
-{\r
- CV_GpuCountNonZeroTest(): CvTest("GPU-CountNonZeroTest", "countNonZero") {}\r
-\r
- void run(int) \r
- {\r
- try\r
- {\r
- int depth_end;\r
- if (cv::gpu::DeviceInfo().supports(cv::gpu::NATIVE_DOUBLE)) \r
- depth_end = CV_64F; \r
- else \r
- depth_end = CV_32F;\r
- for (int depth = CV_8U; depth <= CV_32F; ++depth)\r
- {\r
- for (int i = 0; i < 4; ++i)\r
- {\r
- int rows = 1 + rand() % 1000;\r
- int cols = 1 + rand() % 1000;\r
- test(rows, cols, depth);\r
- }\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void test(int rows, int cols, int depth)\r
- {\r
- cv::Mat src(rows, cols, depth);\r
- cv::RNG rng;\r
- if (depth == 5)\r
- rng.fill(src, RNG::UNIFORM, Scalar(-1000.f), Scalar(1000.f));\r
- else if (depth == 6)\r
- rng.fill(src, RNG::UNIFORM, Scalar(-1000.), Scalar(1000.));\r
- else\r
- for (int i = 0; i < src.rows; ++i)\r
- { \r
- Mat row(1, src.cols * src.elemSize(), CV_8U, src.ptr(i));\r
- rng.fill(row, RNG::UNIFORM, Scalar(0), Scalar(256));\r
- }\r
-\r
- int n_gold = cv::countNonZero(src);\r
- int n = cv::gpu::countNonZero(cv::gpu::GpuMat(src));\r
-\r
- if (n != n_gold)\r
- {\r
- ts->printf(CvTS::LOG, "%d %d %d %d %d\n", n, n_gold, depth, cols, rows);\r
- n_gold = cv::countNonZero(src);\r
- }\r
-\r
- CHECK(n == n_gold, CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
-};\r
-\r
-\r
-//////////////////////////////////////////////////////////////////////////////\r
-// sum\r
-\r
-struct CV_GpuSumTest: CvTest \r
-{\r
- CV_GpuSumTest(): CvTest("GPU-SumTest", "sum") {}\r
-\r
- void run(int) \r
- {\r
- try\r
- {\r
- Mat src;\r
- Scalar a, b;\r
- double max_err = 1e-5;\r
-\r
- int typemax = CV_32F;\r
- for (int type = CV_8U; type <= typemax; ++type) \r
- {\r
- //\r
- // sum\r
- //\r
-\r
- gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 1), src);\r
- a = sum(src);\r
- b = sum(GpuMat(src));\r
- if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "1 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 2), src);\r
- a = sum(src);\r
- b = sum(GpuMat(src));\r
- if (abs(a[0] - b[0]) + abs(a[1] - b[1]) > src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "2 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[1], b[1]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 3), src);\r
- a = sum(src);\r
- b = sum(GpuMat(src));\r
- if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2])> src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "3 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[2], b[2]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- gen(1 + rand() % 500, 1 + rand() % 500, CV_MAKETYPE(type, 4), src);\r
- a = sum(src);\r
- b = sum(GpuMat(src));\r
- if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2]) + abs(a[3] - b[3])> src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "4 cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[3], b[3]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- gen(1 + rand() % 500, 1 + rand() % 500, type, src);\r
- a = sum(src);\r
- b = sum(GpuMat(src));\r
- if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "cols: %d, rows: %d, expected: %f, actual: %f\n", src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- //\r
- // absSum\r
- //\r
-\r
- gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 1), src);\r
- b = absSum(GpuMat(src));\r
- a = norm(src, NORM_L1);\r
- if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- //\r
- // sqrSum\r
- //\r
-\r
- if (type != CV_8S)\r
- {\r
- gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 1), src);\r
- b = sqrSum(GpuMat(src));\r
- Mat sqrsrc;\r
- multiply(src, src, sqrsrc);\r
- a = sum(sqrsrc);\r
- if (abs(a[0] - b[0]) > src.size().area() * max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 2), src);\r
- b = sqrSum(GpuMat(src));\r
- multiply(src, src, sqrsrc);\r
- a = sum(sqrsrc);\r
- if (abs(a[0] - b[0]) + abs(a[1] - b[1])> src.size().area() * max_err * 2)\r
- {\r
- ts->printf(CvTS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 3), src);\r
- b = sqrSum(GpuMat(src));\r
- multiply(src, src, sqrsrc);\r
- a = sum(sqrsrc);\r
- if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2])> src.size().area() * max_err * 3)\r
- {\r
- ts->printf(CvTS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- gen(1 + rand() % 200, 1 + rand() % 200, CV_MAKETYPE(type, 4), src);\r
- b = sqrSum(GpuMat(src));\r
- multiply(src, src, sqrsrc);\r
- a = sum(sqrsrc);\r
- if (abs(a[0] - b[0]) + abs(a[1] - b[1]) + abs(a[2] - b[2]) + abs(a[3] - b[3])> src.size().area() * max_err * 4)\r
- {\r
- ts->printf(CvTS::CONSOLE, "type: %d, cols: %d, rows: %d, expected: %f, actual: %f\n", type, src.cols, src.rows, a[0], b[0]);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void gen(int cols, int rows, int type, Mat& m)\r
- {\r
- m.create(rows, cols, type);\r
- RNG rng;\r
- rng.fill(m, RNG::UNIFORM, Scalar::all(0), Scalar::all(16));\r
-\r
- }\r
-};\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-/////////////////// tests registration /////////////////////////////////////\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-// If we comment some tests, we may foget/miss to uncomment it after.\r
-// Placing all test definitions in one place\r
-// makes us know about what tests are commented.\r
-\r
-CV_GpuNppImageAddTest CV_GpuNppImageAdd_test;\r
-CV_GpuNppImageSubtractTest CV_GpuNppImageSubtract_test;\r
-CV_GpuNppImageMultiplyTest CV_GpuNppImageMultiply_test;\r
-CV_GpuNppImageDivideTest CV_GpuNppImageDivide_test;\r
-CV_GpuNppImageTransposeTest CV_GpuNppImageTranspose_test;\r
-CV_GpuNppImageAbsdiffTest CV_GpuNppImageAbsdiff_test;\r
-CV_GpuNppImageCompareTest CV_GpuNppImageCompare_test;\r
-CV_GpuNppImageMeanStdDevTest CV_GpuNppImageMeanStdDev_test;\r
-CV_GpuNppImageNormTest CV_GpuNppImageNorm_test;\r
-CV_GpuNppImageFlipTest CV_GpuNppImageFlip_test;\r
-CV_GpuNppImageLUTTest CV_GpuNppImageLUT_test;\r
-CV_GpuNppImageExpTest CV_GpuNppImageExp_test;\r
-CV_GpuNppImageLogTest CV_GpuNppImageLog_test;\r
-CV_GpuNppImageMagnitudeTest CV_GpuNppImageMagnitude_test;\r
-CV_GpuNppImagePhaseTest CV_GpuNppImagePhase_test;\r
-CV_GpuNppImageCartToPolarTest CV_GpuNppImageCartToPolar_test;\r
-CV_GpuNppImagePolarToCartTest CV_GpuNppImagePolarToCart_test;\r
-CV_GpuMinMaxTest CV_GpuMinMaxTest_test;\r
-CV_GpuMinMaxLocTest CV_GpuMinMaxLocTest_test;\r
-CV_GpuCountNonZeroTest CV_CountNonZero_test;\r
-CV_GpuSumTest CV_GpuSum_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <limits>\r
-#include "gputest.hpp"\r
-\r
-#define CHECK(pred, err) if (!(pred)) { \\r
- ts->printf(CvTS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \\r
- ts->set_failed_test_info(err); \\r
- return; }\r
-\r
-using namespace cv;\r
-using namespace std;\r
-\r
-struct CV_GpuBitwiseTest: public CvTest\r
-{\r
- CV_GpuBitwiseTest(): CvTest("GPU-BitwiseOpersTest", "bitwiseMatOperators") {}\r
-\r
- void run(int)\r
- {\r
- int rows, cols;\r
-\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- int depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (int depth = CV_8U; depth <= depth_end; ++depth)\r
- for (int cn = 1; cn <= 4; ++cn)\r
- for (int attempt = 0; attempt < 3; ++attempt)\r
- {\r
- rows = 1 + rand() % 100;\r
- cols = 1 + rand() % 100;\r
- test_bitwise_not(rows, cols, CV_MAKETYPE(depth, cn));\r
- test_bitwise_or(rows, cols, CV_MAKETYPE(depth, cn));\r
- test_bitwise_and(rows, cols, CV_MAKETYPE(depth, cn));\r
- test_bitwise_xor(rows, cols, CV_MAKETYPE(depth, cn));\r
- }\r
- }\r
-\r
- void test_bitwise_not(int rows, int cols, int type)\r
- {\r
- Mat src(rows, cols, type);\r
-\r
- RNG rng;\r
- for (int i = 0; i < src.rows; ++i)\r
- {\r
- Mat row(1, src.cols * src.elemSize(), CV_8U, src.ptr(i));\r
- rng.fill(row, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- }\r
-\r
- Mat dst_gold = ~src;\r
-\r
- gpu::GpuMat mask(src.size(), CV_8U);\r
- mask.setTo(Scalar(1));\r
-\r
- gpu::GpuMat dst;\r
- gpu::bitwise_not(gpu::GpuMat(src), dst);\r
-\r
- CHECK(dst_gold.size() == dst.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold.type() == dst.type(), CvTS::FAIL_INVALID_OUTPUT); \r
-\r
- Mat dsth(dst);\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT);\r
-\r
- dst.setTo(Scalar::all(0));\r
- gpu::bitwise_not(gpu::GpuMat(src), dst, mask);\r
-\r
- CHECK(dst_gold.size() == dst.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold.type() == dst.type(), CvTS::FAIL_INVALID_OUTPUT); \r
-\r
- dsth = dst;\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
- }\r
-\r
- void test_bitwise_or(int rows, int cols, int type)\r
- {\r
- Mat src1(rows, cols, type);\r
- Mat src2(rows, cols, type);\r
-\r
- RNG rng;\r
- for (int i = 0; i < src1.rows; ++i)\r
- {\r
- Mat row1(1, src1.cols * src1.elemSize(), CV_8U, src1.ptr(i));\r
- rng.fill(row1, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- Mat row2(1, src2.cols * src2.elemSize(), CV_8U, src2.ptr(i));\r
- rng.fill(row2, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- }\r
-\r
- Mat dst_gold = src1 | src2;\r
- gpu::GpuMat dst = gpu::GpuMat(src1) | gpu::GpuMat(src2);\r
-\r
- CHECK(dst_gold.size() == dst.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold.type() == dst.type(), CvTS::FAIL_INVALID_OUTPUT); \r
- Mat dsth(dst);\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
-\r
- Mat mask(src1.size(), CV_8U);\r
- randu(mask, Scalar(0), Scalar(255));\r
-\r
- Mat dst_gold2(dst_gold.size(), dst_gold.type()); dst_gold2.setTo(Scalar::all(0));\r
- gpu::GpuMat dst2(dst.size(), dst.type()); dst2.setTo(Scalar::all(0));\r
- bitwise_or(src1, src2, dst_gold2, mask);\r
- gpu::bitwise_or(gpu::GpuMat(src1), gpu::GpuMat(src2), dst2, gpu::GpuMat(mask));\r
-\r
- CHECK(dst_gold2.size() == dst2.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold2.type() == dst2.type(), CvTS::FAIL_INVALID_OUTPUT); \r
- dsth = dst2;\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold2.ptr(i), dsth.ptr(i), dst_gold2.cols * dst_gold2.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
- }\r
-\r
- void test_bitwise_and(int rows, int cols, int type)\r
- {\r
- Mat src1(rows, cols, type);\r
- Mat src2(rows, cols, type);\r
-\r
- RNG rng;\r
- for (int i = 0; i < src1.rows; ++i)\r
- {\r
- Mat row1(1, src1.cols * src1.elemSize(), CV_8U, src1.ptr(i));\r
- rng.fill(row1, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- Mat row2(1, src2.cols * src2.elemSize(), CV_8U, src2.ptr(i));\r
- rng.fill(row2, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- }\r
-\r
- Mat dst_gold = src1 & src2;\r
-\r
- gpu::GpuMat dst = gpu::GpuMat(src1) & gpu::GpuMat(src2);\r
-\r
- CHECK(dst_gold.size() == dst.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold.type() == dst.type(), CvTS::FAIL_INVALID_OUTPUT); \r
- Mat dsth(dst);\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
-\r
-\r
- Mat mask(src1.size(), CV_8U);\r
- randu(mask, Scalar(0), Scalar(255));\r
-\r
- Mat dst_gold2(dst_gold.size(), dst_gold.type()); dst_gold2.setTo(Scalar::all(0));\r
- gpu::GpuMat dst2(dst.size(), dst.type()); dst2.setTo(Scalar::all(0));\r
- bitwise_and(src1, src2, dst_gold2, mask);\r
- gpu::bitwise_and(gpu::GpuMat(src1), gpu::GpuMat(src2), dst2, gpu::GpuMat(mask));\r
-\r
- CHECK(dst_gold2.size() == dst2.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold2.type() == dst2.type(), CvTS::FAIL_INVALID_OUTPUT); \r
- dsth = dst2;\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold2.ptr(i), dsth.ptr(i), dst_gold2.cols * dst_gold2.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
- }\r
-\r
- void test_bitwise_xor(int rows, int cols, int type)\r
- {\r
- Mat src1(rows, cols, type);\r
- Mat src2(rows, cols, type);\r
-\r
- RNG rng;\r
- for (int i = 0; i < src1.rows; ++i)\r
- {\r
- Mat row1(1, src1.cols * src1.elemSize(), CV_8U, src1.ptr(i));\r
- rng.fill(row1, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- Mat row2(1, src2.cols * src2.elemSize(), CV_8U, src2.ptr(i));\r
- rng.fill(row2, RNG::UNIFORM, Scalar(0), Scalar(255));\r
- }\r
-\r
- Mat dst_gold = src1 ^ src2;\r
-\r
- gpu::GpuMat dst = gpu::GpuMat(src1) ^ gpu::GpuMat(src2);\r
-\r
- CHECK(dst_gold.size() == dst.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold.type() == dst.type(), CvTS::FAIL_INVALID_OUTPUT); \r
- Mat dsth(dst);\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold.ptr(i), dsth.ptr(i), dst_gold.cols * dst_gold.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
-\r
-\r
- Mat mask(src1.size(), CV_8U);\r
- randu(mask, Scalar(0), Scalar(255));\r
-\r
- Mat dst_gold2(dst_gold.size(), dst_gold.type()); dst_gold2.setTo(Scalar::all(0));\r
- gpu::GpuMat dst2(dst.size(), dst.type()); dst2.setTo(Scalar::all(0));\r
- bitwise_xor(src1, src2, dst_gold2, mask);\r
- gpu::bitwise_xor(gpu::GpuMat(src1), gpu::GpuMat(src2), dst2, gpu::GpuMat(mask));\r
-\r
- CHECK(dst_gold2.size() == dst2.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(dst_gold2.type() == dst2.type(), CvTS::FAIL_INVALID_OUTPUT); \r
- dsth = dst2;\r
- for (int i = 0; i < dst_gold.rows; ++i) \r
- CHECK(memcmp(dst_gold2.ptr(i), dsth.ptr(i), dst_gold2.cols * dst_gold2.elemSize()) == 0, CvTS::FAIL_INVALID_OUTPUT)\r
- }\r
-} gpu_bitwise_test;\r
-\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-#include <algorithm>\r
-#include <iterator>\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-class CV_GpuBruteForceMatcherTest : public CvTest\r
-{\r
-public:\r
- CV_GpuBruteForceMatcherTest() :\r
- CvTest( "GPU-BruteForceMatcher", "BruteForceMatcher" )\r
- {\r
- }\r
-\r
-protected:\r
- virtual void run(int);\r
- \r
- void emptyDataTest();\r
- void dataTest(int dim);\r
- \r
- void generateData(GpuMat& query, GpuMat& train, int dim);\r
-\r
- void matchTest(const GpuMat& query, const GpuMat& train);\r
- void knnMatchTest(const GpuMat& query, const GpuMat& train);\r
- void radiusMatchTest(const GpuMat& query, const GpuMat& train);\r
-\r
-private:\r
- BruteForceMatcher_GPU< L2<float> > dmatcher;\r
-\r
- static const int queryDescCount = 300; // must be even number because we split train data in some cases in two\r
- static const int countFactor = 4; // do not change it\r
-};\r
-\r
-void CV_GpuBruteForceMatcherTest::emptyDataTest()\r
-{\r
- GpuMat queryDescriptors, trainDescriptors, mask;\r
- vector<GpuMat> trainDescriptorCollection, masks;\r
- vector<DMatch> matches;\r
- vector< vector<DMatch> > vmatches;\r
-\r
- try\r
- {\r
- dmatcher.match(queryDescriptors, trainDescriptors, matches, mask);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "match() on empty descriptors must not generate exception (1).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- try\r
- {\r
- dmatcher.knnMatch(queryDescriptors, trainDescriptors, vmatches, 2, mask);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "knnMatch() on empty descriptors must not generate exception (1).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- try\r
- {\r
- dmatcher.radiusMatch(queryDescriptors, trainDescriptors, vmatches, 10.f, mask);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "radiusMatch() on empty descriptors must not generate exception (1).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- try\r
- {\r
- dmatcher.add(trainDescriptorCollection);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "add() on empty descriptors must not generate exception.\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- try\r
- {\r
- dmatcher.match(queryDescriptors, matches, masks);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "match() on empty descriptors must not generate exception (2).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- try\r
- {\r
- dmatcher.knnMatch(queryDescriptors, vmatches, 2, masks);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "knnMatch() on empty descriptors must not generate exception (2).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- try\r
- {\r
- dmatcher.radiusMatch( queryDescriptors, vmatches, 10.f, masks );\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "radiusMatch() on empty descriptors must not generate exception (2).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::generateData( GpuMat& queryGPU, GpuMat& trainGPU, int dim )\r
-{\r
- Mat query, train;\r
- RNG rng(*ts->get_rng());\r
-\r
- // Generate query descriptors randomly.\r
- // Descriptor vector elements are integer values.\r
- Mat buf( queryDescCount, dim, CV_32SC1 );\r
- rng.fill( buf, RNG::UNIFORM, Scalar::all(0), Scalar(3) );\r
- buf.convertTo( query, CV_32FC1 );\r
-\r
- // Generate train decriptors as follows:\r
- // copy each query descriptor to train set countFactor times\r
- // and perturb some one element of the copied descriptors in\r
- // in ascending order. General boundaries of the perturbation\r
- // are (0.f, 1.f).\r
- train.create( query.rows*countFactor, query.cols, CV_32FC1 );\r
- float step = 1.f / countFactor;\r
- for( int qIdx = 0; qIdx < query.rows; qIdx++ )\r
- {\r
- Mat queryDescriptor = query.row(qIdx);\r
- for( int c = 0; c < countFactor; c++ )\r
- {\r
- int tIdx = qIdx * countFactor + c;\r
- Mat trainDescriptor = train.row(tIdx);\r
- queryDescriptor.copyTo( trainDescriptor );\r
- int elem = rng(dim);\r
- float diff = rng.uniform( step*c, step*(c+1) );\r
- trainDescriptor.at<float>(0, elem) += diff;\r
- }\r
- }\r
-\r
- queryGPU.upload(query);\r
- trainGPU.upload(train);\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::matchTest( const GpuMat& query, const GpuMat& train )\r
-{\r
- dmatcher.clear();\r
-\r
- // test const version of match()\r
- {\r
- vector<DMatch> matches;\r
- dmatcher.match( query, train, matches );\r
-\r
- if( (int)matches.size() != queryDescCount )\r
- {\r
- ts->printf(CvTS::LOG, "Incorrect matches count while test match() function (1).\n");\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- else\r
- {\r
- int badCount = 0;\r
- for( size_t i = 0; i < matches.size(); i++ )\r
- {\r
- DMatch match = matches[i];\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )\r
- badCount++;\r
- }\r
- if (badCount > 0)\r
- {\r
- ts->printf( CvTS::LOG, "%f - too large bad matches part while test match() function (1).\n",\r
- (float)badCount/(float)queryDescCount );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- }\r
- }\r
-\r
- // test version of match() with add()\r
- {\r
- vector<DMatch> matches;\r
- // make add() twice to test such case\r
- dmatcher.add( vector<GpuMat>(1,train.rowRange(0, train.rows/2)) );\r
- dmatcher.add( vector<GpuMat>(1,train.rowRange(train.rows/2, train.rows)) );\r
- // prepare masks (make first nearest match illegal)\r
- vector<GpuMat> masks(2);\r
- for(int mi = 0; mi < 2; mi++ )\r
- {\r
- masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
- for( int di = 0; di < queryDescCount/2; di++ )\r
- masks[mi].col(di*countFactor).setTo(Scalar::all(0));\r
- }\r
-\r
- dmatcher.match( query, matches, masks );\r
-\r
- if( (int)matches.size() != queryDescCount )\r
- {\r
- ts->printf(CvTS::LOG, "Incorrect matches count while test match() function (2).\n");\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- else\r
- {\r
- int badCount = 0;\r
- for( size_t i = 0; i < matches.size(); i++ )\r
- {\r
- DMatch match = matches[i];\r
- int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
- {\r
- if( i < queryDescCount/2 )\r
- {\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor + shift) || (match.imgIdx != 0) )\r
- badCount++;\r
- }\r
- else\r
- {\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != ((int)i-queryDescCount/2)*countFactor + shift) || (match.imgIdx != 1) )\r
- badCount++;\r
- }\r
- }\r
- }\r
- if (badCount > 0)\r
- {\r
- ts->printf( CvTS::LOG, "%f - too large bad matches part while test match() function (2).\n",\r
- (float)badCount/(float)queryDescCount );\r
- ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );\r
- }\r
- }\r
- }\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::knnMatchTest( const GpuMat& query, const GpuMat& train )\r
-{\r
- dmatcher.clear();\r
-\r
- // test const version of knnMatch()\r
- {\r
- const int knn = 3;\r
-\r
- vector< vector<DMatch> > matches;\r
- dmatcher.knnMatch( query, train, matches, knn );\r
-\r
- if( (int)matches.size() != queryDescCount )\r
- {\r
- ts->printf(CvTS::LOG, "Incorrect matches count while test knnMatch() function (1).\n");\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- else\r
- {\r
- int badCount = 0;\r
- for( size_t i = 0; i < matches.size(); i++ )\r
- {\r
- if( (int)matches[i].size() != knn )\r
- badCount++;\r
- else\r
- {\r
- int localBadCount = 0;\r
- for( int k = 0; k < knn; k++ )\r
- {\r
- DMatch match = matches[i][k];\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor+k) || (match.imgIdx != 0) )\r
- localBadCount++;\r
- }\r
- badCount += localBadCount > 0 ? 1 : 0;\r
- }\r
- }\r
- if (badCount > 0)\r
- {\r
- ts->printf( CvTS::LOG, "%f - too large bad matches part while test knnMatch() function (1).\n",\r
- (float)badCount/(float)queryDescCount );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- }\r
- }\r
-\r
- // test version of knnMatch() with add()\r
- {\r
- const int knn = 2;\r
- vector<vector<DMatch> > matches;\r
- // make add() twice to test such case\r
- dmatcher.add( vector<GpuMat>(1,train.rowRange(0, train.rows/2)) );\r
- dmatcher.add( vector<GpuMat>(1,train.rowRange(train.rows/2, train.rows)) );\r
- // prepare masks (make first nearest match illegal)\r
- vector<GpuMat> masks(2);\r
- for(int mi = 0; mi < 2; mi++ )\r
- {\r
- masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
- for( int di = 0; di < queryDescCount/2; di++ )\r
- masks[mi].col(di*countFactor).setTo(Scalar::all(0));\r
- }\r
-\r
- dmatcher.knnMatch( query, matches, knn, masks );\r
-\r
- if( (int)matches.size() != queryDescCount )\r
- {\r
- ts->printf(CvTS::LOG, "Incorrect matches count while test knnMatch() function (2).\n");\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- else\r
- {\r
- int badCount = 0;\r
- int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
- for( size_t i = 0; i < matches.size(); i++ )\r
- {\r
- if( (int)matches[i].size() != knn )\r
- badCount++;\r
- else\r
- {\r
- int localBadCount = 0;\r
- for( int k = 0; k < knn; k++ )\r
- {\r
- DMatch match = matches[i][k];\r
- {\r
- if( i < queryDescCount/2 )\r
- {\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor + k + shift) ||\r
- (match.imgIdx != 0) )\r
- localBadCount++;\r
- }\r
- else\r
- {\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != ((int)i-queryDescCount/2)*countFactor + k + shift) ||\r
- (match.imgIdx != 1) )\r
- localBadCount++;\r
- }\r
- }\r
- }\r
- badCount += localBadCount > 0 ? 1 : 0;\r
- }\r
- }\r
- if (badCount > 0)\r
- {\r
- ts->printf( CvTS::LOG, "%f - too large bad matches part while test knnMatch() function (2).\n",\r
- (float)badCount/(float)queryDescCount );\r
- ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );\r
- }\r
- }\r
- }\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::radiusMatchTest( const GpuMat& query, const GpuMat& train )\r
-{\r
- bool atomics_ok = TargetArchs::builtWith(GLOBAL_ATOMICS) && DeviceInfo().supports(GLOBAL_ATOMICS);\r
- if (!atomics_ok)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nCode and device atomics support is required for radiusMatch (CC >= 1.1)");\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- dmatcher.clear();\r
- // test const version of match()\r
- {\r
- const float radius = 1.f/countFactor;\r
- vector< vector<DMatch> > matches;\r
- dmatcher.radiusMatch( query, train, matches, radius );\r
-\r
- if( (int)matches.size() != queryDescCount )\r
- {\r
- ts->printf(CvTS::LOG, "Incorrect matches count while test radiusMatch() function (1).\n");\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- else\r
- {\r
- int badCount = 0;\r
- for( size_t i = 0; i < matches.size(); i++ )\r
- {\r
- if( (int)matches[i].size() != 1 )\r
- badCount++;\r
- else\r
- {\r
- DMatch match = matches[i][0];\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor) || (match.imgIdx != 0) )\r
- badCount++;\r
- }\r
- }\r
- if (badCount > 0)\r
- {\r
- ts->printf( CvTS::LOG, "%f - too large bad matches part while test radiusMatch() function (1).\n",\r
- (float)badCount/(float)queryDescCount );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
- }\r
- }\r
-\r
- // test version of match() with add()\r
- {\r
- int n = 3;\r
- const float radius = 1.f/countFactor * n;\r
- vector< vector<DMatch> > matches;\r
- // make add() twice to test such case\r
- dmatcher.add( vector<GpuMat>(1,train.rowRange(0, train.rows/2)) );\r
- dmatcher.add( vector<GpuMat>(1,train.rowRange(train.rows/2, train.rows)) );\r
- // prepare masks (make first nearest match illegal)\r
- vector<GpuMat> masks(2);\r
- for(int mi = 0; mi < 2; mi++ )\r
- {\r
- masks[mi] = GpuMat(query.rows, train.rows/2, CV_8UC1, Scalar::all(1));\r
- for( int di = 0; di < queryDescCount/2; di++ )\r
- masks[mi].col(di*countFactor).setTo(Scalar::all(0));\r
- }\r
-\r
- dmatcher.radiusMatch( query, matches, radius, masks );\r
-\r
- int curRes = CvTS::OK;\r
- if( (int)matches.size() != queryDescCount )\r
- {\r
- ts->printf(CvTS::LOG, "Incorrect matches count while test radiusMatch() function (1).\n");\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- int badCount = 0;\r
- int shift = dmatcher.isMaskSupported() ? 1 : 0;\r
- int needMatchCount = dmatcher.isMaskSupported() ? n-1 : n;\r
- for( size_t i = 0; i < matches.size(); i++ )\r
- {\r
- if( (int)matches[i].size() != needMatchCount )\r
- badCount++;\r
- else\r
- {\r
- int localBadCount = 0;\r
- for( int k = 0; k < needMatchCount; k++ )\r
- {\r
- DMatch match = matches[i][k];\r
- {\r
- if( i < queryDescCount/2 )\r
- {\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != (int)i*countFactor + k + shift) ||\r
- (match.imgIdx != 0) )\r
- localBadCount++;\r
- }\r
- else\r
- {\r
- if( (match.queryIdx != (int)i) || (match.trainIdx != ((int)i-queryDescCount/2)*countFactor + k + shift) ||\r
- (match.imgIdx != 1) )\r
- localBadCount++;\r
- }\r
- }\r
- }\r
- badCount += localBadCount > 0 ? 1 : 0;\r
- }\r
- }\r
-\r
- if (badCount > 0)\r
- {\r
- curRes = CvTS::FAIL_INVALID_OUTPUT;\r
- ts->printf( CvTS::LOG, "%f - too large bad matches part while test radiusMatch() function (2).\n",\r
- (float)badCount/(float)queryDescCount );\r
- ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );\r
- }\r
- }\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::dataTest(int dim)\r
-{\r
- GpuMat query, train;\r
- generateData(query, train, dim);\r
-\r
- matchTest(query, train);\r
- knnMatchTest(query, train);\r
- radiusMatchTest(query, train);\r
-\r
- dmatcher.clear();\r
-}\r
-\r
-void CV_GpuBruteForceMatcherTest::run(int)\r
-{\r
- try\r
- {\r
- emptyDataTest();\r
-\r
- dataTest(50);\r
- dataTest(64);\r
- dataTest(100);\r
- dataTest(128);\r
- dataTest(200);\r
- dataTest(256);\r
- dataTest(300);\r
- }\r
- catch(cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw; \r
- return;\r
- }\r
-}\r
-\r
-CV_GpuBruteForceMatcherTest CV_GpuBruteForceMatcher_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-struct CV_GpuMulSpectrumsTest: CvTest\r
-{\r
- CV_GpuMulSpectrumsTest(): CvTest("GPU-MulSpectrumsTest", "mulSpectrums") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- test(0);\r
- testConj(0);\r
- testScaled(0);\r
- testScaledConj(0);\r
- test(DFT_ROWS);\r
- testConj(DFT_ROWS);\r
- testScaled(DFT_ROWS);\r
- testScaledConj(DFT_ROWS);\r
- }\r
- catch (const Exception& e)\r
- {\r
- ts->printf(CvTS::CONSOLE, e.what());\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void gen(int cols, int rows, Mat& mat)\r
- {\r
- RNG rng;\r
- mat.create(rows, cols, CV_32FC2);\r
- rng.fill(mat, RNG::UNIFORM, Scalar::all(0.f), Scalar::all(10.f));\r
- }\r
-\r
- bool cmp(const Mat& gold, const Mat& mine, float max_err=1e-3f)\r
- {\r
- if (gold.size() != mine.size())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad sizes: gold: %d d%, mine: %d %d\n", gold.cols, gold.rows, mine.cols, mine.rows);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- if (gold.type() != mine.type())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad types: gold=%d, mine=%d\n", gold.type(), mine.type());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- for (int i = 0; i < gold.rows; ++i)\r
- {\r
- for (int j = 0; j < gold.cols * 2; ++j)\r
- {\r
- float gold_ = gold.at<float>(i, j);\r
- float mine_ = mine.at<float>(i, j);\r
- if (fabs(gold_ - mine_) > max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad values at %d %d: gold=%f, mine=%f\n", j, i, gold_, mine_);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- bool cmpScaled(const Mat& gold, const Mat& mine, float scale, float max_err=1e-3f)\r
- {\r
- if (gold.size() != mine.size())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad sizes: gold: %d d%, mine: %d %d\n", gold.cols, gold.rows, mine.cols, mine.rows);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- if (gold.type() != mine.type())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad types: gold=%d, mine=%d\n", gold.type(), mine.type());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- for (int i = 0; i < gold.rows; ++i)\r
- {\r
- for (int j = 0; j < gold.cols * 2; ++j)\r
- {\r
- float gold_ = gold.at<float>(i, j) * scale;\r
- float mine_ = mine.at<float>(i, j);\r
- if (fabs(gold_ - mine_) > max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad values at %d %d: gold=%f, mine=%f\n", j, i, gold_, mine_);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- void test(int flags)\r
- {\r
- int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
- Mat a, b;\r
- gen(cols, rows, a);\r
- gen(cols, rows, b);\r
-\r
- Mat c_gold;\r
- mulSpectrums(a, b, c_gold, flags, false);\r
-\r
- GpuMat d_c;\r
- mulSpectrums(GpuMat(a), GpuMat(b), d_c, flags, false);\r
-\r
- if (!cmp(c_gold, Mat(d_c)))\r
- ts->printf(CvTS::CONSOLE, "test failed: cols=%d, rows=%d, flags=%d\n", cols, rows, flags);\r
- }\r
-\r
- void testConj(int flags)\r
- {\r
- int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
- Mat a, b;\r
- gen(cols, rows, a);\r
- gen(cols, rows, b);\r
-\r
- Mat c_gold;\r
- mulSpectrums(a, b, c_gold, flags, true);\r
-\r
- GpuMat d_c;\r
- mulSpectrums(GpuMat(a), GpuMat(b), d_c, flags, true);\r
-\r
- if (!cmp(c_gold, Mat(d_c)))\r
- ts->printf(CvTS::CONSOLE, "testConj failed: cols=%d, rows=%d, flags=%d\n", cols, rows, flags);\r
- }\r
-\r
- void testScaled(int flags)\r
- {\r
- int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
- Mat a, b;\r
- gen(cols, rows, a);\r
- gen(cols, rows, b);\r
- float scale = 1.f / a.size().area();\r
-\r
- Mat c_gold;\r
- mulSpectrums(a, b, c_gold, flags, false);\r
-\r
- GpuMat d_c;\r
- mulAndScaleSpectrums(GpuMat(a), GpuMat(b), d_c, flags, scale, false);\r
-\r
- if (!cmpScaled(c_gold, Mat(d_c), scale))\r
- ts->printf(CvTS::CONSOLE, "testScaled failed: cols=%d, rows=%d, flags=%d\n", cols, rows, flags);\r
- }\r
-\r
- void testScaledConj(int flags)\r
- {\r
- int cols = 1 + rand() % 100, rows = 1 + rand() % 1000;\r
-\r
- Mat a, b;\r
- gen(cols, rows, a);\r
- gen(cols, rows, b);\r
- float scale = 1.f / a.size().area();\r
-\r
- Mat c_gold;\r
- mulSpectrums(a, b, c_gold, flags, true);\r
-\r
- GpuMat d_c;\r
- mulAndScaleSpectrums(GpuMat(a), GpuMat(b), d_c, flags, scale, true);\r
-\r
- if (!cmpScaled(c_gold, Mat(d_c), scale))\r
- ts->printf(CvTS::CONSOLE, "testScaledConj failed: cols=%d, rows=%d, flags=%D\n", cols, rows, flags);\r
- }\r
-} CV_GpuMulSpectrumsTest_inst;\r
-\r
-\r
-struct CV_GpuDftTest: CvTest\r
-{\r
- CV_GpuDftTest(): CvTest("GPU-DftTest", "dft") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- srand(0);\r
- int cols = 2 + rand() % 100, rows = 2 + rand() % 100;\r
-\r
- for (int i = 0; i < 2; ++i)\r
- {\r
- bool inplace = i != 0;\r
- testC2C("no flags", cols, rows, 0, inplace);\r
- testC2C("no flags 0 1", cols, rows + 1, 0, inplace);\r
- testC2C("no flags 1 0", cols, rows + 1, 0, inplace);\r
- testC2C("no flags 1 1", cols + 1, rows, 0, inplace);\r
- testC2C("DFT_INVERSE", cols, rows, DFT_INVERSE, inplace);\r
- testC2C("DFT_ROWS", cols, rows, DFT_ROWS, inplace);\r
- testC2C("single col", 1, rows, 0, inplace);\r
- testC2C("single row", cols, 1, 0, inplace);\r
- testC2C("single col inversed", 1, rows, DFT_INVERSE, inplace);\r
- testC2C("single row inversed", cols, 1, DFT_INVERSE, inplace);\r
- testC2C("single row DFT_ROWS", cols, 1, DFT_ROWS, inplace);\r
- testC2C("size 1 2", 1, 2, 0, inplace);\r
- testC2C("size 2 1", 2, 1, 0, inplace);\r
- }\r
-\r
- testR2CThenC2R("sanity", cols, rows);\r
- testR2CThenC2R("sanity 0 1", cols, rows + 1);\r
- testR2CThenC2R("sanity 1 0", cols + 1, rows);\r
- testR2CThenC2R("sanity 1 1", cols + 1, rows + 1);\r
- testR2CThenC2R("single col", 1, rows);\r
- testR2CThenC2R("single col 1", 1, rows + 1);\r
- testR2CThenC2R("single row", cols, 1);\r
- testR2CThenC2R("single row 1", cols + 1, 1);\r
-\r
- testR2CThenC2R("sanity", cols, rows, true);\r
- testR2CThenC2R("sanity 0 1", cols, rows + 1, true);\r
- testR2CThenC2R("sanity 1 0", cols + 1, rows, true);\r
- testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);\r
- testR2CThenC2R("single row", cols, 1, true);\r
- testR2CThenC2R("single row 1", cols + 1, 1, true);\r
- }\r
- catch (const Exception& e)\r
- {\r
- ts->printf(CvTS::CONSOLE, e.what());\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void gen(int cols, int rows, int cn, Mat& mat)\r
- {\r
- RNG rng(1);\r
- mat.create(rows, cols, CV_MAKETYPE(CV_32F, cn));\r
- rng.fill(mat, RNG::UNIFORM, Scalar::all(0.f), Scalar::all(10.f));\r
- }\r
-\r
- bool cmp(const Mat& gold, const Mat& mine, float max_err=1e-3f)\r
- {\r
- if (gold.size() != mine.size())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad sizes: gold: %d %d, mine: %d %d\n", gold.cols, gold.rows, mine.cols, mine.rows);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- if (gold.depth() != mine.depth())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad depth: gold=%d, mine=%d\n", gold.depth(), mine.depth());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- if (gold.channels() != mine.channels())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad channel count: gold=%d, mine=%d\n", gold.channels(), mine.channels());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- for (int i = 0; i < gold.rows; ++i)\r
- {\r
- for (int j = 0; j < gold.cols * gold.channels(); ++j)\r
- {\r
- float gold_ = gold.at<float>(i, j);\r
- float mine_ = mine.at<float>(i, j);\r
- if (fabs(gold_ - mine_) > max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad values at %d %d: gold=%f, mine=%f\n", j / gold.channels(), i, gold_, mine_);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
- }\r
- }\r
- return true;\r
- }\r
-\r
- void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplace=false)\r
- {\r
- Mat a;\r
- gen(cols, rows, 2, a);\r
-\r
- Mat b_gold;\r
- dft(a, b_gold, flags);\r
-\r
- GpuMat d_b;\r
- GpuMat d_b_data;\r
- if (inplace)\r
- {\r
- d_b_data.create(1, a.size().area(), CV_32FC2);\r
- d_b = GpuMat(a.rows, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
- }\r
-\r
- dft(GpuMat(a), d_b, Size(cols, rows), flags);\r
-\r
- bool ok = true;\r
- if (ok && inplace && d_b.ptr() != d_b_data.ptr())\r
- {\r
- ts->printf(CvTS::CONSOLE, "unnecessary reallocation was done\n");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok && d_b.depth() != CV_32F)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad depth: %d\n", d_b.depth());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok && d_b.channels() != 2)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad channel count: %d\n", d_b.channels());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok) ok = cmp(b_gold, Mat(d_b), rows * cols * 1e-4f);\r
- if (!ok) \r
- ts->printf(CvTS::CONSOLE, "testC2C failed: hint=%s, cols=%d, rows=%d, flags=%d, inplace=%d\n", \r
- hint.c_str(), cols, rows, flags, inplace);\r
- }\r
-\r
- void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace=false)\r
- {\r
- Mat a;\r
- gen(cols, rows, 1, a);\r
-\r
- bool ok = true;\r
-\r
- GpuMat d_b, d_c;\r
- GpuMat d_b_data, d_c_data;\r
- if (inplace)\r
- {\r
- if (a.cols == 1)\r
- {\r
- d_b_data.create(1, (a.rows / 2 + 1) * a.cols, CV_32FC2);\r
- d_b = GpuMat(a.rows / 2 + 1, a.cols, CV_32FC2, d_b_data.ptr(), a.cols * d_b_data.elemSize());\r
- }\r
- else\r
- {\r
- d_b_data.create(1, a.rows * (a.cols / 2 + 1), CV_32FC2);\r
- d_b = GpuMat(a.rows, a.cols / 2 + 1, CV_32FC2, d_b_data.ptr(), (a.cols / 2 + 1) * d_b_data.elemSize());\r
- }\r
- d_c_data.create(1, a.size().area(), CV_32F);\r
- d_c = GpuMat(a.rows, a.cols, CV_32F, d_c_data.ptr(), a.cols * d_c_data.elemSize());\r
- }\r
-\r
- dft(GpuMat(a), d_b, Size(cols, rows), 0);\r
- dft(d_b, d_c, Size(cols, rows), DFT_REAL_OUTPUT | DFT_SCALE);\r
-\r
- if (ok && inplace && d_b.ptr() != d_b_data.ptr())\r
- {\r
- ts->printf(CvTS::CONSOLE, "unnecessary reallocation was done for b\n");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok && inplace && d_c.ptr() != d_c_data.ptr())\r
- {\r
- ts->printf(CvTS::CONSOLE, "unnecessary reallocation was done for c\n");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok && d_c.depth() != CV_32F)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad depth: %d\n", d_c.depth());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok && d_c.channels() != 1)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad channel count: %d\n", d_c.channels());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- ok = false;\r
- }\r
- if (ok) ok = cmp(a, Mat(d_c), rows * cols * 1e-5f);\r
- if (!ok) \r
- ts->printf(CvTS::CONSOLE, "testR2CThenC2R failed: hint=%s, cols=%d, rows=%d, inplace=%d\n", \r
- hint.c_str(), cols, rows, inplace);\r
- }\r
-} CV_GpuDftTest_inst;
\ No newline at end of file
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-#include <string>\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-const string FEATURES2D_DIR = "features2d";\r
-const string IMAGE_FILENAME = "aloe.png";\r
-const string VALID_FILE_NAME = "surf.xml.gz";\r
-\r
-class CV_GPU_SURFTest : public CvTest\r
-{\r
-public:\r
- CV_GPU_SURFTest() :\r
- CvTest( "GPU-SURF", "SURF_GPU") \r
- {\r
- }\r
-\r
-protected:\r
- bool isSimilarKeypoints(const KeyPoint& p1, const KeyPoint& p2);\r
- void compareKeypointSets(const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints,\r
- const Mat& validDescriptors, const Mat& calcDescriptors);\r
-\r
- void emptyDataTest(SURF_GPU& fdetector);\r
- void regressionTest(SURF_GPU& fdetector);\r
-\r
- virtual void run(int);\r
-};\r
-\r
-void CV_GPU_SURFTest::emptyDataTest(SURF_GPU& fdetector)\r
-{\r
- GpuMat image;\r
- vector<KeyPoint> keypoints;\r
- vector<float> descriptors;\r
- try\r
- {\r
- fdetector(image, GpuMat(), keypoints, descriptors);\r
- }\r
- catch(...)\r
- {\r
- ts->printf( CvTS::LOG, "detect() on empty image must not generate exception (1).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- }\r
-\r
- if( !keypoints.empty() )\r
- {\r
- ts->printf( CvTS::LOG, "detect() on empty image must return empty keypoints vector (1).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- return;\r
- }\r
-\r
- if( !descriptors.empty() )\r
- {\r
- ts->printf( CvTS::LOG, "detect() on empty image must return empty descriptors vector (1).\n" );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );\r
- return;\r
- }\r
-}\r
-\r
-bool CV_GPU_SURFTest::isSimilarKeypoints(const KeyPoint& p1, const KeyPoint& p2)\r
-{\r
- const float maxPtDif = 1.f;\r
- const float maxSizeDif = 1.f;\r
- const float maxAngleDif = 2.f;\r
- const float maxResponseDif = 0.1f;\r
-\r
- float dist = (float)norm( p1.pt - p2.pt );\r
- return (dist < maxPtDif &&\r
- fabs(p1.size - p2.size) < maxSizeDif &&\r
- abs(p1.angle - p2.angle) < maxAngleDif &&\r
- abs(p1.response - p2.response) < maxResponseDif &&\r
- p1.octave == p2.octave &&\r
- p1.class_id == p2.class_id );\r
-}\r
-\r
-void CV_GPU_SURFTest::compareKeypointSets(const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints, \r
- const Mat& validDescriptors, const Mat& calcDescriptors)\r
-{\r
- if (validKeypoints.size() != calcKeypoints.size())\r
- {\r
- ts->printf(CvTS::LOG, "Keypoints sizes doesn't equal (validCount = %d, calcCount = %d).\n",\r
- validKeypoints.size(), calcKeypoints.size());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- if (validDescriptors.size() != calcDescriptors.size())\r
- {\r
- ts->printf(CvTS::LOG, "Descriptors sizes doesn't equal.\n");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- for (size_t v = 0; v < validKeypoints.size(); v++)\r
- {\r
- int nearestIdx = -1;\r
- float minDist = std::numeric_limits<float>::max();\r
-\r
- for (size_t c = 0; c < calcKeypoints.size(); c++)\r
- {\r
- float curDist = (float)norm(calcKeypoints[c].pt - validKeypoints[v].pt);\r
- if (curDist < minDist)\r
- {\r
- minDist = curDist;\r
- nearestIdx = c;\r
- }\r
- }\r
-\r
- assert(minDist >= 0);\r
- if (!isSimilarKeypoints(validKeypoints[v], calcKeypoints[nearestIdx]))\r
- {\r
- ts->printf(CvTS::LOG, "Bad keypoints accuracy.\n");\r
- ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );\r
- return;\r
- }\r
-\r
- if (norm(validDescriptors.row(v), calcDescriptors.row(nearestIdx), NORM_L2) > 1.5f)\r
- {\r
- ts->printf(CvTS::LOG, "Bad descriptors accuracy.\n");\r
- ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );\r
- return;\r
- }\r
- }\r
-}\r
-\r
-void CV_GPU_SURFTest::regressionTest(SURF_GPU& fdetector)\r
-{\r
- string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME;\r
- string resFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + VALID_FILE_NAME;\r
-\r
- // Read the test image.\r
- GpuMat image(imread(imgFilename, 0));\r
- if (image.empty())\r
- {\r
- ts->printf( CvTS::LOG, "Image %s can not be read.\n", imgFilename.c_str() );\r
- ts->set_failed_test_info( CvTS::FAIL_INVALID_TEST_DATA );\r
- return;\r
- }\r
-\r
- FileStorage fs(resFilename, FileStorage::READ);\r
-\r
- // Compute keypoints.\r
- GpuMat mask(image.size(), CV_8UC1, Scalar::all(1));\r
- mask(Range(0, image.rows / 2), Range(0, image.cols / 2)).setTo(Scalar::all(0));\r
- vector<KeyPoint> calcKeypoints;\r
- GpuMat calcDespcriptors;\r
- fdetector(image, mask, calcKeypoints, calcDespcriptors);\r
-\r
- if (fs.isOpened()) // Compare computed and valid keypoints.\r
- {\r
- // Read validation keypoints set.\r
- vector<KeyPoint> validKeypoints;\r
- Mat validDespcriptors;\r
- read(fs["keypoints"], validKeypoints);\r
- read(fs["descriptors"], validDespcriptors);\r
- if (validKeypoints.empty() || validDespcriptors.empty())\r
- {\r
- ts->printf(CvTS::LOG, "Validation file can not be read.\n");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_TEST_DATA);\r
- return;\r
- }\r
-\r
- compareKeypointSets(validKeypoints, calcKeypoints, validDespcriptors, calcDespcriptors);\r
- }\r
- else // Write detector parameters and computed keypoints as validation data.\r
- {\r
- fs.open(resFilename, FileStorage::WRITE);\r
- if (!fs.isOpened())\r
- {\r
- ts->printf(CvTS::LOG, "File %s can not be opened to write.\n", resFilename.c_str());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_TEST_DATA);\r
- return;\r
- }\r
- else\r
- {\r
- write(fs, "keypoints", calcKeypoints);\r
- write(fs, "descriptors", (Mat)calcDespcriptors);\r
- }\r
- }\r
-}\r
-\r
-void CV_GPU_SURFTest::run( int /*start_from*/ )\r
-{\r
- try\r
- {\r
- SURF_GPU fdetector;\r
-\r
- emptyDataTest(fdetector);\r
- regressionTest(fdetector);\r
- }\r
- catch(cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw; \r
- return;\r
- }\r
-}\r
-\r
-CV_GPU_SURFTest CV_GPU_SURF_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <cmath>\r
-#include <limits>\r
-#include "gputest.hpp"\r
-\r
-using namespace cv;\r
-using namespace std;\r
-using namespace gpu;\r
-\r
-class CV_GpuNppFilterTest : public CvTest\r
-{\r
-public:\r
- CV_GpuNppFilterTest(const char* test_name, const char* test_funcs) : CvTest(test_name, test_funcs) {}\r
- virtual ~CV_GpuNppFilterTest() {}\r
-\r
-protected:\r
- void run(int);\r
- virtual int test(const Mat& img) = 0;\r
- \r
- int test8UC1(const Mat& img)\r
- {\r
- cv::Mat img_C1;\r
- cvtColor(img, img_C1, CV_BGR2GRAY);\r
- return test(img_C1);\r
- }\r
-\r
- int test8UC4(const Mat& img)\r
- {\r
- cv::Mat img_C4;\r
- cvtColor(img, img_C4, CV_BGR2BGRA);\r
- return test(img_C4);\r
- }\r
- \r
- int CheckNorm(const Mat& m1, const Mat& m2, const Size& ksize)\r
- {\r
- Rect roi = Rect(ksize.width, ksize.height, m1.cols - 2 * ksize.width, m1.rows - 2 * ksize.height);\r
- Mat m1ROI = m1(roi);\r
- Mat m2ROI = m2(roi);\r
-\r
- double res = norm(m1ROI, m2ROI, NORM_INF);\r
-\r
- // Max difference (2.0) in GaussianBlur\r
- if (res <= 2)\r
- return CvTS::OK;\r
- \r
- ts->printf(CvTS::LOG, "Norm: %f\n", res);\r
- return CvTS::FAIL_GENERIC;\r
- }\r
-};\r
-\r
-void CV_GpuNppFilterTest::run( int )\r
-{ \r
- cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
- \r
- if (img.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- try\r
- {\r
- //run tests\r
- int testResult = CvTS::OK;\r
-\r
- if (test8UC1(img) != CvTS::OK)\r
- testResult = CvTS::FAIL_GENERIC;\r
-\r
- if (test8UC4(img) != CvTS::OK)\r
- testResult = CvTS::FAIL_GENERIC;\r
-\r
- ts->set_failed_test_info(testResult);\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(CvTS::OK);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// blur\r
-struct CV_GpuNppImageBlurTest : public CV_GpuNppFilterTest\r
-{\r
- CV_GpuNppImageBlurTest() : CV_GpuNppFilterTest( "GPU-NppImageBlur", "blur" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- int ksizes[] = {3, 5, 7};\r
- int ksizes_num = sizeof(ksizes) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < ksizes_num; ++i)\r
- {\r
- for (int j = 0; j < ksizes_num; ++j)\r
- {\r
- Size ksize(ksizes[i], ksizes[j]);\r
-\r
- ts->printf(CvTS::LOG, "\nksize = (%dx%d)\n", ksizes[i], ksizes[j]);\r
-\r
- Mat cpudst;\r
- cv::blur(img, cpudst, ksize);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::blur(gpu1, gpudst, ksize);\r
-\r
- if (CheckNorm(cpudst, gpudst, ksize) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Sobel\r
-struct CV_GpuNppImageSobelTest : public CV_GpuNppFilterTest\r
-{\r
- CV_GpuNppImageSobelTest() : CV_GpuNppFilterTest( "GPU-NppImageSobel", "Sobel" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- int ksizes[] = {3, 5, 7};\r
- int ksizes_num = sizeof(ksizes) / sizeof(int);\r
-\r
- int dx = 1, dy = 0;\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < ksizes_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nksize = %d\n", ksizes[i]);\r
-\r
- Mat cpudst;\r
- cv::Sobel(img, cpudst, -1, dx, dy, ksizes[i]);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::Sobel(gpu1, gpudst, -1, dx, dy, ksizes[i]);\r
-\r
- if (CheckNorm(cpudst, gpudst, Size(ksizes[i], ksizes[i])) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Scharr\r
-struct CV_GpuNppImageScharrTest : public CV_GpuNppFilterTest\r
-{\r
- CV_GpuNppImageScharrTest() : CV_GpuNppFilterTest( "GPU-NppImageScharr", "Scharr" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- int dx = 1, dy = 0;\r
-\r
- Mat cpudst;\r
- cv::Scharr(img, cpudst, -1, dx, dy);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::Scharr(gpu1, gpudst, -1, dx, dy);\r
- \r
- return CheckNorm(cpudst, gpudst, Size(3, 3));\r
- }\r
-};\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// GaussianBlur\r
-struct CV_GpuNppImageGaussianBlurTest : public CV_GpuNppFilterTest\r
-{\r
- CV_GpuNppImageGaussianBlurTest() : CV_GpuNppFilterTest( "GPU-NppImageGaussianBlur", "GaussianBlur" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- int ksizes[] = {3, 5, 7};\r
- int ksizes_num = sizeof(ksizes) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- const double sigma1 = 3.0;\r
-\r
- for (int i = 0; i < ksizes_num; ++i)\r
- {\r
- for (int j = 0; j < ksizes_num; ++j)\r
- {\r
- cv::Size ksize(ksizes[i], ksizes[j]);\r
-\r
- ts->printf(CvTS::LOG, "ksize = (%dx%d)\t\n", ksizes[i], ksizes[j]);\r
-\r
- Mat cpudst;\r
- cv::GaussianBlur(img, cpudst, ksize, sigma1);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::GaussianBlur(gpu1, gpudst, ksize, sigma1);\r
-\r
- if (CheckNorm(cpudst, gpudst, ksize) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Laplacian\r
-struct CV_GpuNppImageLaplacianTest : public CV_GpuNppFilterTest\r
-{\r
- CV_GpuNppImageLaplacianTest() : CV_GpuNppFilterTest( "GPU-NppImageLaplacian", "Laplacian" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- int ksizes[] = {1, 3};\r
- int ksizes_num = sizeof(ksizes) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < ksizes_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nksize = %d\n", ksizes[i]);\r
-\r
- Mat cpudst;\r
- cv::Laplacian(img, cpudst, -1, ksizes[i]);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::Laplacian(gpu1, gpudst, -1, ksizes[i]);\r
-\r
- if (CheckNorm(cpudst, gpudst, Size(3, 3)) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Erode\r
-class CV_GpuErodeTest : public CV_GpuNppFilterTest\r
-{\r
-public:\r
- CV_GpuErodeTest() : CV_GpuNppFilterTest( "GPU-NppErode", "erode" ) {} \r
-\r
-protected:\r
- virtual int test(const Mat& img)\r
- {\r
- Mat kernel(Mat::ones(3, 3, CV_8U));\r
-\r
- cv::Mat cpuRes;\r
- cv::erode(img, cpuRes, kernel);\r
-\r
- GpuMat gpuRes;\r
- cv::gpu::erode(GpuMat(img), gpuRes, kernel);\r
-\r
- return CheckNorm(cpuRes, gpuRes, Size(3, 3));\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Dilate\r
-class CV_GpuDilateTest : public CV_GpuNppFilterTest\r
-{\r
-public:\r
- CV_GpuDilateTest() : CV_GpuNppFilterTest( "GPU-NppDilate", "dilate" ) {} \r
-\r
-protected:\r
- virtual int test(const Mat& img)\r
- {\r
- Mat kernel(Mat::ones(3, 3, CV_8U));\r
-\r
- cv::Mat cpuRes;\r
- cv::dilate(img, cpuRes, kernel);\r
-\r
- GpuMat gpuRes;\r
- cv::gpu::dilate(GpuMat(img), gpuRes, kernel);\r
- \r
- return CheckNorm(cpuRes, gpuRes, Size(3, 3));\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// MorphologyEx\r
-class CV_GpuMorphExTest : public CV_GpuNppFilterTest\r
-{\r
-public:\r
- CV_GpuMorphExTest() : CV_GpuNppFilterTest( "GPU-NppMorphologyEx", "morphologyEx" ) {} \r
-\r
-protected:\r
- virtual int test(const Mat& img)\r
- {\r
- static int ops[] = { MORPH_OPEN, CV_MOP_CLOSE, CV_MOP_GRADIENT, CV_MOP_TOPHAT, CV_MOP_BLACKHAT};\r
- const char *names[] = { "MORPH_OPEN", "CV_MOP_CLOSE", "CV_MOP_GRADIENT", "CV_MOP_TOPHAT", "CV_MOP_BLACKHAT"};\r
- int num = sizeof(ops)/sizeof(ops[0]);\r
-\r
- GpuMat kernel(Mat::ones(3, 3, CV_8U));\r
-\r
- int res = CvTS::OK;\r
-\r
- for(int i = 0; i < num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "Tesing %s\n", names[i]);\r
-\r
- cv::Mat cpuRes;\r
- cv::morphologyEx(img, cpuRes, ops[i], kernel);\r
-\r
- GpuMat gpuRes;\r
- cv::gpu::morphologyEx(GpuMat(img), gpuRes, ops[i], kernel);\r
-\r
- if (CvTS::OK != CheckNorm(cpuRes, gpuRes, Size(4, 4)))\r
- res = CvTS::FAIL_GENERIC;\r
- }\r
- return res;\r
- }\r
-};\r
-\r
-\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-/////////////////// tests registration /////////////////////////////////////\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-CV_GpuNppImageBlurTest CV_GpuNppImageBlur_test;\r
-CV_GpuNppImageSobelTest CV_GpuNppImageSobel_test;\r
-CV_GpuNppImageScharrTest CV_GpuNppImageScharr_test;\r
-CV_GpuNppImageGaussianBlurTest CV_GpuNppImageGaussianBlur_test;\r
-CV_GpuNppImageLaplacianTest CV_GpuNppImageLaplacian_test;\r
-CV_GpuErodeTest CV_GpuErode_test;\r
-CV_GpuDilateTest CV_GpuDilate_test;\r
-CV_GpuMorphExTest CV_GpuMorphEx_test;
\ No newline at end of file
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#ifndef _GPU_TEST_H_\r
-#define _GPU_TEST_H_\r
-\r
-#if defined WIN32 || defined _WIN32\r
-#include <windows.h>\r
-#undef min\r
-#undef max\r
-#endif\r
-\r
-#include <opencv2/gpu/gpu.hpp>\r
-#include <opencv2/highgui/highgui.hpp>\r
-#include <opencv2/imgproc/imgproc.hpp>\r
-#include <opencv2/features2d/features2d.hpp>\r
-#include <opencv2/calib3d/calib3d.hpp>\r
-#include "cxts.h"\r
-\r
-/****************************************************************************************/\r
-/* Warnings Disabling */\r
-/****************************************************************************************/\r
-#if _MSC_VER > 1000\r
-#pragma warning(disable : 4514) /* unreferenced inline function has been */\r
- /* removed */\r
-#pragma warning(disable : 4127) /* conditional expression is constant */\r
- /* for no warnings in _ASSERT */\r
-#pragma warning(disable : 4996) /* deprecated function */\r
-#endif\r
-\r
-\r
-static inline bool check_and_treat_gpu_exception(const cv::Exception& e, CvTS* ts)\r
-{\r
- switch (e.code)\r
- {\r
- case CV_GpuNotSupported: \r
- ts->printf(CvTS::LOG, "\nGpu not supported by the library"); \r
- break;\r
-\r
- case CV_GpuApiCallError: \r
- ts->printf(CvTS::LOG, "\nGPU Error: %s", e.what());\r
- break;\r
-\r
- case CV_GpuNppCallError: \r
- ts->printf(CvTS::LOG, "\nNPP Error: %s", e.what());\r
- break;\r
-\r
- default:\r
- return false;\r
- }\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC); \r
- return true;\r
-}\r
-\r
-#endif \r
-\r
-/* End of file. */\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-
-CvTS test_system("gpu");
-
-//const char* blacklist[] =
-//{
-// "GPU-NVidia",
-// 0
-//};
-
-int main( int argc, char** argv )
-{
- return test_system.run( argc, argv );
-}
-
-/* End of file. */
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-#include <fstream>\r
-\r
-using namespace std;\r
-\r
-//#define DUMP\r
-\r
-#define CHECK(pred, err) if (!(pred)) { \\r
- ts->printf(CvTS::CONSOLE, "Fail: \"%s\" at line: %d\n", #pred, __LINE__); \\r
- ts->set_failed_test_info(err); \\r
- return; }\r
-\r
-struct CV_GpuHogDetectTestRunner: cv::gpu::HOGDescriptor\r
-{\r
- CV_GpuHogDetectTestRunner(CvTS* ts_): ts(ts_) {}\r
-\r
- void run(int) \r
- { \r
- try \r
- {\r
- cv::Mat img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/road.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
-\r
-#ifdef DUMP\r
- f.open((std::string(ts->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);\r
- CHECK(f.is_open(), CvTS::FAIL_GENERIC); \r
-#else\r
- f.open((std::string(ts->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);\r
- CHECK(f.is_open(), CvTS::FAIL_MISSING_TEST_DATA); \r
-#endif\r
- \r
- // Test on color image\r
- cv::Mat img;\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- test(img);\r
-\r
- // Test on gray image\r
- cv::cvtColor(img_rgb, img, CV_BGR2GRAY);\r
- test(img);\r
-\r
- f.close();\r
- }\r
- catch (const cv::Exception& e)\r
- {\r
- f.close();\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
-#ifdef DUMP\r
- void dump(const cv::Mat& block_hists, const std::vector<cv::Point>& locations) \r
- {\r
- f.write((char*)&block_hists.rows, sizeof(block_hists.rows));\r
- f.write((char*)&block_hists.cols, sizeof(block_hists.cols));\r
- for (int i = 0; i < block_hists.rows; ++i)\r
- {\r
- for (int j = 0; j < block_hists.cols; ++j)\r
- {\r
- float val = block_hists.at<float>(i, j);\r
- f.write((char*)&val, sizeof(val));\r
- }\r
- }\r
- size_t nlocations = locations.size();\r
- f.write((char*)&nlocations, sizeof(nlocations));\r
- for (size_t i = 0; i < locations.size(); ++i)\r
- f.write((char*)&locations[i], sizeof(locations[i]));\r
- }\r
-#else\r
- void compare(const cv::Mat& block_hists, const std::vector<cv::Point>& locations) \r
- {\r
- int rows, cols;\r
- size_t nlocations;\r
-\r
- f.read((char*)&rows, sizeof(rows));\r
- f.read((char*)&cols, sizeof(cols));\r
- CHECK(rows == block_hists.rows, CvTS::FAIL_INVALID_OUTPUT);\r
- CHECK(cols == block_hists.cols, CvTS::FAIL_INVALID_OUTPUT);\r
- for (int i = 0; i < block_hists.rows; ++i)\r
- {\r
- for (int j = 0; j < block_hists.cols; ++j)\r
- {\r
- float val;\r
- f.read((char*)&val, sizeof(val));\r
- CHECK(fabs(val - block_hists.at<float>(i, j)) < 1e-3f, CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- }\r
- f.read((char*)&nlocations, sizeof(nlocations));\r
- CHECK(nlocations == locations.size(), CvTS::FAIL_INVALID_OUTPUT);\r
- for (size_t i = 0; i < nlocations; ++i)\r
- {\r
- cv::Point location;\r
- f.read((char*)&location, sizeof(location));\r
- CHECK(location == locations[i], CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- }\r
-#endif\r
-\r
- void test(const cv::Mat& img) \r
- {\r
- cv::gpu::GpuMat d_img(img);\r
-\r
- gamma_correction = false;\r
- setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());\r
- //cpu detector may be updated soon\r
- //hog.setSVMDetector(cv::HOGDescriptor::getDefaultPeopleDetector());\r
-\r
- std::vector<cv::Point> locations;\r
-\r
- // Test detect\r
- detect(d_img, locations, 0);\r
-\r
-#ifdef DUMP\r
- dump(block_hists, locations);\r
-#else\r
- compare(block_hists, locations);\r
-#endif\r
-\r
- // Test detect on smaller image\r
- cv::Mat img2;\r
- cv::resize(img, img2, cv::Size(img.cols / 2, img.rows / 2)); \r
- detect(cv::gpu::GpuMat(img2), locations, 0);\r
-\r
-#ifdef DUMP\r
- dump(block_hists, locations);\r
-#else\r
- compare(block_hists, locations);\r
-#endif\r
-\r
- // Test detect on greater image\r
- cv::resize(img, img2, cv::Size(img.cols * 2, img.rows * 2)); \r
- detect(cv::gpu::GpuMat(img2), locations, 0);\r
- \r
-#ifdef DUMP\r
- dump(block_hists, locations);\r
-#else\r
- compare(block_hists, locations);\r
-#endif\r
- }\r
-\r
-#ifdef DUMP\r
- std::ofstream f;\r
-#else\r
- std::ifstream f;\r
-#endif\r
-\r
- CvTS* ts;\r
-};\r
-\r
-\r
-struct CV_GpuHogDetectTest: CvTest \r
-{\r
- CV_GpuHogDetectTest(): CvTest("GPU-HogDetectTest", "HOGDescriptor::detect") {}\r
-\r
- void run(int i)\r
- {\r
- CV_GpuHogDetectTestRunner runner(ts);\r
- runner.run(i);\r
- }\r
-} CV_GpuHogDetectTest_inst;\r
-\r
-\r
-struct CV_GpuHogGetDescriptorsTestRunner: cv::gpu::HOGDescriptor\r
-{\r
- CV_GpuHogGetDescriptorsTestRunner(CvTS* ts_): HOGDescriptor(cv::Size(64, 128)), ts(ts_) {}\r
-\r
- void run(int)\r
- {\r
- try \r
- {\r
- // Load image (e.g. train data, composed from windows)\r
- cv::Mat img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/train_data.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
-\r
- // Convert to C4\r
- cv::Mat img;\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- cv::gpu::GpuMat d_img(img);\r
-\r
-\r
- // Convert train images into feature vectors (train table)\r
- cv::gpu::GpuMat descriptors, descriptors_by_cols;\r
- getDescriptors(d_img, win_size, descriptors, DESCR_FORMAT_ROW_BY_ROW);\r
- getDescriptors(d_img, win_size, descriptors_by_cols, DESCR_FORMAT_COL_BY_COL);\r
-\r
- // Check size of the result train table\r
- wins_per_img_x = 3;\r
- wins_per_img_y = 2;\r
- blocks_per_win_x = 7;\r
- blocks_per_win_y = 15;\r
- block_hist_size = 36;\r
- cv::Size descr_size_expected = cv::Size(blocks_per_win_x * blocks_per_win_y * block_hist_size, \r
- wins_per_img_x * wins_per_img_y); \r
- CHECK(descriptors.size() == descr_size_expected, CvTS::FAIL_INVALID_OUTPUT);\r
-\r
- // Check both formats of output descriptors are handled correctly\r
- cv::Mat dr(descriptors);\r
- cv::Mat dc(descriptors_by_cols);\r
- for (int i = 0; i < wins_per_img_x * wins_per_img_y; ++i)\r
- {\r
- const float* l = dr.rowRange(i, i + 1).ptr<float>();\r
- const float* r = dc.rowRange(i, i + 1).ptr<float>();\r
- for (int y = 0; y < blocks_per_win_y; ++y)\r
- for (int x = 0; x < blocks_per_win_x; ++x)\r
- for (int k = 0; k < block_hist_size; ++k)\r
- CHECK(l[(y * blocks_per_win_x + x) * block_hist_size + k] == \r
- r[(x * blocks_per_win_y + y) * block_hist_size + k], CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
-\r
- /* Now we want to extract the same feature vectors, but from single images. NOTE: results will \r
- be defferent, due to border values interpolation. Using of many small images is slower, however we \r
- wont't call getDescriptors and will use computeBlockHistograms instead of. computeBlockHistograms \r
- works good, it can be checked in the gpu_hog sample */\r
-\r
- img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/positive1.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- computeBlockHistograms(cv::gpu::GpuMat(img));\r
- // Everything is fine with interpolation for left top subimage\r
- CHECK(cv::norm(block_hists, descriptors.rowRange(0, 1)) == 0.f, CvTS::FAIL_INVALID_OUTPUT);\r
-\r
- img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/positive2.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- computeBlockHistograms(cv::gpu::GpuMat(img));\r
- compare_inner_parts(block_hists, descriptors.rowRange(1, 2));\r
-\r
- img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/negative1.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- computeBlockHistograms(cv::gpu::GpuMat(img));\r
- compare_inner_parts(block_hists, descriptors.rowRange(2, 3));\r
-\r
- img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/negative2.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- computeBlockHistograms(cv::gpu::GpuMat(img));\r
- compare_inner_parts(block_hists, descriptors.rowRange(3, 4));\r
-\r
- img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/positive3.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- computeBlockHistograms(cv::gpu::GpuMat(img));\r
- compare_inner_parts(block_hists, descriptors.rowRange(4, 5));\r
-\r
- img_rgb = cv::imread(std::string(ts->get_data_path()) + "hog/negative3.png");\r
- CHECK(!img_rgb.empty(), CvTS::FAIL_MISSING_TEST_DATA);\r
- cv::cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- computeBlockHistograms(cv::gpu::GpuMat(img));\r
- compare_inner_parts(block_hists, descriptors.rowRange(5, 6));\r
- }\r
- catch (const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- // Does not compare border value, as interpolation leads to delta\r
- void compare_inner_parts(cv::Mat d1, cv::Mat d2)\r
- {\r
- for (int i = 1; i < blocks_per_win_y - 1; ++i)\r
- for (int j = 1; j < blocks_per_win_x - 1; ++j)\r
- for (int k = 0; k < block_hist_size; ++k)\r
- {\r
- float a = d1.at<float>(0, (i * blocks_per_win_x + j) * block_hist_size);\r
- float b = d2.at<float>(0, (i * blocks_per_win_x + j) * block_hist_size);\r
- CHECK(a == b, CvTS::FAIL_INVALID_OUTPUT)\r
- }\r
- }\r
-\r
- int wins_per_img_x;\r
- int wins_per_img_y;\r
- int blocks_per_win_x;\r
- int blocks_per_win_y;\r
- int block_hist_size;\r
-\r
- CvTS* ts;\r
-};\r
-\r
-\r
-struct CV_GpuHogGetDescriptorsTest: CvTest \r
-{\r
- CV_GpuHogGetDescriptorsTest(): CvTest("GPU-HogGetDescriptorsTest", "HOGDescriptor::getDescriptors") {}\r
-\r
- void run(int i)\r
- {\r
- CV_GpuHogGetDescriptorsTestRunner runner(ts);\r
- runner.run(i);\r
- }\r
-} CV_GpuHogGetDescriptorsTest_inst;
\ No newline at end of file
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <cmath>\r
-#include <limits>\r
-#include "gputest.hpp"\r
-\r
-using namespace cv;\r
-using namespace std;\r
-using namespace gpu;\r
-\r
-class CV_GpuImageProcTest : public CvTest\r
-{\r
-public:\r
- CV_GpuImageProcTest(const char* test_name, const char* test_funcs) : CvTest(test_name, test_funcs) {}\r
- virtual ~CV_GpuImageProcTest() {}\r
-\r
-protected:\r
- void run(int);\r
-\r
- int test8UC1 (const Mat& img);\r
- int test8UC4 (const Mat& img);\r
- int test32SC1(const Mat& img);\r
- int test32FC1(const Mat& img);\r
-\r
- virtual int test(const Mat& img) = 0;\r
-\r
- int CheckNorm(const Mat& m1, const Mat& m2);\r
-\r
- // Checks whether two images are similar enough using normalized\r
- // cross-correlation as an error measure\r
- int CheckSimilarity(const Mat& m1, const Mat& m2, float max_err=1e-3f);\r
-};\r
-\r
-\r
-int CV_GpuImageProcTest::test8UC1(const Mat& img)\r
-{\r
- cv::Mat img_C1;\r
- cvtColor(img, img_C1, CV_BGR2GRAY);\r
-\r
- return test(img_C1);\r
-}\r
-\r
-int CV_GpuImageProcTest::test8UC4(const Mat& img)\r
-{\r
- cv::Mat img_C4;\r
- cvtColor(img, img_C4, CV_BGR2BGRA);\r
-\r
- return test(img_C4);\r
-}\r
-\r
-int CV_GpuImageProcTest::test32SC1(const Mat& img)\r
-{\r
- cv::Mat img_C1;\r
- cvtColor(img, img_C1, CV_BGR2GRAY);\r
- img_C1.convertTo(img_C1, CV_32S);\r
-\r
- return test(img_C1);\r
-}\r
-\r
-int CV_GpuImageProcTest::test32FC1(const Mat& img)\r
-{\r
- cv::Mat temp, img_C1;\r
- img.convertTo(temp, CV_32F, 1.f / 255.f);\r
- cvtColor(temp, img_C1, CV_BGR2GRAY);\r
-\r
- return test(img_C1);\r
-}\r
-\r
-int CV_GpuImageProcTest::CheckNorm(const Mat& m1, const Mat& m2)\r
-{\r
- double ret = norm(m1, m2, NORM_INF);\r
-\r
- if (ret < std::numeric_limits<double>::epsilon())\r
- {\r
- return CvTS::OK;\r
- }\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "Norm: %f\n", ret);\r
- return CvTS::FAIL_GENERIC;\r
- }\r
-}\r
-\r
-int CV_GpuImageProcTest::CheckSimilarity(const Mat& m1, const Mat& m2, float max_err)\r
-{\r
- Mat diff;\r
- cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
-\r
- float err = abs(diff.at<float>(0, 0) - 1.f);\r
-\r
- if (err > max_err)\r
- return CvTS::FAIL_INVALID_OUTPUT;\r
-\r
- return CvTS::OK;\r
-}\r
-\r
-void CV_GpuImageProcTest::run( int )\r
-{\r
- //load image\r
- cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-\r
- if (img.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- int testResult = CvTS::OK;\r
- try\r
- {\r
- //run tests\r
- ts->printf(CvTS::LOG, "\n========Start test 8UC1========\n");\r
- if (test8UC1(img) == CvTS::OK)\r
- ts->printf(CvTS::LOG, "SUCCESS\n");\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "FAIL\n");\r
- testResult = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- ts->printf(CvTS::LOG, "\n========Start test 8UC4========\n");\r
- if (test8UC4(img) == CvTS::OK)\r
- ts->printf(CvTS::LOG, "SUCCESS\n");\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "FAIL\n");\r
- testResult = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- ts->printf(CvTS::LOG, "\n========Start test 32SC1========\n");\r
- if (test32SC1(img) == CvTS::OK)\r
- ts->printf(CvTS::LOG, "SUCCESS\n");\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "FAIL\n");\r
- testResult = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- ts->printf(CvTS::LOG, "\n========Start test 32FC1========\n");\r
- if (test32FC1(img) == CvTS::OK)\r
- ts->printf(CvTS::LOG, "SUCCESS\n");\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "FAIL\n");\r
- testResult = CvTS::FAIL_GENERIC;\r
- }\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(testResult);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// threshold\r
-struct CV_GpuImageThresholdTest : public CV_GpuImageProcTest\r
-{\r
-public:\r
- CV_GpuImageThresholdTest() : CV_GpuImageProcTest( "GPU-ImageThreshold", "threshold" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- if (img.type() != CV_8UC1 && img.type() != CV_32FC1)\r
- {\r
- ts->printf(CvTS::LOG, "\nUnsupported type\n");\r
- return CvTS::OK;\r
- }\r
-\r
- const double maxVal = img.type() == CV_8UC1 ? 255 : 1.0;\r
-\r
- cv::RNG rng(*ts->get_rng());\r
-\r
- int res = CvTS::OK;\r
-\r
- for (int type = THRESH_BINARY; type <= THRESH_TOZERO_INV; ++type)\r
- {\r
- const double thresh = rng.uniform(0.0, maxVal);\r
-\r
- cv::Mat cpuRes;\r
- cv::threshold(img, cpuRes, thresh, maxVal, type);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpuRes;\r
- cv::gpu::threshold(gpu1, gpuRes, thresh, maxVal, type);\r
-\r
- if (CheckNorm(cpuRes, gpuRes) != CvTS::OK)\r
- res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// resize\r
-struct CV_GpuNppImageResizeTest : public CV_GpuImageProcTest\r
-{\r
- CV_GpuNppImageResizeTest() : CV_GpuImageProcTest( "GPU-NppImageResize", "resize" ) {}\r
- int test(const Mat& img)\r
- {\r
- if (img.type() != CV_8UC1 && img.type() != CV_8UC4)\r
- {\r
- ts->printf(CvTS::LOG, "Unsupported type\n");\r
- return CvTS::OK;\r
- }\r
-\r
- int interpolations[] = {INTER_NEAREST, INTER_LINEAR, /*INTER_CUBIC,*/ /*INTER_LANCZOS4*/};\r
- const char* interpolations_str[] = {"INTER_NEAREST", "INTER_LINEAR", /*"INTER_CUBIC",*/ /*"INTER_LANCZOS4"*/};\r
- int interpolations_num = sizeof(interpolations) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < interpolations_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "Interpolation: %s\n", interpolations_str[i]);\r
-\r
- Mat cpu_res1, cpu_res2;\r
- cv::resize(img, cpu_res1, Size(), 2.0, 2.0, interpolations[i]);\r
- cv::resize(cpu_res1, cpu_res2, Size(), 0.5, 0.5, interpolations[i]);\r
-\r
- GpuMat gpu1(img), gpu_res1, gpu_res2;\r
- cv::gpu::resize(gpu1, gpu_res1, Size(), 2.0, 2.0, interpolations[i]);\r
- cv::gpu::resize(gpu_res1, gpu_res2, Size(), 0.5, 0.5, interpolations[i]);\r
-\r
- if (CheckSimilarity(cpu_res2, gpu_res2) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// copyMakeBorder\r
-struct CV_GpuNppImageCopyMakeBorderTest : public CV_GpuImageProcTest\r
-{\r
- CV_GpuNppImageCopyMakeBorderTest() : CV_GpuImageProcTest( "GPU-NppImageCopyMakeBorder", "copyMakeBorder" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- if (img.type() != CV_8UC1 && img.type() != CV_8UC4 && img.type() != CV_32SC1)\r
- {\r
- ts->printf(CvTS::LOG, "\nUnsupported type\n");\r
- return CvTS::OK;\r
- }\r
-\r
- cv::RNG rng(*ts->get_rng());\r
- int top = rng.uniform(1, 10);\r
- int botton = rng.uniform(1, 10);\r
- int left = rng.uniform(1, 10);\r
- int right = rng.uniform(1, 10);\r
- cv::Scalar val(rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255), rng.uniform(0, 255));\r
-\r
- Mat cpudst;\r
- cv::copyMakeBorder(img, cpudst, top, botton, left, right, BORDER_CONSTANT, val);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::copyMakeBorder(gpu1, gpudst, top, botton, left, right, val);\r
-\r
- return CheckNorm(cpudst, gpudst);\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// warpAffine\r
-struct CV_GpuNppImageWarpAffineTest : public CV_GpuImageProcTest\r
-{\r
- CV_GpuNppImageWarpAffineTest() : CV_GpuImageProcTest( "GPU-NppImageWarpAffine", "warpAffine" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- if (img.type() == CV_32SC1)\r
- {\r
- ts->printf(CvTS::LOG, "\nUnsupported type\n");\r
- return CvTS::OK;\r
- }\r
-\r
- static double reflect[2][3] = { {-1, 0, 0},\r
- { 0, -1, 0} };\r
- reflect[0][2] = img.cols;\r
- reflect[1][2] = img.rows;\r
-\r
- Mat M(2, 3, CV_64F, (void*)reflect);\r
-\r
- int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};\r
- const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};\r
- int flags_num = sizeof(flags) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < flags_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]);\r
-\r
- Mat cpudst;\r
- cv::warpAffine(img, cpudst, M, img.size(), flags[i]);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::warpAffine(gpu1, gpudst, M, gpu1.size(), flags[i]);\r
-\r
- // Check inner parts (ignoring 1 pixel width border)\r
- if (CheckSimilarity(cpudst.rowRange(1, cpudst.rows - 1).colRange(1, cpudst.cols - 1),\r
- gpudst.rowRange(1, gpudst.rows - 1).colRange(1, gpudst.cols - 1)) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// warpPerspective\r
-struct CV_GpuNppImageWarpPerspectiveTest : public CV_GpuImageProcTest\r
-{\r
- CV_GpuNppImageWarpPerspectiveTest() : CV_GpuImageProcTest( "GPU-NppImageWarpPerspective", "warpPerspective" ) {}\r
-\r
-\r
- int test(const Mat& img)\r
- {\r
- if (img.type() == CV_32SC1)\r
- {\r
- ts->printf(CvTS::LOG, "\nUnsupported type\n");\r
- return CvTS::OK;\r
- }\r
-\r
- static double reflect[3][3] = { { -1, 0, 0},\r
- { 0, -1, 0},\r
- { 0, 0, 1 }};\r
- reflect[0][2] = img.cols;\r
- reflect[1][2] = img.rows;\r
- Mat M(3, 3, CV_64F, (void*)reflect);\r
-\r
- int flags[] = {INTER_NEAREST, INTER_LINEAR, INTER_CUBIC, INTER_NEAREST | WARP_INVERSE_MAP, INTER_LINEAR | WARP_INVERSE_MAP, INTER_CUBIC | WARP_INVERSE_MAP};\r
- const char* flags_str[] = {"INTER_NEAREST", "INTER_LINEAR", "INTER_CUBIC", "INTER_NEAREST | WARP_INVERSE_MAP", "INTER_LINEAR | WARP_INVERSE_MAP", "INTER_CUBIC | WARP_INVERSE_MAP"};\r
- int flags_num = sizeof(flags) / sizeof(int);\r
-\r
- int test_res = CvTS::OK;\r
-\r
- for (int i = 0; i < flags_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\nFlags: %s\n", flags_str[i]);\r
-\r
- Mat cpudst;\r
- cv::warpPerspective(img, cpudst, M, img.size(), flags[i]);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpudst;\r
- cv::gpu::warpPerspective(gpu1, gpudst, M, gpu1.size(), flags[i]);\r
-\r
- // Check inner parts (ignoring 1 pixel width border)\r
- if (CheckSimilarity(cpudst.rowRange(1, cpudst.rows - 1).colRange(1, cpudst.cols - 1),\r
- gpudst.rowRange(1, gpudst.rows - 1).colRange(1, gpudst.cols - 1)) != CvTS::OK)\r
- test_res = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- return test_res;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// integral\r
-struct CV_GpuNppImageIntegralTest : public CV_GpuImageProcTest\r
-{\r
- CV_GpuNppImageIntegralTest() : CV_GpuImageProcTest( "GPU-NppImageIntegral", "integral" ) {}\r
-\r
- int test(const Mat& img)\r
- {\r
- if (img.type() != CV_8UC1)\r
- {\r
- ts->printf(CvTS::LOG, "\nUnsupported type\n");\r
- return CvTS::OK;\r
- }\r
-\r
- Mat cpusum;\r
- cv::integral(img, cpusum, CV_32S);\r
-\r
- GpuMat gpu1(img);\r
- GpuMat gpusum;\r
- cv::gpu::integral(gpu1, gpusum);\r
-\r
- return CheckNorm(cpusum, gpusum) == CvTS::OK ? CvTS::OK : CvTS::FAIL_GENERIC;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Canny\r
-//struct CV_GpuNppImageCannyTest : public CV_GpuImageProcTest\r
-//{\r
-// CV_GpuNppImageCannyTest() : CV_GpuImageProcTest( "GPU-NppImageCanny", "Canny" ) {}\r
-//\r
-// int test(const Mat& img)\r
-// {\r
-// if (img.type() != CV_8UC1)\r
-// {\r
-// ts->printf(CvTS::LOG, "\nUnsupported type\n");\r
-// return CvTS::OK;\r
-// }\r
-//\r
-// const double threshold1 = 1.0, threshold2 = 10.0;\r
-//\r
-// Mat cpudst;\r
-// cv::Canny(img, cpudst, threshold1, threshold2);\r
-//\r
-// GpuMat gpu1(img);\r
-// GpuMat gpudst;\r
-// cv::gpu::Canny(gpu1, gpudst, threshold1, threshold2);\r
-//\r
-// return CheckNorm(cpudst, gpudst);\r
-// }\r
-//};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// cvtColor\r
-class CV_GpuCvtColorTest : public CvTest\r
-{\r
-public:\r
- CV_GpuCvtColorTest() : CvTest("GPU-CvtColor", "cvtColor") {}\r
- ~CV_GpuCvtColorTest() {};\r
-\r
-protected:\r
- void run(int);\r
-\r
- int CheckNorm(const Mat& m1, const Mat& m2);\r
-};\r
-\r
-\r
-int CV_GpuCvtColorTest::CheckNorm(const Mat& m1, const Mat& m2)\r
-{\r
- double ret = norm(m1, m2, NORM_INF);\r
-\r
- if (ret <= 3)\r
- {\r
- return CvTS::OK;\r
- }\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);\r
- return CvTS::FAIL_GENERIC;\r
- }\r
-}\r
-\r
-void CV_GpuCvtColorTest::run( int )\r
-{\r
- cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-\r
- if (img.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- int testResult = CvTS::OK;\r
- cv::Mat cpuRes;\r
- cv::gpu::GpuMat gpuImg(img), gpuRes;\r
- try\r
- {\r
- int codes[] = { CV_BGR2RGB, CV_RGB2BGRA, CV_BGRA2RGB,\r
- CV_RGB2BGR555, CV_BGR5552BGR, CV_BGR2BGR565, CV_BGR5652RGB,\r
- CV_RGB2YCrCb, CV_YCrCb2BGR, CV_BGR2YUV, CV_YUV2RGB,\r
- CV_RGB2XYZ, CV_XYZ2BGR, CV_BGR2XYZ, CV_XYZ2RGB,\r
- CV_RGB2HSV, CV_HSV2BGR, CV_BGR2HSV_FULL, CV_HSV2RGB_FULL,\r
- CV_RGB2HLS, CV_HLS2BGR, CV_BGR2HLS_FULL, CV_HLS2RGB_FULL,\r
- CV_RGB2GRAY, CV_GRAY2BGRA, CV_BGRA2GRAY,\r
- CV_GRAY2BGR555, CV_BGR5552GRAY, CV_GRAY2BGR565, CV_BGR5652GRAY};\r
- const char* codes_str[] = { "CV_BGR2RGB", "CV_RGB2BGRA", "CV_BGRA2RGB",\r
- "CV_RGB2BGR555", "CV_BGR5552BGR", "CV_BGR2BGR565", "CV_BGR5652RGB",\r
- "CV_RGB2YCrCb", "CV_YCrCb2BGR", "CV_BGR2YUV", "CV_YUV2RGB",\r
- "CV_RGB2XYZ", "CV_XYZ2BGR", "CV_BGR2XYZ", "CV_XYZ2RGB",\r
- "CV_RGB2HSV", "CV_HSV2RGB", "CV_BGR2HSV_FULL", "CV_HSV2RGB_FULL",\r
- "CV_RGB2HLS", "CV_HLS2RGB", "CV_BGR2HLS_FULL", "CV_HLS2RGB_FULL",\r
- "CV_RGB2GRAY", "CV_GRAY2BGRA", "CV_BGRA2GRAY",\r
- "CV_GRAY2BGR555", "CV_BGR5552GRAY", "CV_GRAY2BGR565", "CV_BGR5652GRAY"};\r
- int codes_num = sizeof(codes) / sizeof(int);\r
-\r
- for (int i = 0; i < codes_num; ++i)\r
- {\r
- ts->printf(CvTS::LOG, "\n%s\n", codes_str[i]);\r
-\r
- cv::cvtColor(img, cpuRes, codes[i]);\r
- cv::gpu::cvtColor(gpuImg, gpuRes, codes[i]);\r
-\r
- if (CheckNorm(cpuRes, gpuRes) == CvTS::OK)\r
- ts->printf(CvTS::LOG, "\nSUCCESS\n");\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "\nFAIL\n");\r
- testResult = CvTS::FAIL_GENERIC;\r
- }\r
-\r
- img = cpuRes;\r
- gpuImg = gpuRes;\r
- }\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(testResult);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Histograms\r
-class CV_GpuHistogramsTest : public CvTest\r
-{\r
-public:\r
- CV_GpuHistogramsTest() : CvTest("GPU-Histograms", "histEven") {}\r
- ~CV_GpuHistogramsTest() {};\r
-\r
-protected:\r
- void run(int);\r
-\r
- int CheckNorm(const Mat& m1, const Mat& m2)\r
- {\r
- double ret = norm(m1, m2, NORM_INF);\r
-\r
- if (ret < std::numeric_limits<double>::epsilon())\r
- {\r
- return CvTS::OK;\r
- }\r
- else\r
- {\r
- ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);\r
- return CvTS::FAIL_GENERIC;\r
- }\r
- }\r
-};\r
-\r
-void CV_GpuHistogramsTest::run( int )\r
-{\r
- //load image\r
- cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
-\r
- if (img.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- try\r
- {\r
- Mat hsv;\r
- cv::cvtColor(img, hsv, CV_BGR2HSV);\r
-\r
- int hbins = 30;\r
- int histSize[] = {hbins};\r
-\r
- float hranges[] = {0, 180};\r
- const float* ranges[] = {hranges};\r
-\r
- MatND hist;\r
-\r
- int channels[] = {0};\r
- calcHist(&hsv, 1, channels, Mat(), hist, 1, histSize, ranges);\r
-\r
- GpuMat gpuHsv(hsv);\r
- std::vector<GpuMat> srcs;\r
- cv::gpu::split(gpuHsv, srcs);\r
- GpuMat gpuHist;\r
- histEven(srcs[0], gpuHist, hbins, (int)hranges[0], (int)hranges[1]);\r
-\r
- Mat cpuHist = hist;\r
- cpuHist = cpuHist.t();\r
- cpuHist.convertTo(cpuHist, CV_32S);\r
-\r
- ts->set_failed_test_info(CheckNorm(cpuHist, gpuHist));\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Corner Harris feature detector\r
-\r
-struct CV_GpuCornerHarrisTest: CvTest \r
-{\r
- CV_GpuCornerHarrisTest(): CvTest("GPU-CornerHarrisTest", "cornerHarris") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- for (int i = 0; i < 5; ++i)\r
- {\r
- int rows = 25 + rand() % 300, cols = 25 + rand() % 300;\r
- if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
- if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, -1)) return;\r
- if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
- if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, -1)) return;\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- bool compareToCpuTest(int rows, int cols, int depth, int blockSize, int apertureSize)\r
- {\r
- RNG rng;\r
- cv::Mat src(rows, cols, depth);\r
- if (depth == CV_32F) \r
- rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));\r
- else if (depth == CV_8U)\r
- rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(256));\r
-\r
- double k = 0.1;\r
-\r
- cv::Mat dst_gold;\r
- cv::gpu::GpuMat dst;\r
- cv::Mat dsth;\r
- int borderType;\r
-\r
- borderType = BORDER_REFLECT101;\r
- cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType); \r
- cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k, borderType);\r
-\r
- dsth = dst;\r
- for (int i = 0; i < dst.rows; ++i)\r
- {\r
- for (int j = 0; j < dst.cols; ++j)\r
- {\r
- float a = dst_gold.at<float>(i, j);\r
- float b = dsth.at<float>(i, j);\r
- if (fabs(a - b) > 1e-3f) \r
- {\r
- ts->printf(CvTS::CONSOLE, "%d %d %f %f %d\n", i, j, a, b, apertureSize);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- };\r
- }\r
- }\r
-\r
- borderType = BORDER_REPLICATE;\r
- cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType); \r
- cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k, borderType);\r
-\r
- dsth = dst;\r
- for (int i = 0; i < dst.rows; ++i)\r
- {\r
- for (int j = 0; j < dst.cols; ++j)\r
- {\r
- float a = dst_gold.at<float>(i, j);\r
- float b = dsth.at<float>(i, j);\r
- if (fabs(a - b) > 1e-3f) \r
- {\r
- ts->printf(CvTS::CONSOLE, "%d %d %f %f %d\n", i, j, a, b, apertureSize);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- };\r
- }\r
- }\r
- return true;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-// Corner Min Eigen Val\r
-\r
-struct CV_GpuCornerMinEigenValTest: CvTest \r
-{\r
- CV_GpuCornerMinEigenValTest(): CvTest("GPU-CornerMinEigenValTest", "cornerMinEigenVal") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- for (int i = 0; i < 3; ++i)\r
- {\r
- int rows = 25 + rand() % 300, cols = 25 + rand() % 300;\r
- if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, -1)) return;\r
- if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
- if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, -1)) return;\r
- if (!compareToCpuTest(rows, cols, CV_8U, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- bool compareToCpuTest(int rows, int cols, int depth, int blockSize, int apertureSize)\r
- {\r
- RNG rng;\r
- cv::Mat src(rows, cols, depth);\r
- if (depth == CV_32F) \r
- rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));\r
- else if (depth == CV_8U)\r
- rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(256));\r
-\r
- cv::Mat dst_gold;\r
- cv::gpu::GpuMat dst;\r
- cv::Mat dsth;\r
-\r
- int borderType;\r
-\r
- borderType = BORDER_REFLECT101;\r
- cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType); \r
- cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType); \r
-\r
- dsth = dst;\r
- for (int i = 0; i < dst.rows; ++i)\r
- {\r
- for (int j = 0; j < dst.cols; ++j)\r
- {\r
- float a = dst_gold.at<float>(i, j);\r
- float b = dsth.at<float>(i, j);\r
- if (fabs(a - b) > 1e-2f) \r
- {\r
- ts->printf(CvTS::CONSOLE, "%d %d %f %f %d %d\n", i, j, a, b, apertureSize, blockSize);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- };\r
- }\r
- }\r
-\r
- borderType = BORDER_REPLICATE;\r
- cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType); \r
- cv::gpu::cornerMinEigenVal(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, borderType); \r
-\r
- dsth = dst;\r
- for (int i = 0; i < dst.rows; ++i)\r
- {\r
- for (int j = 0; j < dst.cols; ++j)\r
- {\r
- float a = dst_gold.at<float>(i, j);\r
- float b = dsth.at<float>(i, j);\r
- if (fabs(a - b) > 1e-2f) \r
- {\r
- ts->printf(CvTS::CONSOLE, "%d %d %f %f %d %d\n", i, j, a, b, apertureSize, blockSize);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- };\r
- }\r
- }\r
-\r
- return true;\r
- }\r
-};\r
-\r
-struct CV_GpuColumnSumTest: CvTest \r
-{\r
- CV_GpuColumnSumTest(): CvTest("GPU-ColumnSumTest", "columnSum") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- int cols = 375;\r
- int rows = 1072;\r
-\r
- Mat src(rows, cols, CV_32F);\r
- RNG rng(1);\r
- rng.fill(src, RNG::UNIFORM, Scalar(0), Scalar(1));\r
-\r
- GpuMat d_dst;\r
- columnSum(GpuMat(src), d_dst);\r
- \r
- Mat dst = d_dst;\r
- for (int j = 0; j < src.cols; ++j)\r
- {\r
- float a = src.at<float>(0, j);\r
- float b = dst.at<float>(0, j);\r
- if (fabs(a - b) > 0.5f)\r
- {\r
- ts->printf(CvTS::CONSOLE, "big diff at %d %d: %f %f\n", 0, j, a, b);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- for (int i = 1; i < src.rows; ++i)\r
- {\r
- for (int j = 0; j < src.cols; ++j)\r
- {\r
- float a = src.at<float>(i, j) += src.at<float>(i - 1, j);\r
- float b = dst.at<float>(i, j);\r
- if (fabs(a - b) > 0.5f)\r
- {\r
- ts->printf(CvTS::CONSOLE, "big diff at %d %d: %f %f\n", i, j, a, b);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- ts->printf(CvTS::CONSOLE, e.what());\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-};\r
-\r
-struct CV_GpuNormTest : CvTest \r
-{\r
- CV_GpuNormTest() : CvTest("GPU-Norm", "norm") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- RNG rng(0);\r
-\r
- int rows = rng.uniform(1, 500);\r
- int cols = rng.uniform(1, 500);\r
-\r
- for (int cn = 1; cn <= 4; ++cn)\r
- {\r
- test(NORM_L1, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
- test(NORM_L1, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_L1, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
- test(NORM_L1, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_L1, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_L1, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
-\r
- test(NORM_L2, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
- test(NORM_L2, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_L2, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
- test(NORM_L2, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_L2, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_L2, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
-\r
- test(NORM_INF, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
- test(NORM_INF, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_INF, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
- test(NORM_INF, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_INF, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
- test(NORM_INF, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
- }\r
- }\r
- catch (const cv::Exception& e)\r
- {\r
- ts->printf(CvTS::CONSOLE, e.what());\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)\r
- {\r
- mat.create(rows, cols, type);\r
- RNG rng(0);\r
- rng.fill(mat, RNG::UNIFORM, low, high);\r
- }\r
-\r
- void test(int norm_type, int rows, int cols, int depth, int cn, Scalar low, Scalar high)\r
- {\r
- int type = CV_MAKE_TYPE(depth, cn);\r
-\r
- Mat src;\r
- gen(src, rows, cols, type, low, high);\r
-\r
- double gold = norm(src, norm_type);\r
- double mine = norm(GpuMat(src), norm_type);\r
-\r
- if (abs(gold - mine) > 1e-3)\r
- {\r
- ts->printf(CvTS::CONSOLE, "failed test: gold=%f, mine=%f, norm_type=%d, rows=%d, "\r
- "cols=%d, depth=%d, cn=%d\n", gold, mine, norm_type, rows, cols, depth, cn);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// reprojectImageTo3D\r
-class CV_GpuReprojectImageTo3DTest : public CvTest\r
-{\r
-public:\r
- CV_GpuReprojectImageTo3DTest() : CvTest("GPU-ReprojectImageTo3D", "reprojectImageTo3D") {}\r
-\r
-protected:\r
- void run(int)\r
- {\r
- Mat disp(320, 240, CV_8UC1);\r
-\r
- RNG rng(*ts->get_rng());\r
- rng.fill(disp, RNG::UNIFORM, Scalar(5), Scalar(30));\r
-\r
- Mat Q(4, 4, CV_32FC1);\r
- rng.fill(Q, RNG::UNIFORM, Scalar(0.1), Scalar(1));\r
-\r
- Mat cpures;\r
- GpuMat gpures;\r
-\r
- reprojectImageTo3D(disp, cpures, Q, false);\r
- reprojectImageTo3D(GpuMat(disp), gpures, Q);\r
-\r
- Mat temp = gpures;\r
-\r
- for (int y = 0; y < cpures.rows; ++y)\r
- {\r
- const Vec3f* cpu_row = cpures.ptr<Vec3f>(y);\r
- const Vec4f* gpu_row = temp.ptr<Vec4f>(y);\r
- for (int x = 0; x < cpures.cols; ++x)\r
- {\r
- Vec3f a = cpu_row[x];\r
- Vec4f b = gpu_row[x];\r
-\r
- if (fabs(a[0] - b[0]) > 1e-5 || fabs(a[1] - b[1]) > 1e-5 || fabs(a[2] - b[2]) > 1e-5)\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- }\r
- }\r
-};\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-/////////////////// tests registration /////////////////////////////////////\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-// If we comment some tests, we may foget/miss to uncomment it after.\r
-// Placing all test definitions in one place\r
-// makes us know about what tests are commented.\r
-\r
-CV_GpuImageThresholdTest CV_GpuImageThreshold_test;\r
-CV_GpuNppImageResizeTest CV_GpuNppImageResize_test;\r
-CV_GpuNppImageCopyMakeBorderTest CV_GpuNppImageCopyMakeBorder_test;\r
-CV_GpuNppImageWarpAffineTest CV_GpuNppImageWarpAffine_test;\r
-CV_GpuNppImageWarpPerspectiveTest CV_GpuNppImageWarpPerspective_test;\r
-CV_GpuNppImageIntegralTest CV_GpuNppImageIntegral_test;\r
-//CV_GpuNppImageCannyTest CV_GpuNppImageCanny_test;\r
-CV_GpuCvtColorTest CV_GpuCvtColor_test;\r
-CV_GpuHistogramsTest CV_GpuHistograms_test;\r
-CV_GpuCornerHarrisTest CV_GpuCornerHarris_test;\r
-CV_GpuCornerMinEigenValTest CV_GpuCornerMinEigenVal_test;\r
-CV_GpuColumnSumTest CV_GpuColumnSum_test;\r
-CV_GpuNormTest CV_GpuNormTest_test;\r
-CV_GpuReprojectImageTo3DTest CV_GpuReprojectImageTo3D_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other GpuMaterials provided with the distribution.\r
-//\r
-// * The name of the copyright holders may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or bpied warranties, including, but not limited to, the bpied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-#include <string>\r
-#include <iostream>\r
-\r
-//#define SHOW_TIME\r
-\r
-#ifdef SHOW_TIME\r
-#include <ctime>\r
-#define F(x) x\r
-#else\r
-#define F(x)\r
-#endif\r
-\r
-using namespace cv;\r
-using namespace std;\r
-\r
-struct CV_GpuMatchTemplateTest: CvTest \r
-{\r
- CV_GpuMatchTemplateTest(): CvTest("GPU-MatchTemplateTest", "matchTemplate") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- if (!double_ok)\r
- {\r
- // For sqrIntegral\r
- ts->printf(CvTS::CONSOLE, "\nCode and device double support is required (CC >= 1.3)");\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- Mat image, templ;\r
- Mat dst_gold;\r
- gpu::GpuMat dst;\r
- int n, m, h, w;\r
- F(clock_t t;)\r
-\r
- RNG rng(*ts->get_rng());\r
-\r
- for (int cn = 1; cn <= 4; ++cn)\r
- {\r
- F(ts->printf(CvTS::CONSOLE, "cn: %d\n", cn);)\r
- for (int i = 0; i <= 0; ++i)\r
- {\r
- n = rng.uniform(30, 100);\r
- m = rng.uniform(30, 100);\r
- h = rng.uniform(5, n - 1);\r
- w = rng.uniform(5, m - 1);\r
-\r
- gen(image, n, m, CV_8U, cn);\r
- gen(templ, h, w, CV_8U, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_SQDIFF);\r
- F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_SQDIFF);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), 5 * h * w * 1e-4f, "SQDIFF 8U")) return;\r
-\r
- gen(image, n, m, CV_8U, cn);\r
- gen(templ, h, w, CV_8U, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_SQDIFF_NORMED);\r
- F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_SQDIFF_NORMED);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), h * w * 1e-5f, "SQDIFF_NOREMD 8U")) return;\r
-\r
- gen(image, n, m, CV_8U, cn);\r
- gen(templ, h, w, CV_8U, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_CCORR);\r
- F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), 5 * h * w * cn * cn * 1e-5f, "CCORR 8U")) return;\r
-\r
- gen(image, n, m, CV_8U, cn);\r
- gen(templ, h, w, CV_8U, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_CCORR_NORMED);\r
- F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR_NORMED);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), h * w * 1e-6f, "CCORR_NORMED 8U")) return;\r
-\r
- gen(image, n, m, CV_8U, cn);\r
- gen(templ, h, w, CV_8U, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_CCOEFF);\r
- F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCOEFF);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), 5 * h * w * cn * cn * 1e-5f, "CCOEFF 8U")) return;\r
-\r
- gen(image, n, m, CV_8U, cn);\r
- gen(templ, h, w, CV_8U, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_CCOEFF_NORMED);\r
- F(cout << "depth: 8U cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCOEFF_NORMED);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), h * w * 1e-6f, "CCOEFF_NORMED 8U")) return;\r
-\r
- gen(image, n, m, CV_32F, cn);\r
- gen(templ, h, w, CV_32F, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_SQDIFF);\r
- F(cout << "depth: 32F cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_SQDIFF);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), 0.25f * h * w * 1e-5f, "SQDIFF 32F")) return;\r
-\r
- gen(image, n, m, CV_32F, cn);\r
- gen(templ, h, w, CV_32F, cn);\r
- F(t = clock();)\r
- matchTemplate(image, templ, dst_gold, CV_TM_CCORR);\r
- F(cout << "depth: 32F cn: " << cn << " n: " << n << " m: " << m << " w: " << w << " h: " << h << endl;)\r
- F(cout << "cpu:" << clock() - t << endl;)\r
- F(t = clock();)\r
- gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR);\r
- F(cout << "gpu_block: " << clock() - t << endl;)\r
- if (!check(dst_gold, Mat(dst), 0.25f * h * w * 1e-5f, "CCORR 32F")) return;\r
- }\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- ts->printf(CvTS::CONSOLE, e.what());\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-\r
- void gen(Mat& a, int rows, int cols, int depth, int cn)\r
- {\r
- RNG rng;\r
- a.create(rows, cols, CV_MAKETYPE(depth, cn));\r
- if (depth == CV_8U)\r
- rng.fill(a, RNG::UNIFORM, Scalar::all(1), Scalar::all(10));\r
- else if (depth == CV_32F)\r
- rng.fill(a, RNG::UNIFORM, Scalar::all(0.001f), Scalar::all(1.f));\r
- }\r
-\r
- bool check(const Mat& a, const Mat& b, float max_err, const string& method="")\r
- {\r
- if (a.size() != b.size())\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad size, method=%s\n", method.c_str());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
-\r
- //for (int i = 0; i < a.rows; ++i)\r
- //{\r
- // for (int j = 0; j < a.cols; ++j)\r
- // {\r
- // float a_ = a.at<float>(i, j);\r
- // float b_ = b.at<float>(i, j);\r
- // if (fabs(a_ - b_) > max_err)\r
- // {\r
- // ts->printf(CvTS::CONSOLE, "a=%f, b=%f, i=%d, j=%d\n", a_, b_, i, j);\r
- // cin.get();\r
- // }\r
- // }\r
- //}\r
-\r
- float err = (float)norm(a, b, NORM_INF);\r
- if (err > max_err)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad accuracy: %f, method=%s\n", err, method.c_str());\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-} match_template_test;\r
-\r
-struct CV_GpuMatchTemplateFindPatternInBlackTest: CvTest \r
-{\r
- CV_GpuMatchTemplateFindPatternInBlackTest()\r
- : CvTest("GPU-MatchTemplateFindPatternInBlackTest", "matchTemplate") {}\r
-\r
- void run(int)\r
- {\r
- try\r
- {\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- if (!double_ok)\r
- {\r
- // For sqrIntegral\r
- ts->printf(CvTS::CONSOLE, "\nCode and device double support is required (CC >= 1.3)");\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- Mat image = imread(std::string(ts->get_data_path()) + "matchtemplate/black.png");\r
- if (image.empty())\r
- {\r
- ts->printf(CvTS::CONSOLE, "can't open file '%s'", (std::string(ts->get_data_path()) \r
- + "matchtemplate/black.png").c_str());\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- Mat pattern = imread(std::string(ts->get_data_path()) + "matchtemplate/cat.png");\r
- if (pattern.empty())\r
- {\r
- ts->printf(CvTS::CONSOLE, "can't open file '%s'", (std::string(ts->get_data_path()) \r
- + "matchtemplate/cat.png").c_str());\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- gpu::GpuMat d_image(image);\r
- gpu::GpuMat d_pattern(pattern);\r
- gpu::GpuMat d_result;\r
-\r
- double maxValue;\r
- Point maxLoc;\r
- Point maxLocGold(284, 12);\r
-\r
- gpu::matchTemplate(d_image, d_pattern, d_result, CV_TM_CCOEFF_NORMED);\r
- gpu::minMaxLoc(d_result, NULL, &maxValue, NULL, &maxLoc );\r
- if (maxLoc != maxLocGold)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad match (CV_TM_CCOEFF_NORMED): %d %d, must be at: %d %d", \r
- maxLoc.x, maxLoc.y, maxLocGold.x, maxLocGold.y);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- gpu::matchTemplate(d_image, d_pattern, d_result, CV_TM_CCORR_NORMED);\r
- gpu::minMaxLoc(d_result, NULL, &maxValue, NULL, &maxLoc );\r
- if (maxLoc != maxLocGold)\r
- {\r
- ts->printf(CvTS::CONSOLE, "bad match (CV_TM_CCORR_NORMED): %d %d, must be at: %d %d", \r
- maxLoc.x, maxLoc.y, maxLocGold.x, maxLocGold.y);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- catch (const Exception& e)\r
- {\r
- ts->printf(CvTS::CONSOLE, e.what());\r
- if (!check_and_treat_gpu_exception(e, ts)) throw;\r
- return;\r
- }\r
- }\r
-} match_templet_find_bordered_pattern_test;
\ No newline at end of file
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-#include <iostream>\r
-#include <string>\r
-\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-\r
-\r
-struct CV_GpuMeanShiftTest : public CvTest\r
-{\r
- CV_GpuMeanShiftTest(): CvTest( "GPU-MeanShift", "MeanShift" ){}\r
-\r
- void run(int)\r
- {\r
- bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
- if (!cc12_ok)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nCompute capability 1.2 is required");\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- int spatialRad = 30;\r
- int colorRad = 30;\r
-\r
- cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");\r
- cv::Mat img_template; \r
- \r
- if (cv::gpu::TargetArchs::builtWith(cv::gpu::FEATURE_SET_COMPUTE_20) &&\r
- cv::gpu::DeviceInfo().supports(cv::gpu::FEATURE_SET_COMPUTE_20))\r
- img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result.png");\r
- else\r
- img_template = cv::imread(std::string(ts->get_data_path()) + "meanshift/con_result_CC1X.png");\r
-\r
- if (img.empty() || img_template.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- cv::Mat rgba;\r
- cvtColor(img, rgba, CV_BGR2BGRA);\r
-\r
- try\r
- {\r
- cv::gpu::GpuMat res;\r
- cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), res, spatialRad, colorRad );\r
-\r
- if (res.type() != CV_8UC4)\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- cv::Mat result;\r
- res.download(result);\r
-\r
- uchar maxDiff = 0;\r
- for (int j = 0; j < result.rows; ++j)\r
- {\r
- const uchar* res_line = result.ptr<uchar>(j);\r
- const uchar* ref_line = img_template.ptr<uchar>(j);\r
-\r
- for (int i = 0; i < result.cols; ++i)\r
- {\r
- for (int k = 0; k < 3; ++k)\r
- {\r
- const uchar& ch1 = res_line[result.channels()*i + k];\r
- const uchar& ch2 = ref_line[img_template.channels()*i + k];\r
- uchar diff = static_cast<uchar>(abs(ch1 - ch2));\r
- if (maxDiff < diff)\r
- maxDiff = diff;\r
- }\r
- }\r
- }\r
- if (maxDiff > 0) \r
- {\r
- ts->printf(CvTS::LOG, "\nMeanShift maxDiff = %d\n", maxDiff);\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(CvTS::OK);\r
- }\r
-\r
-};\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-/////////////////// tests registration /////////////////////////////////////\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-CV_GpuMeanShiftTest CV_GpuMeanShift_test;\r
-\r
-struct CV_GpuMeanShiftProcTest : public CvTest\r
-{\r
- CV_GpuMeanShiftProcTest(): CvTest( "GPU-MeanShiftProc", "MeanShiftProc" ){}\r
-\r
- void run(int)\r
- {\r
- bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
- if (!cc12_ok)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nCompute capability 1.2 is required");\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- int spatialRad = 30;\r
- int colorRad = 30;\r
-\r
- cv::Mat img = cv::imread(std::string(ts->get_data_path()) + "meanshift/cones.png");\r
-\r
- if (img.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- cv::Mat rgba;\r
- cvtColor(img, rgba, CV_BGR2BGRA);\r
-\r
- try\r
- {\r
- cv::gpu::GpuMat h_rmap_filtered;\r
- cv::gpu::meanShiftFiltering( cv::gpu::GpuMat(rgba), h_rmap_filtered, spatialRad, colorRad );\r
-\r
- cv::gpu::GpuMat d_rmap;\r
- cv::gpu::GpuMat d_spmap;\r
- cv::gpu::meanShiftProc( cv::gpu::GpuMat(rgba), d_rmap, d_spmap, spatialRad, colorRad );\r
-\r
- if (d_rmap.type() != CV_8UC4)\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
-\r
- cv::Mat rmap_filtered;\r
- h_rmap_filtered.download(rmap_filtered);\r
-\r
- cv::Mat rmap;\r
- d_rmap.download(rmap);\r
-\r
- uchar maxDiff = 0;\r
- for (int j = 0; j < rmap_filtered.rows; ++j)\r
- {\r
- const uchar* res_line = rmap_filtered.ptr<uchar>(j);\r
- const uchar* ref_line = rmap.ptr<uchar>(j);\r
-\r
- for (int i = 0; i < rmap_filtered.cols; ++i)\r
- {\r
- for (int k = 0; k < 3; ++k)\r
- {\r
- const uchar& ch1 = res_line[rmap_filtered.channels()*i + k];\r
- const uchar& ch2 = ref_line[rmap.channels()*i + k];\r
- uchar diff = static_cast<uchar>(abs(ch1 - ch2));\r
- if (maxDiff < diff)\r
- maxDiff = diff;\r
- }\r
- }\r
- }\r
- if (maxDiff > 0) \r
- {\r
- ts->printf(CvTS::LOG, "\nMeanShiftProc maxDiff = %d\n", maxDiff);\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- cv::Mat spmap;\r
- d_spmap.download(spmap);\r
-\r
- cv::Mat spmap_template;\r
- cv::FileStorage fs;\r
-\r
- if (cv::gpu::TargetArchs::builtWith(cv::gpu::FEATURE_SET_COMPUTE_20) &&\r
- cv::gpu::DeviceInfo().supports(cv::gpu::FEATURE_SET_COMPUTE_20))\r
- fs.open(std::string(ts->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);\r
- else\r
- fs.open(std::string(ts->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);\r
- fs["spmap"] >> spmap_template;\r
-\r
- for (int y = 0; y < spmap.rows; ++y) {\r
- for (int x = 0; x < spmap.cols; ++x) {\r
- cv::Point_<short> expected = spmap_template.at<cv::Point_<short> >(y, x);\r
- cv::Point_<short> actual = spmap.at<cv::Point_<short> >(y, x);\r
- int diff = (expected - actual).dot(expected - actual);\r
- if (actual != expected) {\r
- ts->printf(CvTS::LOG, "\nMeanShiftProc SpMap is bad, diff=%d\n", diff);\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
- }\r
- }\r
-\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(CvTS::OK);\r
- }\r
-\r
-};\r
-\r
-CV_GpuMeanShiftProcTest CV_GpuMeanShiftProc_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include <iostream>\r
-#include <string>\r
-#include <iosfwd>\r
-#include "gputest.hpp"\r
-using namespace cv;\r
-using namespace cv::gpu;\r
-using namespace std;\r
-\r
-struct CV_GpuMeanShiftSegmentationTest : public CvTest {\r
- CV_GpuMeanShiftSegmentationTest() : CvTest( "GPU-MeanShiftSegmentation", "MeanShiftSegmentation" ) {}\r
-\r
- void run(int) \r
- {\r
- try \r
- {\r
- bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
- if (!cc12_ok)\r
- {\r
- ts->printf(CvTS::CONSOLE, "\nCompute capability 1.2 is required");\r
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);\r
- return;\r
- }\r
-\r
- Mat img_rgb = imread(string(ts->get_data_path()) + "meanshift/cones.png");\r
- if (img_rgb.empty())\r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
-\r
- Mat img;\r
- cvtColor(img_rgb, img, CV_BGR2BGRA);\r
- \r
-\r
- for (int minsize = 0; minsize < 2000; minsize = (minsize + 1) * 4) \r
- {\r
- stringstream path;\r
- path << ts->get_data_path() << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;\r
- if (TargetArchs::builtWith(FEATURE_SET_COMPUTE_20) && DeviceInfo().supports(FEATURE_SET_COMPUTE_20))\r
- path << ".png";\r
- else\r
- path << "_CC1X.png";\r
-\r
- Mat dst;\r
- meanShiftSegmentation((GpuMat)img, dst, 10, 10, minsize);\r
- Mat dst_rgb;\r
- cvtColor(dst, dst_rgb, CV_BGRA2BGR);\r
-\r
- //imwrite(path.str(), dst_rgb);\r
- Mat dst_ref = imread(path.str());\r
- if (dst_ref.empty()) \r
- {\r
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);\r
- return;\r
- }\r
- if (CheckSimilarity(dst_rgb, dst_ref, 1e-3f) != CvTS::OK)\r
- {\r
- ts->printf(CvTS::LOG, "\ndiffers from image *minsize%d.png\n", minsize);\r
- ts->set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);\r
- }\r
- }\r
- }\r
- catch (const cv::Exception& e) \r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw;\r
- return;\r
- }\r
-\r
- ts->set_failed_test_info(CvTS::OK);\r
- } \r
-\r
- int CheckSimilarity(const Mat& m1, const Mat& m2, float max_err)\r
- {\r
- Mat diff;\r
- cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);\r
-\r
- float err = abs(diff.at<float>(0, 0) - 1.f);\r
-\r
- if (err > max_err)\r
- return CvTS::FAIL_INVALID_OUTPUT;\r
-\r
- return CvTS::OK;\r
- }\r
-\r
-\r
-} ms_segm_test;\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _ncvautotestlister_hpp_\r
-#define _ncvautotestlister_hpp_\r
-\r
-#include <vector>\r
-\r
-#include "NCVTest.hpp"\r
-\r
-class NCVAutoTestLister\r
-{\r
-public:\r
-\r
- NCVAutoTestLister(std::string testSuiteName, NcvBool bStopOnFirstFail=false, NcvBool bCompactOutput=true)\r
- :\r
- testSuiteName(testSuiteName),\r
- bStopOnFirstFail(bStopOnFirstFail),\r
- bCompactOutput(bCompactOutput)\r
- {\r
- }\r
-\r
- void add(INCVTest *test)\r
- {\r
- this->tests.push_back(test);\r
- }\r
-\r
- bool invoke()\r
- {\r
- Ncv32u nPassed = 0;\r
- Ncv32u nFailed = 0;\r
- Ncv32u nFailedMem = 0;\r
-\r
- if (bCompactOutput)\r
- {\r
- printf("Test suite '%s' with %d tests\n", \r
- testSuiteName.c_str(),\r
- (int)(this->tests.size()));\r
- }\r
-\r
- for (Ncv32u i=0; i<this->tests.size(); i++)\r
- {\r
- INCVTest &curTest = *tests[i];\r
-\r
- NCVTestReport curReport;\r
- bool res = curTest.executeTest(curReport);\r
-\r
- if (!bCompactOutput)\r
- {\r
- printf("Test %3i %16s; Consumed mem GPU = %8d, CPU = %8d; %s\n",\r
- i,\r
- curTest.getName().c_str(),\r
- curReport.statsNums["MemGPU"],\r
- curReport.statsNums["MemCPU"],\r
- curReport.statsText["rcode"].c_str());\r
- }\r
-\r
- if (res)\r
- {\r
- nPassed++;\r
- if (bCompactOutput)\r
- {\r
- printf(".");\r
- }\r
- }\r
- else\r
- {\r
- if (!curReport.statsText["rcode"].compare("FAILED"))\r
- {\r
- nFailed++;\r
- if (bCompactOutput)\r
- {\r
- printf("x");\r
- }\r
- if (bStopOnFirstFail)\r
- {\r
- break;\r
- }\r
- }\r
- else\r
- {\r
- nFailedMem++;\r
- if (bCompactOutput)\r
- {\r
- printf("m");\r
- }\r
- }\r
- }\r
- fflush(stdout);\r
- }\r
- if (bCompactOutput)\r
- {\r
- printf("\n");\r
- }\r
-\r
- printf("Test suite '%s' complete: %d total, %d passed, %d memory errors, %d failed\n\n", \r
- testSuiteName.c_str(),\r
- (int)(this->tests.size()),\r
- nPassed,\r
- nFailedMem,\r
- nFailed);\r
-\r
- bool passed = nFailed == 0 && nFailedMem == 0;\r
- return passed;\r
- }\r
-\r
- ~NCVAutoTestLister()\r
- {\r
- for (Ncv32u i=0; i<this->tests.size(); i++)\r
- {\r
- delete tests[i];\r
- }\r
- }\r
-\r
-private:\r
-\r
- NcvBool bStopOnFirstFail;\r
- NcvBool bCompactOutput;\r
- std::string testSuiteName;\r
- std::vector<INCVTest *> tests;\r
-};\r
-\r
-#endif // _ncvautotestlister_hpp_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _ncvtest_hpp_\r
-#define _ncvtest_hpp_\r
-\r
-#pragma warning( disable : 4201 4408 4127 4100)\r
-\r
-#include <string>\r
-#include <vector>\r
-#include <map>\r
-#include <memory>\r
-#include <algorithm>\r
-#include <fstream>\r
-\r
-#include <cuda_runtime.h>\r
-#include "NPP_staging.hpp"\r
-\r
-\r
-struct NCVTestReport\r
-{\r
- std::map<std::string, Ncv32u> statsNums;\r
- std::map<std::string, std::string> statsText;\r
-};\r
-\r
-\r
-class INCVTest\r
-{\r
-public:\r
- virtual bool executeTest(NCVTestReport &report) = 0;\r
- virtual std::string getName() const = 0;\r
-};\r
-\r
-\r
-class NCVTestProvider : public INCVTest\r
-{\r
-public:\r
-\r
- NCVTestProvider(std::string testName)\r
- :\r
- testName(testName)\r
- {\r
- int devId;\r
- ncvAssertPrintReturn(cudaSuccess == cudaGetDevice(&devId), "Error returned from cudaGetDevice", );\r
- ncvAssertPrintReturn(cudaSuccess == cudaGetDeviceProperties(&this->devProp, devId), "Error returned from cudaGetDeviceProperties", );\r
- }\r
-\r
- virtual bool init() = 0;\r
- virtual bool process() = 0;\r
- virtual bool deinit() = 0;\r
- virtual bool toString(std::ofstream &strOut) = 0;\r
-\r
- virtual std::string getName() const\r
- {\r
- return this->testName;\r
- }\r
-\r
- virtual ~NCVTestProvider()\r
- {\r
- deinitMemory();\r
- }\r
-\r
- virtual bool executeTest(NCVTestReport &report)\r
- {\r
- bool res;\r
- report.statsText["rcode"] = "FAILED";\r
-\r
- res = initMemory(report);\r
- if (!res)\r
- {\r
- dumpToFile(report);\r
- deinitMemory();\r
- return false;\r
- }\r
-\r
- res = init();\r
- if (!res)\r
- {\r
- dumpToFile(report);\r
- deinit();\r
- deinitMemory();\r
- return false;\r
- }\r
-\r
- res = process();\r
- if (!res)\r
- {\r
- dumpToFile(report);\r
- deinit();\r
- deinitMemory();\r
- return false;\r
- }\r
-\r
- res = deinit();\r
- if (!res)\r
- {\r
- dumpToFile(report);\r
- deinitMemory();\r
- return false;\r
- }\r
-\r
- deinitMemory();\r
-\r
- report.statsText["rcode"] = "Passed";\r
- return true;\r
- }\r
-\r
-protected:\r
-\r
- cudaDeviceProp devProp;\r
- std::auto_ptr<INCVMemAllocator> allocatorGPU;\r
- std::auto_ptr<INCVMemAllocator> allocatorCPU;\r
-\r
-private:\r
-\r
- std::string testName;\r
-\r
- bool initMemory(NCVTestReport &report)\r
- {\r
- this->allocatorGPU.reset(new NCVMemStackAllocator(devProp.textureAlignment));\r
- this->allocatorCPU.reset(new NCVMemStackAllocator(devProp.textureAlignment));\r
-\r
- if (!this->allocatorGPU.get()->isInitialized() ||\r
- !this->allocatorCPU.get()->isInitialized())\r
- {\r
- report.statsText["rcode"] = "Memory FAILED";\r
- return false;\r
- }\r
-\r
- if (!this->process())\r
- {\r
- report.statsText["rcode"] = "Memory FAILED";\r
- return false;\r
- }\r
-\r
- Ncv32u maxGPUsize = (Ncv32u)this->allocatorGPU.get()->maxSize();\r
- Ncv32u maxCPUsize = (Ncv32u)this->allocatorCPU.get()->maxSize();\r
-\r
- report.statsNums["MemGPU"] = maxGPUsize;\r
- report.statsNums["MemCPU"] = maxCPUsize;\r
-\r
- this->allocatorGPU.reset(new NCVMemStackAllocator(NCVMemoryTypeDevice, maxGPUsize, devProp.textureAlignment));\r
-\r
- this->allocatorCPU.reset(new NCVMemStackAllocator(NCVMemoryTypeHostPinned, maxCPUsize, devProp.textureAlignment));\r
-\r
- if (!this->allocatorGPU.get()->isInitialized() ||\r
- !this->allocatorCPU.get()->isInitialized())\r
- {\r
- report.statsText["rcode"] = "Memory FAILED";\r
- return false;\r
- }\r
-\r
- return true;\r
- }\r
-\r
- void deinitMemory()\r
- {\r
- this->allocatorGPU.reset();\r
- this->allocatorCPU.reset();\r
- }\r
-\r
- void dumpToFile(NCVTestReport &report)\r
- {\r
- bool bReasonMem = (0 == report.statsText["rcode"].compare("Memory FAILED"));\r
- std::string fname = "TestDump_";\r
- fname += (bReasonMem ? "m_" : "") + this->testName + ".log";\r
- std::ofstream stream(fname.c_str(), std::ios::trunc | std::ios::out);\r
- if (!stream.is_open()) return;\r
-\r
- stream << "NCV Test Failure Log: " << this->testName << std::endl;\r
- stream << "====================================================" << std::endl << std::endl;\r
- stream << "Test initialization report: " << std::endl;\r
- for (std::map<std::string,std::string>::iterator it=report.statsText.begin();\r
- it != report.statsText.end(); it++)\r
- {\r
- stream << it->first << "=" << it->second << std::endl;\r
- }\r
- for (std::map<std::string,Ncv32u>::iterator it=report.statsNums.begin();\r
- it != report.statsNums.end(); it++)\r
- {\r
- stream << it->first << "=" << it->second << std::endl;\r
- }\r
- stream << std::endl;\r
-\r
- stream << "Test initialization parameters: " << std::endl;\r
- bool bSerializeRes = false;\r
- try\r
- {\r
- bSerializeRes = this->toString(stream);\r
- }\r
- catch (...)\r
- {\r
- }\r
-\r
- if (!bSerializeRes)\r
- {\r
- stream << "Couldn't retrieve object dump" << std::endl;\r
- }\r
-\r
- stream.flush();\r
- }\r
-};\r
-\r
-#endif // _ncvtest_hpp_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _ncvtestsourceprovider_hpp_\r
-#define _ncvtestsourceprovider_hpp_\r
-\r
-#include <memory>\r
-\r
-#include "NCV.hpp"\r
-#include <opencv2/highgui/highgui.hpp>\r
-\r
-\r
-template <class T>\r
-class NCVTestSourceProvider\r
-{\r
-public:\r
-\r
- NCVTestSourceProvider(Ncv32u seed, T rangeLow, T rangeHigh, Ncv32u maxWidth, Ncv32u maxHeight)\r
- :\r
- bInit(false)\r
- {\r
- ncvAssertPrintReturn(rangeLow < rangeHigh, "NCVTestSourceProvider ctor:: Invalid range", );\r
-\r
- int devId;\r
- cudaDeviceProp devProp;\r
- ncvAssertPrintReturn(cudaSuccess == cudaGetDevice(&devId), "Error returned from cudaGetDevice", );\r
- ncvAssertPrintReturn(cudaSuccess == cudaGetDeviceProperties(&devProp, devId), "Error returned from cudaGetDeviceProperties", );\r
-\r
- //Ncv32u maxWpitch = alignUp(maxWidth * sizeof(T), devProp.textureAlignment);\r
-\r
- allocatorCPU.reset(new NCVMemNativeAllocator(NCVMemoryTypeHostPinned, devProp.textureAlignment));\r
- data.reset(new NCVMatrixAlloc<T>(*this->allocatorCPU.get(), maxWidth, maxHeight));\r
- ncvAssertPrintReturn(data.get()->isMemAllocated(), "NCVTestSourceProvider ctor:: Matrix not allocated", );\r
-\r
- this->dataWidth = maxWidth;\r
- this->dataHeight = maxHeight;\r
-\r
- srand(seed);\r
-\r
- for (Ncv32u i=0; i<maxHeight; i++)\r
- {\r
- for (Ncv32u j=0; j<data.get()->stride(); j++)\r
- {\r
- data.get()->ptr()[i * data.get()->stride() + j] =\r
- (T)(((1.0 * rand()) / RAND_MAX) * (rangeHigh - rangeLow) + rangeLow);\r
- }\r
- }\r
-\r
- this->bInit = true;\r
- }\r
-\r
- NCVTestSourceProvider(std::string pgmFilename)\r
- :\r
- bInit(false)\r
- {\r
- ncvAssertPrintReturn(sizeof(T) == 1, "NCVTestSourceProvider ctor:: PGM constructor complies only with 8bit types", );\r
-\r
- cv::Mat image = cv::imread(pgmFilename); \r
- ncvAssertPrintReturn(!image.empty(), "NCVTestSourceProvider ctor:: PGM file error", );\r
-\r
- int devId;\r
- cudaDeviceProp devProp;\r
- ncvAssertPrintReturn(cudaSuccess == cudaGetDevice(&devId), "Error returned from cudaGetDevice", );\r
- ncvAssertPrintReturn(cudaSuccess == cudaGetDeviceProperties(&devProp, devId), "Error returned from cudaGetDeviceProperties", );\r
-\r
- allocatorCPU.reset(new NCVMemNativeAllocator(NCVMemoryTypeHostPinned, devProp.textureAlignment));\r
- data.reset(new NCVMatrixAlloc<T>(*this->allocatorCPU.get(), image.cols, image.rows));\r
- ncvAssertPrintReturn(data.get()->isMemAllocated(), "NCVTestSourceProvider ctor:: Matrix not allocated", );\r
-\r
- this->dataWidth = image.cols;\r
- this->dataHeight = image.rows;\r
-\r
- cv::Mat hdr(image.size(), CV_8UC1, data.get()->ptr(), data.get()->pitch());\r
- image.copyTo(hdr);\r
- \r
- this->bInit = true;\r
- }\r
-\r
- NcvBool fill(NCVMatrix<T> &dst)\r
- {\r
- ncvAssertReturn(this->isInit() &&\r
- dst.memType() == allocatorCPU.get()->memType(), false);\r
-\r
- if (dst.width() == 0 || dst.height() == 0)\r
- {\r
- return true;\r
- }\r
-\r
- for (Ncv32u i=0; i<dst.height(); i++)\r
- {\r
- Ncv32u srcLine = i % this->dataHeight;\r
-\r
- Ncv32u srcFullChunks = dst.width() / this->dataWidth;\r
- for (Ncv32u j=0; j<srcFullChunks; j++)\r
- {\r
- memcpy(dst.ptr() + i * dst.stride() + j * this->dataWidth,\r
- this->data.get()->ptr() + this->data.get()->stride() * srcLine,\r
- this->dataWidth * sizeof(T));\r
- }\r
-\r
- Ncv32u srcLastChunk = dst.width() % this->dataWidth;\r
- memcpy(dst.ptr() + i * dst.stride() + srcFullChunks * this->dataWidth,\r
- this->data.get()->ptr() + this->data.get()->stride() * srcLine,\r
- srcLastChunk * sizeof(T));\r
- }\r
-\r
- return true;\r
- }\r
-\r
- NcvBool fill(NCVVector<T> &dst)\r
- {\r
- ncvAssertReturn(this->isInit() &&\r
- dst.memType() == allocatorCPU.get()->memType(), false);\r
-\r
- if (dst.length() == 0)\r
- {\r
- return true;\r
- }\r
-\r
- Ncv32u srcLen = this->dataWidth * this->dataHeight;\r
-\r
- Ncv32u srcFullChunks = (Ncv32u)dst.length() / srcLen;\r
- for (Ncv32u j=0; j<srcFullChunks; j++)\r
- {\r
- memcpy(dst.ptr() + j * srcLen, this->data.get()->ptr(), srcLen * sizeof(T));\r
- }\r
-\r
- Ncv32u srcLastChunk = dst.length() % srcLen;\r
- memcpy(dst.ptr() + srcFullChunks * srcLen, this->data.get()->ptr(), srcLastChunk * sizeof(T));\r
-\r
- return true;\r
- }\r
-\r
- ~NCVTestSourceProvider()\r
- {\r
- data.reset();\r
- allocatorCPU.reset();\r
- }\r
-\r
-private:\r
-\r
- NcvBool isInit(void)\r
- {\r
- return this->bInit;\r
- }\r
-\r
- NcvBool bInit;\r
- std::auto_ptr< INCVMemAllocator > allocatorCPU;\r
- std::auto_ptr< NCVMatrixAlloc<T> > data;\r
- Ncv32u dataWidth;\r
- Ncv32u dataHeight;\r
-};\r
-\r
-#endif // _ncvtestsourceprovider_hpp_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include "TestCompact.h"\r
-\r
-\r
-TestCompact::TestCompact(std::string testName, NCVTestSourceProvider<Ncv32u> &src,\r
- Ncv32u length, Ncv32u badElem, Ncv32u badElemPercentage)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- length(length),\r
- badElem(badElem),\r
- badElemPercentage(badElemPercentage > 100 ? 100 : badElemPercentage)\r
-{\r
-}\r
-\r
-\r
-bool TestCompact::toString(std::ofstream &strOut)\r
-{\r
- strOut << "length=" << length << std::endl;\r
- strOut << "badElem=" << badElem << std::endl;\r
- strOut << "badElemPercentage=" << badElemPercentage << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestCompact::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-bool TestCompact::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- NCVVectorAlloc<Ncv32u> h_vecSrc(*this->allocatorCPU.get(), this->length);\r
- ncvAssertReturn(h_vecSrc.isMemAllocated(), false);\r
- NCVVectorAlloc<Ncv32u> d_vecSrc(*this->allocatorGPU.get(), this->length);\r
- ncvAssertReturn(d_vecSrc.isMemAllocated(), false);\r
-\r
- NCVVectorAlloc<Ncv32u> h_vecDst(*this->allocatorCPU.get(), this->length);\r
- ncvAssertReturn(h_vecDst.isMemAllocated(), false);\r
- NCVVectorAlloc<Ncv32u> d_vecDst(*this->allocatorGPU.get(), this->length);\r
- ncvAssertReturn(d_vecDst.isMemAllocated(), false);\r
- NCVVectorAlloc<Ncv32u> h_vecDst_d(*this->allocatorCPU.get(), this->length);\r
- ncvAssertReturn(h_vecDst_d.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_vecSrc), false);\r
- for (Ncv32u i=0; i<this->length; i++)\r
- {\r
- Ncv32u tmp = (h_vecSrc.ptr()[i]) & 0xFF;\r
- tmp = tmp * 99 / 255;\r
- if (tmp < this->badElemPercentage)\r
- {\r
- h_vecSrc.ptr()[i] = this->badElem;\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- NCVVectorAlloc<Ncv32u> h_dstLen(*this->allocatorCPU.get(), 1);\r
- ncvAssertReturn(h_dstLen.isMemAllocated(), false);\r
- Ncv32u bufSize;\r
- ncvStat = nppsStCompactGetSize_32u(this->length, &bufSize, this->devProp);\r
- ncvAssertReturn(NPPST_SUCCESS == ncvStat, false);\r
- NCVVectorAlloc<Ncv8u> d_tmpBuf(*this->allocatorGPU.get(), bufSize);\r
- ncvAssertReturn(d_tmpBuf.isMemAllocated(), false);\r
-\r
- Ncv32u h_outElemNum_h = 0;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- ncvStat = h_vecSrc.copySolid(d_vecSrc, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- ncvStat = nppsStCompact_32u(d_vecSrc.ptr(), this->length,\r
- d_vecDst.ptr(), h_dstLen.ptr(), this->badElem,\r
- d_tmpBuf.ptr(), bufSize, this->devProp);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- ncvStat = d_vecDst.copySolid(h_vecDst_d, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppsStCompact_32u_host(h_vecSrc.ptr(), this->length, h_vecDst.ptr(), &h_outElemNum_h, this->badElem);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- if (h_dstLen.ptr()[0] != h_outElemNum_h)\r
- {\r
- bLoopVirgin = false;\r
- }\r
- else\r
- {\r
- for (Ncv32u i=0; bLoopVirgin && i < h_outElemNum_h; i++)\r
- {\r
- if (h_vecDst.ptr()[i] != h_vecDst_d.ptr()[i])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestCompact::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testhypothesescompact_h_\r
-#define _testhypothesescompact_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestCompact : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestCompact(std::string testName, NCVTestSourceProvider<Ncv32u> &src,\r
- Ncv32u length, Ncv32u badElem, Ncv32u badElemPercentage);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestCompact(const TestCompact&);\r
- TestCompact& operator=(const TestCompact&); \r
-\r
-\r
- NCVTestSourceProvider<Ncv32u> &src;\r
- Ncv32u length;\r
- Ncv32u badElem;\r
- Ncv32u badElemPercentage;\r
-};\r
-\r
-#endif // _testhypothesescompact_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include "TestDrawRects.h"\r
-#include "NCVHaarObjectDetection.hpp"\r
-\r
-\r
-template <class T>\r
-TestDrawRects<T>::TestDrawRects(std::string testName, NCVTestSourceProvider<T> &src, NCVTestSourceProvider<Ncv32u> &src32u,\r
- Ncv32u width, Ncv32u height, Ncv32u numRects, T color)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- src32u(src32u),\r
- width(width),\r
- height(height),\r
- numRects(numRects),\r
- color(color)\r
-{\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestDrawRects<T>::toString(std::ofstream &strOut)\r
-{\r
- strOut << "sizeof(T)=" << sizeof(T) << std::endl;\r
- strOut << "width=" << width << std::endl;\r
- strOut << "height=" << height << std::endl;\r
- strOut << "numRects=" << numRects << std::endl;\r
- strOut << "color=" << color << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestDrawRects<T>::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestDrawRects<T>::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- NCVMatrixAlloc<T> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_img_d(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img_d.isMemAllocated(), false);\r
-\r
- NCVVectorAlloc<NcvRect32u> d_rects(*this->allocatorGPU.get(), this->numRects);\r
- ncvAssertReturn(d_rects.isMemAllocated(), false);\r
- NCVVectorAlloc<NcvRect32u> h_rects(*this->allocatorCPU.get(), this->numRects);\r
- ncvAssertReturn(h_rects.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- //fill vector of rectangles with random rects covering the input\r
- NCVVectorReuse<Ncv32u> h_rects_as32u(h_rects.getSegment());\r
- ncvAssertReturn(h_rects_as32u.isMemReused(), false);\r
- ncvAssertReturn(this->src32u.fill(h_rects_as32u), false);\r
- for (Ncv32u i=0; i<this->numRects; i++)\r
- {\r
- h_rects.ptr()[i].x = (Ncv32u)(((1.0 * h_rects.ptr()[i].x) / RAND_MAX) * (this->width-2));\r
- h_rects.ptr()[i].y = (Ncv32u)(((1.0 * h_rects.ptr()[i].y) / RAND_MAX) * (this->height-2));\r
- h_rects.ptr()[i].width = (Ncv32u)(((1.0 * h_rects.ptr()[i].width) / RAND_MAX) * (this->width+10 - h_rects.ptr()[i].x));\r
- h_rects.ptr()[i].height = (Ncv32u)(((1.0 * h_rects.ptr()[i].height) / RAND_MAX) * (this->height+10 - h_rects.ptr()[i].y));\r
- }\r
- ncvStat = h_rects.copySolid(d_rects, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- ncvStat = ncvDrawRects_32u_device((Ncv32u *)d_img.ptr(), d_img.stride(), this->width, this->height,\r
- (NcvRect32u *)d_rects.ptr(), this->numRects, this->color, 0);\r
- }\r
- else if (sizeof(T) == sizeof(Ncv8u))\r
- {\r
- ncvStat = ncvDrawRects_8u_device((Ncv8u *)d_img.ptr(), d_img.stride(), this->width, this->height,\r
- (NcvRect32u *)d_rects.ptr(), this->numRects, (Ncv8u)this->color, 0);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect drawrects test instance", false);\r
- }\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- ncvStat = d_img.copySolid(h_img_d, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- NCV_SKIP_COND_BEGIN\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- ncvStat = ncvDrawRects_32u_host((Ncv32u *)h_img.ptr(), h_img.stride(), this->width, this->height,\r
- (NcvRect32u *)h_rects.ptr(), this->numRects, this->color);\r
- }\r
- else if (sizeof(T) == sizeof(Ncv8u))\r
- {\r
- ncvStat = ncvDrawRects_8u_host((Ncv8u *)h_img.ptr(), h_img.stride(), this->width, this->height,\r
- (NcvRect32u *)h_rects.ptr(), this->numRects, (Ncv8u)this->color);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect drawrects test instance", false);\r
- }\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- //const Ncv64f relEPS = 0.005;\r
- for (Ncv32u i=0; bLoopVirgin && i < h_img.height(); i++)\r
- {\r
- for (Ncv32u j=0; bLoopVirgin && j < h_img.width(); j++)\r
- {\r
- if (h_img.ptr()[h_img.stride()*i+j] != h_img_d.ptr()[h_img_d.stride()*i+j])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestDrawRects<T>::deinit()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template class TestDrawRects<Ncv8u>;\r
-template class TestDrawRects<Ncv32u>;\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testdrawrects_h_\r
-#define _testdrawrects_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-template <class T>\r
-class TestDrawRects : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestDrawRects(std::string testName, NCVTestSourceProvider<T> &src, NCVTestSourceProvider<Ncv32u> &src32u,\r
- Ncv32u width, Ncv32u height, Ncv32u numRects, T color);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
-\r
- TestDrawRects(const TestDrawRects&);\r
- TestDrawRects& operator=(const TestDrawRects&); \r
-\r
- NCVTestSourceProvider<T> &src;\r
- NCVTestSourceProvider<Ncv32u> &src32u;\r
- Ncv32u width;\r
- Ncv32u height;\r
- Ncv32u numRects;\r
- T color;\r
-};\r
-\r
-#endif // _testdrawrects_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include <float.h>\r
-\r
-#if defined(__GNUC__)\r
- #include <fpu_control.h>\r
-#endif\r
-\r
-#include "TestHaarCascadeApplication.h"\r
-#include "NCVHaarObjectDetection.hpp"\r
-\r
-\r
-TestHaarCascadeApplication::TestHaarCascadeApplication(std::string testName, NCVTestSourceProvider<Ncv8u> &src,\r
- std::string cascadeName, Ncv32u width, Ncv32u height)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- cascadeName(cascadeName),\r
- width(width),\r
- height(height)\r
-{\r
-}\r
-\r
-\r
-bool TestHaarCascadeApplication::toString(std::ofstream &strOut)\r
-{\r
- strOut << "cascadeName=" << cascadeName << std::endl;\r
- strOut << "width=" << width << std::endl;\r
- strOut << "height=" << height << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestHaarCascadeApplication::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-bool TestHaarCascadeApplication::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- Ncv32u numStages, numNodes, numFeatures;\r
-\r
- ncvStat = ncvHaarGetClassifierSize(this->cascadeName, numStages, numNodes, numFeatures);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- NCVVectorAlloc<HaarStage64> h_HaarStages(*this->allocatorCPU.get(), numStages);\r
- ncvAssertReturn(h_HaarStages.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarClassifierNode128> h_HaarNodes(*this->allocatorCPU.get(), numNodes);\r
- ncvAssertReturn(h_HaarNodes.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarFeature64> h_HaarFeatures(*this->allocatorCPU.get(), numFeatures);\r
- ncvAssertReturn(h_HaarFeatures.isMemAllocated(), false);\r
-\r
- NCVVectorAlloc<HaarStage64> d_HaarStages(*this->allocatorGPU.get(), numStages);\r
- ncvAssertReturn(d_HaarStages.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarClassifierNode128> d_HaarNodes(*this->allocatorGPU.get(), numNodes);\r
- ncvAssertReturn(d_HaarNodes.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarFeature64> d_HaarFeatures(*this->allocatorGPU.get(), numFeatures);\r
- ncvAssertReturn(d_HaarFeatures.isMemAllocated(), false);\r
-\r
- HaarClassifierCascadeDescriptor haar;\r
- haar.ClassifierSize.width = haar.ClassifierSize.height = 1;\r
- haar.bNeedsTiltedII = false;\r
- haar.NumClassifierRootNodes = numNodes;\r
- haar.NumClassifierTotalNodes = numNodes;\r
- haar.NumFeatures = numFeatures;\r
- haar.NumStages = numStages;\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
-\r
- ncvStat = ncvHaarLoadFromFile_host(this->cascadeName, haar, h_HaarStages, h_HaarNodes, h_HaarFeatures);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- ncvAssertReturn(NCV_SUCCESS == h_HaarStages.copySolid(d_HaarStages, 0), false);\r
- ncvAssertReturn(NCV_SUCCESS == h_HaarNodes.copySolid(d_HaarNodes, 0), false);\r
- ncvAssertReturn(NCV_SUCCESS == h_HaarFeatures.copySolid(d_HaarFeatures, 0), false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- NCV_SKIP_COND_END\r
-\r
- NcvSize32s srcRoi, srcIIRoi, searchRoi;\r
- srcRoi.width = this->width;\r
- srcRoi.height = this->height;\r
- srcIIRoi.width = srcRoi.width + 1;\r
- srcIIRoi.height = srcRoi.height + 1;\r
- searchRoi.width = srcIIRoi.width - haar.ClassifierSize.width;\r
- searchRoi.height = srcIIRoi.height - haar.ClassifierSize.height;\r
- if (searchRoi.width <= 0 || searchRoi.height <= 0)\r
- {\r
- return false;\r
- }\r
- NcvSize32u searchRoiU(searchRoi.width, searchRoi.height);\r
-\r
- NCVMatrixAlloc<Ncv8u> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv8u> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
-\r
- Ncv32u integralWidth = this->width + 1;\r
- Ncv32u integralHeight = this->height + 1;\r
-\r
- NCVMatrixAlloc<Ncv32u> d_integralImage(*this->allocatorGPU.get(), integralWidth, integralHeight);\r
- ncvAssertReturn(d_integralImage.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv64u> d_sqIntegralImage(*this->allocatorGPU.get(), integralWidth, integralHeight);\r
- ncvAssertReturn(d_sqIntegralImage.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32u> h_integralImage(*this->allocatorCPU.get(), integralWidth, integralHeight);\r
- ncvAssertReturn(h_integralImage.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv64u> h_sqIntegralImage(*this->allocatorCPU.get(), integralWidth, integralHeight);\r
- ncvAssertReturn(h_sqIntegralImage.isMemAllocated(), false);\r
-\r
- NCVMatrixAlloc<Ncv32f> d_rectStdDev(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_rectStdDev.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32u> d_pixelMask(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_pixelMask.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32f> h_rectStdDev(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_rectStdDev.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32u> h_pixelMask(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_pixelMask.isMemAllocated(), false);\r
-\r
- NCVVectorAlloc<NcvRect32u> d_hypotheses(*this->allocatorGPU.get(), this->width * this->height);\r
- ncvAssertReturn(d_hypotheses.isMemAllocated(), false);\r
- NCVVectorAlloc<NcvRect32u> h_hypotheses(*this->allocatorCPU.get(), this->width * this->height);\r
- ncvAssertReturn(h_hypotheses.isMemAllocated(), false);\r
-\r
- NCVStatus nppStat;\r
- Ncv32u szTmpBufIntegral, szTmpBufSqIntegral;\r
- nppStat = nppiStIntegralGetSize_8u32u(NcvSize32u(this->width, this->height), &szTmpBufIntegral, this->devProp);\r
- ncvAssertReturn(nppStat == NPPST_SUCCESS, false);\r
- nppStat = nppiStSqrIntegralGetSize_8u64u(NcvSize32u(this->width, this->height), &szTmpBufSqIntegral, this->devProp);\r
- ncvAssertReturn(nppStat == NPPST_SUCCESS, false);\r
- NCVVectorAlloc<Ncv8u> d_tmpIIbuf(*this->allocatorGPU.get(), std::max(szTmpBufIntegral, szTmpBufSqIntegral));\r
- ncvAssertReturn(d_tmpIIbuf.isMemAllocated(), false);\r
-\r
- Ncv32u detectionsOnThisScale_d = 0;\r
- Ncv32u detectionsOnThisScale_h = 0;\r
-\r
- NCV_SKIP_COND_BEGIN\r
-\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- nppStat = nppiStIntegral_8u32u_C1R(d_img.ptr(), d_img.pitch(),\r
- d_integralImage.ptr(), d_integralImage.pitch(),\r
- NcvSize32u(d_img.width(), d_img.height()),\r
- d_tmpIIbuf.ptr(), szTmpBufIntegral, this->devProp);\r
- ncvAssertReturn(nppStat == NPPST_SUCCESS, false);\r
-\r
- nppStat = nppiStSqrIntegral_8u64u_C1R(d_img.ptr(), d_img.pitch(),\r
- d_sqIntegralImage.ptr(), d_sqIntegralImage.pitch(),\r
- NcvSize32u(d_img.width(), d_img.height()),\r
- d_tmpIIbuf.ptr(), szTmpBufSqIntegral, this->devProp);\r
- ncvAssertReturn(nppStat == NPPST_SUCCESS, false);\r
-\r
- const NcvRect32u rect(\r
- HAAR_STDDEV_BORDER,\r
- HAAR_STDDEV_BORDER,\r
- haar.ClassifierSize.width - 2*HAAR_STDDEV_BORDER,\r
- haar.ClassifierSize.height - 2*HAAR_STDDEV_BORDER);\r
- nppStat = nppiStRectStdDev_32f_C1R(\r
- d_integralImage.ptr(), d_integralImage.pitch(),\r
- d_sqIntegralImage.ptr(), d_sqIntegralImage.pitch(),\r
- d_rectStdDev.ptr(), d_rectStdDev.pitch(),\r
- NcvSize32u(searchRoi.width, searchRoi.height), rect,\r
- 1.0f, true);\r
- ncvAssertReturn(nppStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = d_integralImage.copySolid(h_integralImage, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvStat = d_rectStdDev.copySolid(h_rectStdDev, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- for (Ncv32u i=0; i<searchRoiU.height; i++)\r
- {\r
- for (Ncv32u j=0; j<h_pixelMask.stride(); j++)\r
- {\r
- if (j<searchRoiU.width)\r
- {\r
- h_pixelMask.ptr()[i*h_pixelMask.stride()+j] = (i << 16) | j;\r
- }\r
- else\r
- {\r
- h_pixelMask.ptr()[i*h_pixelMask.stride()+j] = OBJDET_MASK_ELEMENT_INVALID_32U;\r
- }\r
- }\r
- }\r
- ncvAssertReturn(cudaSuccess == cudaStreamSynchronize(0), false);\r
-\r
-#if defined(__GNUC__)\r
- //http://www.christian-seiler.de/projekte/fpmath/\r
-\r
- fpu_control_t fpu_oldcw, fpu_cw;\r
- _FPU_GETCW(fpu_oldcw); // store old cw\r
- fpu_cw = (fpu_oldcw & ~_FPU_EXTENDED & ~_FPU_DOUBLE & ~_FPU_SINGLE) | _FPU_SINGLE;\r
- _FPU_SETCW(fpu_cw);\r
-\r
- // calculations here\r
- ncvStat = ncvApplyHaarClassifierCascade_host(\r
- h_integralImage, h_rectStdDev, h_pixelMask,\r
- detectionsOnThisScale_h,\r
- haar, h_HaarStages, h_HaarNodes, h_HaarFeatures, false,\r
- searchRoiU, 1, 1.0f);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- _FPU_SETCW(fpu_oldcw); // restore old cw\r
-#else\r
- Ncv32u fpu_oldcw, fpu_cw;\r
- _controlfp_s(&fpu_cw, 0, 0);\r
- fpu_oldcw = fpu_cw;\r
- _controlfp_s(&fpu_cw, _PC_24, _MCW_PC);\r
- ncvStat = ncvApplyHaarClassifierCascade_host(\r
- h_integralImage, h_rectStdDev, h_pixelMask,\r
- detectionsOnThisScale_h,\r
- haar, h_HaarStages, h_HaarNodes, h_HaarFeatures, false,\r
- searchRoiU, 1, 1.0f);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- _controlfp_s(&fpu_cw, fpu_oldcw, _MCW_PC);\r
-#endif\r
- NCV_SKIP_COND_END\r
-\r
- int devId;\r
- ncvAssertCUDAReturn(cudaGetDevice(&devId), false);\r
- cudaDeviceProp devProp;\r
- ncvAssertCUDAReturn(cudaGetDeviceProperties(&devProp, devId), false);\r
-\r
- ncvStat = ncvApplyHaarClassifierCascade_device(\r
- d_integralImage, d_rectStdDev, d_pixelMask,\r
- detectionsOnThisScale_d,\r
- haar, h_HaarStages, d_HaarStages, d_HaarNodes, d_HaarFeatures, false,\r
- searchRoiU, 1, 1.0f,\r
- *this->allocatorGPU.get(), *this->allocatorCPU.get(),\r
- devProp, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- NCVMatrixAlloc<Ncv32u> h_pixelMask_d(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_pixelMask_d.isMemAllocated(), false);\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
-\r
- ncvStat = d_pixelMask.copySolid(h_pixelMask_d, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- if (detectionsOnThisScale_d != detectionsOnThisScale_h)\r
- {\r
- bLoopVirgin = false;\r
- }\r
- else\r
- {\r
- std::sort(h_pixelMask_d.ptr(), h_pixelMask_d.ptr() + detectionsOnThisScale_d);\r
- for (Ncv32u i=0; i<detectionsOnThisScale_d && bLoopVirgin; i++)\r
- {\r
- if (h_pixelMask.ptr()[i] != h_pixelMask_d.ptr()[i])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
-\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestHaarCascadeApplication::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testhaarcascadeapplication_h_\r
-#define _testhaarcascadeapplication_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestHaarCascadeApplication : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestHaarCascadeApplication(std::string testName, NCVTestSourceProvider<Ncv8u> &src,\r
- std::string cascadeName, Ncv32u width, Ncv32u height);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestHaarCascadeApplication(const TestHaarCascadeApplication&);\r
- TestHaarCascadeApplication& operator=(const TestHaarCascadeApplication&); \r
-\r
-\r
- NCVTestSourceProvider<Ncv8u> &src;\r
- std::string cascadeName;\r
- Ncv32u width;\r
- Ncv32u height;\r
-};\r
-\r
-#endif // _testhaarcascadeapplication_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include "TestHaarCascadeLoader.h"\r
-#include "NCVHaarObjectDetection.hpp"\r
-\r
-\r
-TestHaarCascadeLoader::TestHaarCascadeLoader(std::string testName, std::string cascadeName)\r
- :\r
- NCVTestProvider(testName),\r
- cascadeName(cascadeName)\r
-{\r
-}\r
-\r
-\r
-bool TestHaarCascadeLoader::toString(std::ofstream &strOut)\r
-{\r
- strOut << "cascadeName=" << cascadeName << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestHaarCascadeLoader::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-bool TestHaarCascadeLoader::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- Ncv32u numStages, numNodes, numFeatures;\r
- Ncv32u numStages_2 = 0, numNodes_2 = 0, numFeatures_2 = 0;\r
-\r
- ncvStat = ncvHaarGetClassifierSize(this->cascadeName, numStages, numNodes, numFeatures);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- NCVVectorAlloc<HaarStage64> h_HaarStages(*this->allocatorCPU.get(), numStages);\r
- ncvAssertReturn(h_HaarStages.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarClassifierNode128> h_HaarNodes(*this->allocatorCPU.get(), numNodes);\r
- ncvAssertReturn(h_HaarNodes.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarFeature64> h_HaarFeatures(*this->allocatorCPU.get(), numFeatures);\r
- ncvAssertReturn(h_HaarFeatures.isMemAllocated(), false);\r
-\r
- NCVVectorAlloc<HaarStage64> h_HaarStages_2(*this->allocatorCPU.get(), numStages);\r
- ncvAssertReturn(h_HaarStages_2.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarClassifierNode128> h_HaarNodes_2(*this->allocatorCPU.get(), numNodes);\r
- ncvAssertReturn(h_HaarNodes_2.isMemAllocated(), false);\r
- NCVVectorAlloc<HaarFeature64> h_HaarFeatures_2(*this->allocatorCPU.get(), numFeatures);\r
- ncvAssertReturn(h_HaarFeatures_2.isMemAllocated(), false);\r
-\r
- HaarClassifierCascadeDescriptor haar;\r
- HaarClassifierCascadeDescriptor haar_2;\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
-\r
- const std::string testNvbinName = "test.nvbin";\r
- ncvStat = ncvHaarLoadFromFile_host(this->cascadeName, haar, h_HaarStages, h_HaarNodes, h_HaarFeatures);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- ncvStat = ncvHaarStoreNVBIN_host(testNvbinName, haar, h_HaarStages, h_HaarNodes, h_HaarFeatures);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- ncvStat = ncvHaarGetClassifierSize(testNvbinName, numStages_2, numNodes_2, numFeatures_2);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- ncvStat = ncvHaarLoadFromFile_host(testNvbinName, haar_2, h_HaarStages_2, h_HaarNodes_2, h_HaarFeatures_2);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
-\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
-\r
- if (\r
- numStages_2 != numStages ||\r
- numNodes_2 != numNodes ||\r
- numFeatures_2 != numFeatures ||\r
- haar.NumStages != haar_2.NumStages ||\r
- haar.NumClassifierRootNodes != haar_2.NumClassifierRootNodes ||\r
- haar.NumClassifierTotalNodes != haar_2.NumClassifierTotalNodes ||\r
- haar.NumFeatures != haar_2.NumFeatures ||\r
- haar.ClassifierSize.width != haar_2.ClassifierSize.width ||\r
- haar.ClassifierSize.height != haar_2.ClassifierSize.height ||\r
- haar.bNeedsTiltedII != haar_2.bNeedsTiltedII ||\r
- haar.bHasStumpsOnly != haar_2.bHasStumpsOnly )\r
- {\r
- bLoopVirgin = false;\r
- }\r
- if (memcmp(h_HaarStages.ptr(), h_HaarStages_2.ptr(), haar.NumStages * sizeof(HaarStage64)) ||\r
- memcmp(h_HaarNodes.ptr(), h_HaarNodes_2.ptr(), haar.NumClassifierTotalNodes * sizeof(HaarClassifierNode128)) ||\r
- memcmp(h_HaarFeatures.ptr(), h_HaarFeatures_2.ptr(), haar.NumFeatures * sizeof(HaarFeature64)) )\r
- {\r
- bLoopVirgin = false;\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestHaarCascadeLoader::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testhaarcascadeloader_h_\r
-#define _testhaarcascadeloader_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestHaarCascadeLoader : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestHaarCascadeLoader(std::string testName, std::string cascadeName);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
-\r
- std::string cascadeName;\r
-};\r
-\r
-#endif // _testhaarcascadeloader_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include "TestHypothesesFilter.h"\r
-#include "NCVHaarObjectDetection.hpp"\r
-\r
-\r
-TestHypothesesFilter::TestHypothesesFilter(std::string testName, NCVTestSourceProvider<Ncv32u> &src,\r
- Ncv32u numDstRects, Ncv32u minNeighbors, Ncv32f eps)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- numDstRects(numDstRects),\r
- minNeighbors(minNeighbors),\r
- eps(eps)\r
-{\r
-}\r
-\r
-\r
-bool TestHypothesesFilter::toString(std::ofstream &strOut)\r
-{\r
- strOut << "numDstRects=" << numDstRects << std::endl;\r
- strOut << "minNeighbors=" << minNeighbors << std::endl;\r
- strOut << "eps=" << eps << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestHypothesesFilter::init()\r
-{\r
- this->canvasWidth = 4096;\r
- this->canvasHeight = 4096;\r
- return true;\r
-}\r
-\r
-\r
-bool compareRects(const NcvRect32u &r1, const NcvRect32u &r2, Ncv32f eps)\r
-{\r
- double delta = eps*(std::min(r1.width, r2.width) + std::min(r1.height, r2.height))*0.5;\r
- return std::abs((Ncv32s)r1.x - (Ncv32s)r2.x) <= delta &&\r
- std::abs((Ncv32s)r1.y - (Ncv32s)r2.y) <= delta &&\r
- std::abs((Ncv32s)r1.x + (Ncv32s)r1.width - (Ncv32s)r2.x - (Ncv32s)r2.width) <= delta &&\r
- std::abs((Ncv32s)r1.y + (Ncv32s)r1.height - (Ncv32s)r2.y - (Ncv32s)r2.height) <= delta;\r
-}\r
-\r
-\r
-inline bool operator < (const NcvRect32u &a, const NcvRect32u &b)\r
-{\r
- return a.x < b.x;\r
-}\r
-\r
-\r
-bool TestHypothesesFilter::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- NCVVectorAlloc<Ncv32u> h_random32u(*this->allocatorCPU.get(), this->numDstRects * sizeof(NcvRect32u) / sizeof(Ncv32u));\r
- ncvAssertReturn(h_random32u.isMemAllocated(), false);\r
-\r
- Ncv32u srcSlotSize = 2 * this->minNeighbors + 1;\r
-\r
- NCVVectorAlloc<NcvRect32u> h_vecSrc(*this->allocatorCPU.get(), this->numDstRects*srcSlotSize);\r
- ncvAssertReturn(h_vecSrc.isMemAllocated(), false);\r
- NCVVectorAlloc<NcvRect32u> h_vecDst_groundTruth(*this->allocatorCPU.get(), this->numDstRects);\r
- ncvAssertReturn(h_vecDst_groundTruth.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorCPU.get()->isCounting());\r
-\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_random32u), false);\r
- Ncv32u randCnt = 0;\r
- Ncv64f randVal;\r
-\r
- for (Ncv32u i=0; i<this->numDstRects; i++)\r
- {\r
- h_vecDst_groundTruth.ptr()[i].x = i * this->canvasWidth / this->numDstRects + this->canvasWidth / (this->numDstRects * 4);\r
- h_vecDst_groundTruth.ptr()[i].y = i * this->canvasHeight / this->numDstRects + this->canvasHeight / (this->numDstRects * 4);\r
- h_vecDst_groundTruth.ptr()[i].width = this->canvasWidth / (this->numDstRects * 2);\r
- h_vecDst_groundTruth.ptr()[i].height = this->canvasHeight / (this->numDstRects * 2);\r
-\r
- Ncv32u numNeighbors = this->minNeighbors + 1 + (Ncv32u)(((1.0 * h_random32u.ptr()[i]) * (this->minNeighbors + 1)) / 0xFFFFFFFF);\r
- numNeighbors = (numNeighbors > srcSlotSize) ? srcSlotSize : numNeighbors;\r
-\r
- //fill in strong hypotheses (2 * ((1.0 * randVal) / 0xFFFFFFFF) - 1)\r
- for (Ncv32u j=0; j<numNeighbors; j++)\r
- {\r
- randVal = (1.0 * h_random32u.ptr()[randCnt++]) / 0xFFFFFFFF; randCnt = randCnt % h_random32u.length();\r
- h_vecSrc.ptr()[srcSlotSize * i + j].x = \r
- h_vecDst_groundTruth.ptr()[i].x +\r
- (Ncv32s)(h_vecDst_groundTruth.ptr()[i].width * this->eps * (randVal - 0.5));\r
- randVal = (1.0 * h_random32u.ptr()[randCnt++]) / 0xFFFFFFFF; randCnt = randCnt % h_random32u.length();\r
- h_vecSrc.ptr()[srcSlotSize * i + j].y = \r
- h_vecDst_groundTruth.ptr()[i].y +\r
- (Ncv32s)(h_vecDst_groundTruth.ptr()[i].height * this->eps * (randVal - 0.5));\r
- h_vecSrc.ptr()[srcSlotSize * i + j].width = h_vecDst_groundTruth.ptr()[i].width;\r
- h_vecSrc.ptr()[srcSlotSize * i + j].height = h_vecDst_groundTruth.ptr()[i].height;\r
- }\r
-\r
- //generate weak hypotheses (to be removed in processing)\r
- for (Ncv32u j=numNeighbors; j<srcSlotSize; j++)\r
- {\r
- randVal = (1.0 * h_random32u.ptr()[randCnt++]) / 0xFFFFFFFF; randCnt = randCnt % h_random32u.length();\r
- h_vecSrc.ptr()[srcSlotSize * i + j].x = \r
- this->canvasWidth + h_vecDst_groundTruth.ptr()[i].x +\r
- (Ncv32s)(h_vecDst_groundTruth.ptr()[i].width * this->eps * (randVal - 0.5));\r
- randVal = (1.0 * h_random32u.ptr()[randCnt++]) / 0xFFFFFFFF; randCnt = randCnt % h_random32u.length();\r
- h_vecSrc.ptr()[srcSlotSize * i + j].y = \r
- this->canvasHeight + h_vecDst_groundTruth.ptr()[i].y +\r
- (Ncv32s)(h_vecDst_groundTruth.ptr()[i].height * this->eps * (randVal - 0.5));\r
- h_vecSrc.ptr()[srcSlotSize * i + j].width = h_vecDst_groundTruth.ptr()[i].width;\r
- h_vecSrc.ptr()[srcSlotSize * i + j].height = h_vecDst_groundTruth.ptr()[i].height;\r
- }\r
- }\r
-\r
- //shuffle\r
- for (Ncv32u i=0; i<this->numDstRects*srcSlotSize-1; i++)\r
- {\r
- Ncv32u randVal = h_random32u.ptr()[randCnt++]; randCnt = randCnt % h_random32u.length();\r
- Ncv32u secondSwap = randVal % (this->numDstRects*srcSlotSize-1 - i);\r
- NcvRect32u tmp = h_vecSrc.ptr()[i + secondSwap];\r
- h_vecSrc.ptr()[i + secondSwap] = h_vecSrc.ptr()[i];\r
- h_vecSrc.ptr()[i] = tmp;\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- Ncv32u numHypothesesSrc = h_vecSrc.length();\r
- NCV_SKIP_COND_BEGIN\r
- ncvStat = ncvFilterHypotheses_host(h_vecSrc, numHypothesesSrc, this->minNeighbors, this->eps, NULL);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //verification\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- if (numHypothesesSrc != this->numDstRects)\r
- {\r
- bLoopVirgin = false;\r
- }\r
- else\r
- {\r
- std::vector<NcvRect32u> tmpRects(numHypothesesSrc);\r
- memcpy(&tmpRects[0], h_vecSrc.ptr(), numHypothesesSrc * sizeof(NcvRect32u));\r
- std::sort(tmpRects.begin(), tmpRects.end());\r
- for (Ncv32u i=0; i<numHypothesesSrc && bLoopVirgin; i++)\r
- {\r
- if (!compareRects(tmpRects[i], h_vecDst_groundTruth.ptr()[i], this->eps))\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestHypothesesFilter::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testhypothesesfilter_h_\r
-#define _testhypothesesfilter_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestHypothesesFilter : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestHypothesesFilter(std::string testName, NCVTestSourceProvider<Ncv32u> &src,\r
- Ncv32u numDstRects, Ncv32u minNeighbors, Ncv32f eps);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
-\r
- TestHypothesesFilter(const TestHypothesesFilter&);\r
- TestHypothesesFilter& operator=(const TestHypothesesFilter&); \r
-\r
- NCVTestSourceProvider<Ncv32u> &src;\r
- Ncv32u numDstRects;\r
- Ncv32u minNeighbors;\r
- Ncv32f eps;\r
-\r
- Ncv32u canvasWidth;\r
- Ncv32u canvasHeight;\r
-};\r
-\r
-#endif // _testhypothesesfilter_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include "TestHypothesesGrow.h"\r
-#include "NCVHaarObjectDetection.hpp"\r
-\r
-\r
-TestHypothesesGrow::TestHypothesesGrow(std::string testName, NCVTestSourceProvider<Ncv32u> &src,\r
- Ncv32u rectWidth, Ncv32u rectHeight, Ncv32f rectScale, \r
- Ncv32u maxLenSrc, Ncv32u lenSrc, Ncv32u maxLenDst, Ncv32u lenDst)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- rectWidth(rectWidth),\r
- rectHeight(rectHeight),\r
- rectScale(rectScale),\r
- maxLenSrc(maxLenSrc),\r
- lenSrc(lenSrc),\r
- maxLenDst(maxLenDst),\r
- lenDst(lenDst)\r
-{\r
-}\r
-\r
-\r
-bool TestHypothesesGrow::toString(std::ofstream &strOut)\r
-{\r
- strOut << "rectWidth=" << rectWidth << std::endl;\r
- strOut << "rectHeight=" << rectHeight << std::endl;\r
- strOut << "rectScale=" << rectScale << std::endl;\r
- strOut << "maxLenSrc=" << maxLenSrc << std::endl;\r
- strOut << "lenSrc=" << lenSrc << std::endl;\r
- strOut << "maxLenDst=" << maxLenDst << std::endl;\r
- strOut << "lenDst=" << lenDst << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestHypothesesGrow::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-bool TestHypothesesGrow::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- NCVVectorAlloc<Ncv32u> h_vecSrc(*this->allocatorCPU.get(), this->maxLenSrc);\r
- ncvAssertReturn(h_vecSrc.isMemAllocated(), false);\r
- NCVVectorAlloc<Ncv32u> d_vecSrc(*this->allocatorGPU.get(), this->maxLenSrc);\r
- ncvAssertReturn(d_vecSrc.isMemAllocated(), false);\r
-\r
- NCVVectorAlloc<NcvRect32u> h_vecDst(*this->allocatorCPU.get(), this->maxLenDst);\r
- ncvAssertReturn(h_vecDst.isMemAllocated(), false);\r
- NCVVectorAlloc<NcvRect32u> d_vecDst(*this->allocatorGPU.get(), this->maxLenDst);\r
- ncvAssertReturn(d_vecDst.isMemAllocated(), false);\r
- NCVVectorAlloc<NcvRect32u> h_vecDst_d(*this->allocatorCPU.get(), this->maxLenDst);\r
- ncvAssertReturn(h_vecDst_d.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
-\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_vecSrc), false);\r
- memset(h_vecDst.ptr(), 0, h_vecDst.length() * sizeof(NcvRect32u));\r
- NCVVectorReuse<Ncv32u> h_vecDst_as32u(h_vecDst.getSegment(), lenDst * sizeof(NcvRect32u) / sizeof(Ncv32u));\r
- ncvAssertReturn(h_vecDst_as32u.isMemReused(), false);\r
- ncvAssertReturn(this->src.fill(h_vecDst_as32u), false);\r
- memcpy(h_vecDst_d.ptr(), h_vecDst.ptr(), h_vecDst.length() * sizeof(NcvRect32u));\r
- NCV_SKIP_COND_END\r
-\r
- ncvStat = h_vecSrc.copySolid(d_vecSrc, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvStat = h_vecDst.copySolid(d_vecDst, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- Ncv32u h_outElemNum_d = 0;\r
- Ncv32u h_outElemNum_h = 0;\r
- NCV_SKIP_COND_BEGIN\r
- h_outElemNum_d = this->lenDst;\r
- ncvStat = ncvGrowDetectionsVector_device(d_vecSrc, this->lenSrc,\r
- d_vecDst, h_outElemNum_d, this->maxLenDst,\r
- this->rectWidth, this->rectHeight, this->rectScale, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvStat = d_vecDst.copySolid(h_vecDst_d, 0);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- ncvAssertCUDAReturn(cudaStreamSynchronize(0), false);\r
-\r
- h_outElemNum_h = this->lenDst;\r
- ncvStat = ncvGrowDetectionsVector_host(h_vecSrc, this->lenSrc,\r
- h_vecDst, h_outElemNum_h, this->maxLenDst,\r
- this->rectWidth, this->rectHeight, this->rectScale);\r
- ncvAssertReturn(ncvStat == NCV_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- if (h_outElemNum_d != h_outElemNum_h)\r
- {\r
- bLoopVirgin = false;\r
- }\r
- else\r
- {\r
- if (memcmp(h_vecDst.ptr(), h_vecDst_d.ptr(), this->maxLenDst * sizeof(NcvRect32u)))\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestHypothesesGrow::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testhypothesesgrow_h_\r
-#define _testhypothesesgrow_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestHypothesesGrow : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestHypothesesGrow(std::string testName, NCVTestSourceProvider<Ncv32u> &src,\r
- Ncv32u rectWidth, Ncv32u rectHeight, Ncv32f rectScale, \r
- Ncv32u maxLenSrc, Ncv32u lenSrc, Ncv32u maxLenDst, Ncv32u lenDst);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestHypothesesGrow(const TestHypothesesGrow&);\r
- TestHypothesesGrow& operator=(const TestHypothesesGrow&); \r
-\r
-\r
- NCVTestSourceProvider<Ncv32u> &src;\r
- Ncv32u rectWidth;\r
- Ncv32u rectHeight;\r
- Ncv32f rectScale;\r
- Ncv32u maxLenSrc;\r
- Ncv32u lenSrc;\r
- Ncv32u maxLenDst;\r
- Ncv32u lenDst;\r
-};\r
-\r
-#endif // _testhypothesesgrow_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include <math.h>\r
-#include "TestIntegralImage.h"\r
-\r
-\r
-template <class T_in, class T_out>\r
-TestIntegralImage<T_in, T_out>::TestIntegralImage(std::string testName, NCVTestSourceProvider<T_in> &src,\r
- Ncv32u width, Ncv32u height)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- width(width),\r
- height(height)\r
-{\r
-}\r
-\r
-\r
-template <class T_in, class T_out>\r
-bool TestIntegralImage<T_in, T_out>::toString(std::ofstream &strOut)\r
-{\r
- strOut << "sizeof(T_in)=" << sizeof(T_in) << std::endl;\r
- strOut << "sizeof(T_out)=" << sizeof(T_out) << std::endl;\r
- strOut << "width=" << width << std::endl;\r
- strOut << "height=" << height << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-template <class T_in, class T_out>\r
-bool TestIntegralImage<T_in, T_out>::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template <class T_in, class T_out>\r
-bool TestIntegralImage<T_in, T_out>::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- Ncv32u widthII = this->width + 1;\r
- Ncv32u heightII = this->height + 1;\r
-\r
- NCVMatrixAlloc<T_in> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<T_in> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<T_out> d_imgII(*this->allocatorGPU.get(), widthII, heightII);\r
- ncvAssertReturn(d_imgII.isMemAllocated(), false);\r
- NCVMatrixAlloc<T_out> h_imgII(*this->allocatorCPU.get(), widthII, heightII);\r
- ncvAssertReturn(h_imgII.isMemAllocated(), false);\r
- NCVMatrixAlloc<T_out> h_imgII_d(*this->allocatorCPU.get(), widthII, heightII);\r
- ncvAssertReturn(h_imgII_d.isMemAllocated(), false);\r
-\r
- Ncv32u bufSize;\r
- if (sizeof(T_in) == sizeof(Ncv8u))\r
- {\r
- ncvStat = nppiStIntegralGetSize_8u32u(NcvSize32u(this->width, this->height), &bufSize, this->devProp);\r
- ncvAssertReturn(NPPST_SUCCESS == ncvStat, false);\r
- }\r
- else if (sizeof(T_in) == sizeof(Ncv32f))\r
- {\r
- ncvStat = nppiStIntegralGetSize_32f32f(NcvSize32u(this->width, this->height), &bufSize, this->devProp);\r
- ncvAssertReturn(NPPST_SUCCESS == ncvStat, false);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect integral image test instance", false);\r
- }\r
-\r
- NCVVectorAlloc<Ncv8u> d_tmpBuf(*this->allocatorGPU.get(), bufSize);\r
- ncvAssertReturn(d_tmpBuf.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
-\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
-\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- if (sizeof(T_in) == sizeof(Ncv8u))\r
- {\r
- ncvStat = nppiStIntegral_8u32u_C1R((Ncv8u *)d_img.ptr(), d_img.pitch(),\r
- (Ncv32u *)d_imgII.ptr(), d_imgII.pitch(),\r
- NcvSize32u(this->width, this->height),\r
- d_tmpBuf.ptr(), bufSize, this->devProp);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- }\r
- else if (sizeof(T_in) == sizeof(Ncv32f))\r
- {\r
- ncvStat = nppiStIntegral_32f32f_C1R((Ncv32f *)d_img.ptr(), d_img.pitch(),\r
- (Ncv32f *)d_imgII.ptr(), d_imgII.pitch(),\r
- NcvSize32u(this->width, this->height),\r
- d_tmpBuf.ptr(), bufSize, this->devProp);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect integral image test instance", false);\r
- }\r
-\r
- ncvStat = d_imgII.copySolid(h_imgII_d, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- if (sizeof(T_in) == sizeof(Ncv8u))\r
- {\r
- ncvStat = nppiStIntegral_8u32u_C1R_host((Ncv8u *)h_img.ptr(), h_img.pitch(),\r
- (Ncv32u *)h_imgII.ptr(), h_imgII.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- }\r
- else if (sizeof(T_in) == sizeof(Ncv32f))\r
- {\r
- ncvStat = nppiStIntegral_32f32f_C1R_host((Ncv32f *)h_img.ptr(), h_img.pitch(),\r
- (Ncv32f *)h_imgII.ptr(), h_imgII.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect integral image test instance", false);\r
- }\r
-\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- for (Ncv32u i=0; bLoopVirgin && i < h_img.height() + 1; i++)\r
- {\r
- for (Ncv32u j=0; bLoopVirgin && j < h_img.width() + 1; j++)\r
- {\r
- if (sizeof(T_in) == sizeof(Ncv8u))\r
- {\r
- if (h_imgII.ptr()[h_imgII.stride()*i+j] != h_imgII_d.ptr()[h_imgII_d.stride()*i+j])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- else if (sizeof(T_in) == sizeof(Ncv32f))\r
- {\r
- if (fabsf((float)h_imgII.ptr()[h_imgII.stride()*i+j] - (float)h_imgII_d.ptr()[h_imgII_d.stride()*i+j]) > 0.01f)\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect integral image test instance", false);\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-template <class T_in, class T_out>\r
-bool TestIntegralImage<T_in, T_out>::deinit()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template class TestIntegralImage<Ncv8u, Ncv32u>;\r
-template class TestIntegralImage<Ncv32f, Ncv32f>;\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testintegralimage_h_\r
-#define _testintegralimage_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-template <class T_in, class T_out>\r
-class TestIntegralImage : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestIntegralImage(std::string testName, NCVTestSourceProvider<T_in> &src,\r
- Ncv32u width, Ncv32u height);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestIntegralImage(const TestIntegralImage&);\r
- TestIntegralImage& operator=(const TestIntegralImage&); \r
-\r
- NCVTestSourceProvider<T_in> &src;\r
- Ncv32u width;\r
- Ncv32u height;\r
-};\r
-\r
-#endif // _testintegralimage_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include "TestIntegralImageSquared.h"\r
-\r
-\r
-TestIntegralImageSquared::TestIntegralImageSquared(std::string testName, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u width, Ncv32u height)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- width(width),\r
- height(height)\r
-{\r
-}\r
-\r
-\r
-bool TestIntegralImageSquared::toString(std::ofstream &strOut)\r
-{\r
- strOut << "width=" << width << std::endl;\r
- strOut << "height=" << height << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestIntegralImageSquared::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-bool TestIntegralImageSquared::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- Ncv32u widthSII = this->width + 1;\r
- Ncv32u heightSII = this->height + 1;\r
-\r
- NCVMatrixAlloc<Ncv8u> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv8u> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv64u> d_imgSII(*this->allocatorGPU.get(), widthSII, heightSII);\r
- ncvAssertReturn(d_imgSII.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv64u> h_imgSII(*this->allocatorCPU.get(), widthSII, heightSII);\r
- ncvAssertReturn(h_imgSII.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv64u> h_imgSII_d(*this->allocatorCPU.get(), widthSII, heightSII);\r
- ncvAssertReturn(h_imgSII_d.isMemAllocated(), false);\r
-\r
- Ncv32u bufSize;\r
- ncvStat = nppiStSqrIntegralGetSize_8u64u(NcvSize32u(this->width, this->height), &bufSize, this->devProp);\r
- ncvAssertReturn(NPPST_SUCCESS == ncvStat, false);\r
- NCVVectorAlloc<Ncv8u> d_tmpBuf(*this->allocatorGPU.get(), bufSize);\r
- ncvAssertReturn(d_tmpBuf.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
-\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
-\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStSqrIntegral_8u64u_C1R(d_img.ptr(), d_img.pitch(),\r
- d_imgSII.ptr(), d_imgSII.pitch(),\r
- NcvSize32u(this->width, this->height),\r
- d_tmpBuf.ptr(), bufSize, this->devProp);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = d_imgSII.copySolid(h_imgSII_d, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStSqrIntegral_8u64u_C1R_host(h_img.ptr(), h_img.pitch(),\r
- h_imgSII.ptr(), h_imgSII.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- for (Ncv32u i=0; bLoopVirgin && i < h_img.height() + 1; i++)\r
- {\r
- for (Ncv32u j=0; bLoopVirgin && j < h_img.width() + 1; j++)\r
- {\r
- if (h_imgSII.ptr()[h_imgSII.stride()*i+j] != h_imgSII_d.ptr()[h_imgSII_d.stride()*i+j])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestIntegralImageSquared::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testintegralimagesquared_h_\r
-#define _testintegralimagesquared_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestIntegralImageSquared : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestIntegralImageSquared(std::string testName, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u width, Ncv32u height);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestIntegralImageSquared(const TestIntegralImageSquared&);\r
- TestIntegralImageSquared& operator=(const TestIntegralImageSquared&); \r
-\r
- NCVTestSourceProvider<Ncv8u> &src;\r
- Ncv32u width;\r
- Ncv32u height;\r
-};\r
-\r
-#endif // _testintegralimagesquared_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include <math.h>\r
-\r
-#include "TestRectStdDev.h"\r
-\r
-\r
-TestRectStdDev::TestRectStdDev(std::string testName, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u width, Ncv32u height, NcvRect32u rect, Ncv32f scaleFactor,\r
- NcvBool bTextureCache)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- width(width),\r
- height(height),\r
- rect(rect),\r
- scaleFactor(scaleFactor),\r
- bTextureCache(bTextureCache)\r
-{\r
-}\r
-\r
-\r
-bool TestRectStdDev::toString(std::ofstream &strOut)\r
-{\r
- strOut << "width=" << width << std::endl;\r
- strOut << "height=" << height << std::endl;\r
- strOut << "rect=[" << rect.x << ", " << rect.y << ", " << rect.width << ", " << rect.height << "]\n";\r
- strOut << "scaleFactor=" << scaleFactor << std::endl;\r
- strOut << "bTextureCache=" << bTextureCache << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-bool TestRectStdDev::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-bool TestRectStdDev::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- Ncv32s _normWidth = (Ncv32s)this->width - this->rect.x - this->rect.width + 1;\r
- Ncv32s _normHeight = (Ncv32s)this->height - this->rect.y - this->rect.height + 1;\r
- if (_normWidth <= 0 || _normHeight <= 0)\r
- {\r
- return true;\r
- }\r
- Ncv32u normWidth = (Ncv32u)_normWidth;\r
- Ncv32u normHeight = (Ncv32u)_normHeight;\r
- NcvSize32u szNormRoi(normWidth, normHeight);\r
-\r
- Ncv32u widthII = this->width + 1;\r
- Ncv32u heightII = this->height + 1;\r
- Ncv32u widthSII = this->width + 1;\r
- Ncv32u heightSII = this->height + 1;\r
-\r
- NCVMatrixAlloc<Ncv8u> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv8u> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
-\r
- NCVMatrixAlloc<Ncv32u> d_imgII(*this->allocatorGPU.get(), widthII, heightII);\r
- ncvAssertReturn(d_imgII.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32u> h_imgII(*this->allocatorCPU.get(), widthII, heightII);\r
- ncvAssertReturn(h_imgII.isMemAllocated(), false);\r
-\r
- NCVMatrixAlloc<Ncv64u> d_imgSII(*this->allocatorGPU.get(), widthSII, heightSII);\r
- ncvAssertReturn(d_imgSII.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv64u> h_imgSII(*this->allocatorCPU.get(), widthSII, heightSII);\r
- ncvAssertReturn(h_imgSII.isMemAllocated(), false);\r
-\r
- NCVMatrixAlloc<Ncv32f> d_norm(*this->allocatorGPU.get(), normWidth, normHeight);\r
- ncvAssertReturn(d_norm.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32f> h_norm(*this->allocatorCPU.get(), normWidth, normHeight);\r
- ncvAssertReturn(h_norm.isMemAllocated(), false);\r
- NCVMatrixAlloc<Ncv32f> h_norm_d(*this->allocatorCPU.get(), normWidth, normHeight);\r
- ncvAssertReturn(h_norm_d.isMemAllocated(), false);\r
-\r
- Ncv32u bufSizeII, bufSizeSII;\r
- ncvStat = nppiStIntegralGetSize_8u32u(NcvSize32u(this->width, this->height), &bufSizeII, this->devProp);\r
- ncvAssertReturn(NPPST_SUCCESS == ncvStat, false);\r
- ncvStat = nppiStSqrIntegralGetSize_8u64u(NcvSize32u(this->width, this->height), &bufSizeSII, this->devProp);\r
- ncvAssertReturn(NPPST_SUCCESS == ncvStat, false);\r
- Ncv32u bufSize = bufSizeII > bufSizeSII ? bufSizeII : bufSizeSII;\r
- NCVVectorAlloc<Ncv8u> d_tmpBuf(*this->allocatorGPU.get(), bufSize);\r
- ncvAssertReturn(d_tmpBuf.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
-\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStIntegral_8u32u_C1R(d_img.ptr(), d_img.pitch(),\r
- d_imgII.ptr(), d_imgII.pitch(),\r
- NcvSize32u(this->width, this->height),\r
- d_tmpBuf.ptr(), bufSize, this->devProp);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStSqrIntegral_8u64u_C1R(d_img.ptr(), d_img.pitch(),\r
- d_imgSII.ptr(), d_imgSII.pitch(),\r
- NcvSize32u(this->width, this->height),\r
- d_tmpBuf.ptr(), bufSize, this->devProp);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStRectStdDev_32f_C1R(d_imgII.ptr(), d_imgII.pitch(),\r
- d_imgSII.ptr(), d_imgSII.pitch(),\r
- d_norm.ptr(), d_norm.pitch(),\r
- szNormRoi, this->rect,\r
- this->scaleFactor,\r
- this->bTextureCache);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = d_norm.copySolid(h_norm_d, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStIntegral_8u32u_C1R_host(h_img.ptr(), h_img.pitch(),\r
- h_imgII.ptr(), h_imgII.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStSqrIntegral_8u64u_C1R_host(h_img.ptr(), h_img.pitch(),\r
- h_imgSII.ptr(), h_imgSII.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- ncvStat = nppiStRectStdDev_32f_C1R_host(h_imgII.ptr(), h_imgII.pitch(),\r
- h_imgSII.ptr(), h_imgSII.pitch(),\r
- h_norm.ptr(), h_norm.pitch(),\r
- szNormRoi, this->rect,\r
- this->scaleFactor);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- const Ncv64f relEPS = 0.005;\r
- for (Ncv32u i=0; bLoopVirgin && i < h_norm.height(); i++)\r
- {\r
- for (Ncv32u j=0; bLoopVirgin && j < h_norm.width(); j++)\r
- {\r
- Ncv64f absErr = fabs(h_norm.ptr()[h_norm.stride()*i+j] - h_norm_d.ptr()[h_norm_d.stride()*i+j]);\r
- Ncv64f relErr = absErr / h_norm.ptr()[h_norm.stride()*i+j];\r
-\r
- if (relErr > relEPS)\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-bool TestRectStdDev::deinit()\r
-{\r
- return true;\r
-}\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testrectstddev_h_\r
-#define _testrectstddev_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-class TestRectStdDev : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestRectStdDev(std::string testName, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u width, Ncv32u height, NcvRect32u rect, Ncv32f scaleFactor,\r
- NcvBool bTextureCache);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestRectStdDev(const TestRectStdDev&);\r
- TestRectStdDev& operator=(const TestRectStdDev&); \r
-\r
- NCVTestSourceProvider<Ncv8u> &src;\r
- NcvRect32u rect;\r
- Ncv32u width;\r
- Ncv32u height;\r
- Ncv32f scaleFactor;\r
-\r
- NcvBool bTextureCache;\r
-};\r
-\r
-#endif // _testrectstddev_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include <math.h>\r
-\r
-#include "TestResize.h"\r
-\r
-\r
-template <class T>\r
-TestResize<T>::TestResize(std::string testName, NCVTestSourceProvider<T> &src,\r
- Ncv32u width, Ncv32u height, Ncv32u scaleFactor, NcvBool bTextureCache)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- width(width),\r
- height(height),\r
- scaleFactor(scaleFactor),\r
- bTextureCache(bTextureCache)\r
-{\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestResize<T>::toString(std::ofstream &strOut)\r
-{\r
- strOut << "sizeof(T)=" << sizeof(T) << std::endl;\r
- strOut << "width=" << width << std::endl;\r
- strOut << "scaleFactor=" << scaleFactor << std::endl;\r
- strOut << "bTextureCache=" << bTextureCache << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestResize<T>::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestResize<T>::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- Ncv32s smallWidth = this->width / this->scaleFactor;\r
- Ncv32s smallHeight = this->height / this->scaleFactor;\r
- if (smallWidth == 0 || smallHeight == 0)\r
- {\r
- return true;\r
- }\r
-\r
- NcvSize32u srcSize(this->width, this->height);\r
-\r
- NCVMatrixAlloc<T> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
-\r
- NCVMatrixAlloc<T> d_small(*this->allocatorGPU.get(), smallWidth, smallHeight);\r
- ncvAssertReturn(d_small.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_small(*this->allocatorCPU.get(), smallWidth, smallHeight);\r
- ncvAssertReturn(h_small.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_small_d(*this->allocatorCPU.get(), smallWidth, smallHeight);\r
- ncvAssertReturn(h_small_d.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
- NCV_SKIP_COND_END\r
-\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_BEGIN\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- ncvStat = nppiStDownsampleNearest_32u_C1R((Ncv32u *)d_img.ptr(), d_img.pitch(),\r
- (Ncv32u *)d_small.ptr(), d_small.pitch(),\r
- srcSize, this->scaleFactor,\r
- this->bTextureCache);\r
- }\r
- else if (sizeof(T) == sizeof(Ncv64u))\r
- {\r
- ncvStat = nppiStDownsampleNearest_64u_C1R((Ncv64u *)d_img.ptr(), d_img.pitch(),\r
- (Ncv64u *)d_small.ptr(), d_small.pitch(),\r
- srcSize, this->scaleFactor,\r
- this->bTextureCache);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect downsample test instance", false);\r
- }\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
- ncvStat = d_small.copySolid(h_small_d, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- NCV_SKIP_COND_BEGIN\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- ncvStat = nppiStDownsampleNearest_32u_C1R_host((Ncv32u *)h_img.ptr(), h_img.pitch(),\r
- (Ncv32u *)h_small.ptr(), h_small.pitch(),\r
- srcSize, this->scaleFactor);\r
- }\r
- else if (sizeof(T) == sizeof(Ncv64u))\r
- {\r
- ncvStat = nppiStDownsampleNearest_64u_C1R_host((Ncv64u *)h_img.ptr(), h_img.pitch(),\r
- (Ncv64u *)h_small.ptr(), h_small.pitch(),\r
- srcSize, this->scaleFactor);\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect downsample test instance", false);\r
- }\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- //const Ncv64f relEPS = 0.005;\r
- for (Ncv32u i=0; bLoopVirgin && i < h_small.height(); i++)\r
- {\r
- for (Ncv32u j=0; bLoopVirgin && j < h_small.width(); j++)\r
- {\r
- if (h_small.ptr()[h_small.stride()*i+j] != h_small_d.ptr()[h_small_d.stride()*i+j])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestResize<T>::deinit()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template class TestResize<Ncv32u>;\r
-template class TestResize<Ncv64u>;\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testresize_h_\r
-#define _testresize_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-template <class T>\r
-class TestResize : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestResize(std::string testName, NCVTestSourceProvider<T> &src,\r
- Ncv32u width, Ncv32u height, Ncv32u scaleFactor, NcvBool bTextureCache);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
- TestResize(const TestResize&);\r
- TestResize& operator=(const TestResize&); \r
-\r
- NCVTestSourceProvider<T> &src;\r
- Ncv32u width;\r
- Ncv32u height;\r
- Ncv32u scaleFactor;\r
-\r
- NcvBool bTextureCache;\r
-};\r
-\r
-#endif // _testresize_h_\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-\r
-#include <math.h>\r
-\r
-#include "TestTranspose.h"\r
-\r
-\r
-template <class T>\r
-TestTranspose<T>::TestTranspose(std::string testName, NCVTestSourceProvider<T> &src,\r
- Ncv32u width, Ncv32u height)\r
- :\r
- NCVTestProvider(testName),\r
- src(src),\r
- width(width),\r
- height(height)\r
-{\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestTranspose<T>::toString(std::ofstream &strOut)\r
-{\r
- strOut << "sizeof(T)=" << sizeof(T) << std::endl;\r
- strOut << "width=" << width << std::endl;\r
- return true;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestTranspose<T>::init()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestTranspose<T>::process()\r
-{\r
- NCVStatus ncvStat;\r
- bool rcode = false;\r
-\r
- NcvSize32u srcSize(this->width, this->height);\r
-\r
- NCVMatrixAlloc<T> d_img(*this->allocatorGPU.get(), this->width, this->height);\r
- ncvAssertReturn(d_img.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_img(*this->allocatorCPU.get(), this->width, this->height);\r
- ncvAssertReturn(h_img.isMemAllocated(), false);\r
-\r
- NCVMatrixAlloc<T> d_dst(*this->allocatorGPU.get(), this->height, this->width);\r
- ncvAssertReturn(d_dst.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_dst(*this->allocatorCPU.get(), this->height, this->width);\r
- ncvAssertReturn(h_dst.isMemAllocated(), false);\r
- NCVMatrixAlloc<T> h_dst_d(*this->allocatorCPU.get(), this->height, this->width);\r
- ncvAssertReturn(h_dst_d.isMemAllocated(), false);\r
-\r
- NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());\r
- NCV_SKIP_COND_BEGIN\r
- ncvAssertReturn(this->src.fill(h_img), false);\r
- NCV_SKIP_COND_END\r
-\r
- ncvStat = h_img.copySolid(d_img, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_BEGIN\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- ncvStat = nppiStTranspose_32u_C1R((Ncv32u *)d_img.ptr(), d_img.pitch(),\r
- (Ncv32u *)d_dst.ptr(), d_dst.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- }\r
- else if (sizeof(T) == sizeof(Ncv64u))\r
- {\r
- ncvStat = nppiStTranspose_64u_C1R((Ncv64u *)d_img.ptr(), d_img.pitch(),\r
- (Ncv64u *)d_dst.ptr(), d_dst.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect transpose test instance", false);\r
- }\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
- ncvStat = d_dst.copySolid(h_dst_d, 0);\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
-\r
- NCV_SKIP_COND_BEGIN\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- ncvStat = nppiStTranspose_32u_C1R_host((Ncv32u *)h_img.ptr(), h_img.pitch(),\r
- (Ncv32u *)h_dst.ptr(), h_dst.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- }\r
- else if (sizeof(T) == sizeof(Ncv64u))\r
- {\r
- ncvStat = nppiStTranspose_64u_C1R_host((Ncv64u *)h_img.ptr(), h_img.pitch(),\r
- (Ncv64u *)h_dst.ptr(), h_dst.pitch(),\r
- NcvSize32u(this->width, this->height));\r
- }\r
- else\r
- {\r
- ncvAssertPrintReturn(false, "Incorrect downsample test instance", false);\r
- }\r
- ncvAssertReturn(ncvStat == NPPST_SUCCESS, false);\r
- NCV_SKIP_COND_END\r
-\r
- //bit-to-bit check\r
- bool bLoopVirgin = true;\r
-\r
- NCV_SKIP_COND_BEGIN\r
- //const Ncv64f relEPS = 0.005;\r
- for (Ncv32u i=0; bLoopVirgin && i < this->width; i++)\r
- {\r
- for (Ncv32u j=0; bLoopVirgin && j < this->height; j++)\r
- {\r
- if (h_dst.ptr()[h_dst.stride()*i+j] != h_dst_d.ptr()[h_dst_d.stride()*i+j])\r
- {\r
- bLoopVirgin = false;\r
- }\r
- }\r
- }\r
- NCV_SKIP_COND_END\r
-\r
- if (bLoopVirgin)\r
- {\r
- rcode = true;\r
- }\r
-\r
- return rcode;\r
-}\r
-\r
-\r
-template <class T>\r
-bool TestTranspose<T>::deinit()\r
-{\r
- return true;\r
-}\r
-\r
-\r
-template class TestTranspose<Ncv32u>;\r
-template class TestTranspose<Ncv64u>;\r
+++ /dev/null
-/*\r
- * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.\r
- *\r
- * NVIDIA Corporation and its licensors retain all intellectual \r
- * property and proprietary rights in and to this software and \r
- * related documentation and any modifications thereto. \r
- * Any use, reproduction, disclosure, or distribution of this \r
- * software and related documentation without an express license \r
- * agreement from NVIDIA Corporation is strictly prohibited.\r
- */\r
-#ifndef _testtranspose_h_\r
-#define _testtranspose_h_\r
-\r
-#include "NCVTest.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-template <class T>\r
-class TestTranspose : public NCVTestProvider\r
-{\r
-public:\r
-\r
- TestTranspose(std::string testName, NCVTestSourceProvider<T> &src,\r
- Ncv32u width, Ncv32u height);\r
-\r
- virtual bool init();\r
- virtual bool process();\r
- virtual bool deinit();\r
- virtual bool toString(std::ofstream &strOut);\r
-\r
-private:\r
-\r
- TestTranspose(const TestTranspose&);\r
- TestTranspose& operator=(const TestTranspose&); \r
-\r
- NCVTestSourceProvider<T> &src;\r
- Ncv32u width;\r
- Ncv32u height;\r
-};\r
-\r
-#endif // _testtranspose_h_\r
+++ /dev/null
-#pragma warning (disable : 4408 4201 4100)\r
- \r
-#include <cstdio>\r
-\r
-#include "NCV.hpp"\r
-#include "NCVHaarObjectDetection.hpp"\r
-\r
-#include "TestIntegralImage.h"\r
-#include "TestIntegralImageSquared.h"\r
-#include "TestRectStdDev.h"\r
-#include "TestResize.h"\r
-#include "TestCompact.h"\r
-#include "TestTranspose.h"\r
-\r
-#include "TestDrawRects.h"\r
-#include "TestHypothesesGrow.h"\r
-#include "TestHypothesesFilter.h"\r
-#include "TestHaarCascadeLoader.h"\r
-#include "TestHaarCascadeApplication.h"\r
-\r
-#include "NCVAutoTestLister.hpp"\r
-#include "NCVTestSourceProvider.hpp"\r
-\r
-\r
-template <class T_in, class T_out>\r
-void generateIntegralTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<T_in> &src,\r
- Ncv32u maxWidth, Ncv32u maxHeight)\r
-{\r
- for (Ncv32f _i=1.0; _i<maxWidth; _i*=1.2f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "LinIntImgW%dH%d", i, 2);\r
- testLister.add(new TestIntegralImage<T_in, T_out>(testName, src, i, 2));\r
- }\r
- for (Ncv32f _i=1.0; _i<maxHeight; _i*=1.2f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "LinIntImgW%dH%d", 2, i);\r
- testLister.add(new TestIntegralImage<T_in, T_out>(testName, src, 2, i));\r
- }\r
-\r
- //test VGA\r
- testLister.add(new TestIntegralImage<T_in, T_out>("LinIntImg_VGA", src, 640, 480));\r
-\r
- //TODO: add tests of various resolutions up to 4096x4096\r
-}\r
-\r
-\r
-void generateSquaredIntegralTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u maxWidth, Ncv32u maxHeight)\r
-{\r
- for (Ncv32f _i=1.0; _i<maxWidth; _i*=1.2f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "SqIntImgW%dH%d", i, 32);\r
- testLister.add(new TestIntegralImageSquared(testName, src, i, 32));\r
- }\r
- for (Ncv32f _i=1.0; _i<maxHeight; _i*=1.2f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "SqIntImgW%dH%d", 32, i);\r
- testLister.add(new TestIntegralImageSquared(testName, src, 32, i));\r
- }\r
-\r
- //test VGA\r
- testLister.add(new TestIntegralImageSquared("SqLinIntImg_VGA", src, 640, 480));\r
-\r
- //TODO: add tests of various resolutions up to 4096x4096\r
-}\r
-\r
-\r
-void generateRectStdDevTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u maxWidth, Ncv32u maxHeight)\r
-{\r
- NcvRect32u rect(1,1,18,18);\r
-\r
- for (Ncv32f _i=32; _i<maxHeight/2 && _i < maxWidth/2; _i*=1.2f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "RectStdDevW%dH%d", i*2, i);\r
- testLister.add(new TestRectStdDev(testName, src, i*2, i, rect, 1, true));\r
- testLister.add(new TestRectStdDev(testName, src, i*2, i, rect, 1.5, false));\r
- testLister.add(new TestRectStdDev(testName, src, i-1, i*2-1, rect, 1, false));\r
- testLister.add(new TestRectStdDev(testName, src, i-1, i*2-1, rect, 2.5, true));\r
- }\r
-\r
- //test VGA\r
- testLister.add(new TestRectStdDev("RectStdDev_VGA", src, 640, 480, rect, 1, true));\r
-\r
- //TODO: add tests of various resolutions up to 4096x4096\r
-}\r
-\r
-\r
-template <class T>\r
-void generateResizeTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<T> &src)\r
-{\r
- //test VGA\r
- for (Ncv32u i=1; i<480; i+=3)\r
- {\r
- char testName[80];\r
- sprintf(testName, "TestResize_VGA_s%d", i);\r
- testLister.add(new TestResize<T>(testName, src, 640, 480, i, true));\r
- testLister.add(new TestResize<T>(testName, src, 640, 480, i, false));\r
- }\r
-\r
- //test HD\r
- for (Ncv32u i=1; i<1080; i+=5)\r
- {\r
- char testName[80];\r
- sprintf(testName, "TestResize_1080_s%d", i);\r
- testLister.add(new TestResize<T>(testName, src, 1920, 1080, i, true));\r
- testLister.add(new TestResize<T>(testName, src, 1920, 1080, i, false));\r
- }\r
-\r
- //TODO: add tests of various resolutions up to 4096x4096\r
-}\r
-\r
-\r
-void generateNPPSTVectorTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<Ncv32u> &src, Ncv32u maxLength)\r
-{\r
- //compaction\r
- for (Ncv32f _i=256.0; _i<maxLength; _i*=1.1f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "Compaction%d", i);\r
- testLister.add(new TestCompact(testName, src, i, 0xFFFFFFFF, 30));\r
- }\r
- for (Ncv32u i=1; i<260; i++)\r
- {\r
- char testName[80];\r
- sprintf(testName, "Compaction%d", i);\r
- testLister.add(new TestCompact(testName, src, i, 0xC001C0DE, 70));\r
- testLister.add(new TestCompact(testName, src, i, 0xC001C0DE, 0));\r
- testLister.add(new TestCompact(testName, src, i, 0xC001C0DE, 100));\r
- }\r
- for (Ncv32u i=256*256-256; i<256*256+257; i++)\r
- {\r
- char testName[80];\r
- sprintf(testName, "Compaction%d", i);\r
- testLister.add(new TestCompact(testName, src, i, 0xFFFFFFFF, 40));\r
- }\r
- for (Ncv32u i=256*256*256-10; i<256*256*256+10; i++)\r
- {\r
- char testName[80];\r
- sprintf(testName, "Compaction%d", i);\r
- testLister.add(new TestCompact(testName, src, i, 0x00000000, 2));\r
- }\r
-}\r
-\r
-\r
-template <class T>\r
-void generateTransposeTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<T> &src)\r
-{\r
- for (int i=2; i<64; i+=4)\r
- {\r
- for (int j=2; j<64; j+=4)\r
- {\r
- char testName[80];\r
- sprintf(testName, "TestTranspose_%dx%d", i, j);\r
- testLister.add(new TestTranspose<T>(testName, src, i, j));\r
- }\r
- }\r
-\r
- for (int i=1; i<128; i+=1)\r
- {\r
- for (int j=1; j<2; j+=1)\r
- {\r
- char testName[80];\r
- sprintf(testName, "TestTranspose_%dx%d", i, j);\r
- testLister.add(new TestTranspose<T>(testName, src, i, j));\r
- }\r
- }\r
-\r
- testLister.add(new TestTranspose<T>("TestTranspose_VGA", src, 640, 480));\r
- testLister.add(new TestTranspose<T>("TestTranspose_HD1080", src, 1920, 1080));\r
-\r
- //regression tests\r
- testLister.add(new TestTranspose<T>("TestTranspose_reg_0", src, 1072, 375));\r
-}\r
-\r
-\r
-template <class T>\r
-void generateDrawRectsTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<T> &src, NCVTestSourceProvider<Ncv32u> &src32u,\r
- Ncv32u maxWidth, Ncv32u maxHeight)\r
-{\r
- for (Ncv32f _i=16.0; _i<maxWidth; _i*=1.1f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- Ncv32u j = maxHeight * i / maxWidth;\r
- if (!j) continue;\r
- char testName[80];\r
- sprintf(testName, "DrawRectsW%dH%d", i, j);\r
-\r
- if (sizeof(T) == sizeof(Ncv32u))\r
- {\r
- testLister.add(new TestDrawRects<T>(testName, src, src32u, i, j, i*j/1000+1, (T)0xFFFFFFFF));\r
- }\r
- else if (sizeof(T) == sizeof(Ncv8u))\r
- {\r
- testLister.add(new TestDrawRects<T>(testName, src, src32u, i, j, i*j/1000+1, (T)0xFF));\r
- }\r
- else\r
- {\r
- ncvAssertPrintCheck(false, "Attempted to instantiate non-existing DrawRects test suite");\r
- }\r
- }\r
-\r
- //test VGA\r
- testLister.add(new TestDrawRects<T>("DrawRects_VGA", src, src32u, 640, 480, 640*480/1000, (T)0xFF));\r
-\r
- //TODO: add tests of various resolutions up to 4096x4096\r
-}\r
-\r
-\r
-void generateVectorTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<Ncv32u> &src, Ncv32u maxLength)\r
-{\r
- //growth\r
- for (Ncv32f _i=10.0; _i<maxLength; _i*=1.1f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "VectorGrow%d", i);\r
- testLister.add(new TestHypothesesGrow(testName, src, 20, 20, 2.2f, i, i/2, i, i/4));\r
- testLister.add(new TestHypothesesGrow(testName, src, 10, 42, 1.2f, i, i, i, 0));\r
- }\r
- testLister.add(new TestHypothesesGrow("VectorGrow01b", src, 10, 42, 1.2f, 10, 0, 10, 1));\r
- testLister.add(new TestHypothesesGrow("VectorGrow11b", src, 10, 42, 1.2f, 10, 1, 10, 1));\r
- testLister.add(new TestHypothesesGrow("VectorGrow10b", src, 10, 42, 1.2f, 10, 1, 10, 0));\r
- testLister.add(new TestHypothesesGrow("VectorGrow00b", src, 10, 42, 1.2f, 10, 0, 10, 0));\r
-}\r
-\r
-\r
-void generateHypothesesFiltrationTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<Ncv32u> &src, Ncv32u maxLength)\r
-{\r
- for (Ncv32f _i=1.0; _i<maxLength; _i*=1.1f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "HypFilter%d", i);\r
- testLister.add(new TestHypothesesFilter(testName, src, i, 3, 0.2f));\r
- testLister.add(new TestHypothesesFilter(testName, src, i, 0, 0.2f));\r
- testLister.add(new TestHypothesesFilter(testName, src, i, 1, 0.1f));\r
- }\r
-}\r
-\r
-\r
-void generateHaarLoaderTests(NCVAutoTestLister &testLister)\r
-{\r
- testLister.add(new TestHaarCascadeLoader("haarcascade_eye.xml", "haarcascade_eye.xml"));\r
- testLister.add(new TestHaarCascadeLoader("haarcascade_frontalface_alt.xml", "haarcascade_frontalface_alt.xml"));\r
- testLister.add(new TestHaarCascadeLoader("haarcascade_frontalface_alt2.xml", "haarcascade_frontalface_alt2.xml"));\r
- testLister.add(new TestHaarCascadeLoader("haarcascade_frontalface_alt_tree.xml", "haarcascade_frontalface_alt_tree.xml"));\r
- testLister.add(new TestHaarCascadeLoader("haarcascade_eye_tree_eyeglasses.xml", "haarcascade_eye_tree_eyeglasses.xml"));\r
-}\r
-\r
-\r
-void generateHaarApplicationTests(NCVAutoTestLister &testLister, NCVTestSourceProvider<Ncv8u> &src,\r
- Ncv32u maxWidth, Ncv32u maxHeight)\r
-{\r
- for (Ncv32u i=20; i<512; i+=11)\r
- {\r
- for (Ncv32u j=20; j<128; j+=5)\r
- {\r
- char testName[80];\r
- sprintf(testName, "HaarAppl%d_%d", i, j);\r
- testLister.add(new TestHaarCascadeApplication(testName, src, "haarcascade_frontalface_alt.xml", j, i));\r
- }\r
- }\r
- for (Ncv32f _i=20.0; _i<maxWidth; _i*=1.1f)\r
- {\r
- Ncv32u i = (Ncv32u)_i;\r
- char testName[80];\r
- sprintf(testName, "HaarAppl%d", i);\r
- testLister.add(new TestHaarCascadeApplication(testName, src, "haarcascade_frontalface_alt.xml", i, i));\r
- }\r
-}\r
-\r
-\r
-static void devNullOutput(const char *msg)\r
-{\r
-}\r
-\r
-\r
-bool main_nvidia()\r
-{\r
- printf("Testing NVIDIA Computer Vision SDK\n");\r
- printf("==================================\n");\r
-\r
- ncvSetDebugOutputHandler(devNullOutput);\r
-\r
- NCVAutoTestLister testListerII("NPPST Integral Image" );//,,true, false);\r
- NCVAutoTestLister testListerSII("NPPST Squared Integral Image" );//,,true, false);\r
- NCVAutoTestLister testListerRStdDev("NPPST RectStdDev" );//,,true, false);\r
- NCVAutoTestLister testListerResize("NPPST Resize" );//,,true, false);\r
- NCVAutoTestLister testListerNPPSTVectorOperations("NPPST Vector Operations" );//,,true, false);\r
- NCVAutoTestLister testListerTranspose("NPPST Transpose" );//,,true, false);\r
-\r
- NCVAutoTestLister testListerVectorOperations("Vector Operations" );//,,true, false);\r
- NCVAutoTestLister testListerHaarLoader("Haar Cascade Loader" );//,,true, false);\r
- NCVAutoTestLister testListerHaarAppl("Haar Cascade Application" );//,,true, false);\r
- NCVAutoTestLister testListerHypFiltration("Hypotheses Filtration" );//,,true, false);\r
- NCVAutoTestLister testListerVisualize("Visualization" );//,,true, false);\r
-\r
- printf("Initializing data source providers\n");\r
- NCVTestSourceProvider<Ncv32u> testSrcRandom_32u(2010, 0, 0xFFFFFFFF, 4096, 4096);\r
- NCVTestSourceProvider<Ncv8u> testSrcRandom_8u(2010, 0, 255, 4096, 4096);\r
- NCVTestSourceProvider<Ncv64u> testSrcRandom_64u(2010, 0, 0xFFFFFFFFFFFFFFFF, 4096, 4096);\r
- NCVTestSourceProvider<Ncv8u> testSrcFacesVGA_8u("../../data/group_1_640x480_VGA.pgm");\r
- NCVTestSourceProvider<Ncv32f> testSrcRandom_32f(2010, -1.0f, 1.0f, 4096, 4096);\r
-\r
- printf("Generating NPPST test suites\n");\r
- generateIntegralTests<Ncv8u, Ncv32u>(testListerII, testSrcRandom_8u, 4096, 4096);\r
- generateIntegralTests<Ncv32f, Ncv32f>(testListerII, testSrcRandom_32f, 4096, 4096);\r
- generateSquaredIntegralTests(testListerSII, testSrcRandom_8u, 4096, 4096);\r
- generateRectStdDevTests(testListerRStdDev, testSrcRandom_8u, 4096, 4096);\r
- generateResizeTests(testListerResize, testSrcRandom_32u);\r
- generateResizeTests(testListerResize, testSrcRandom_64u);\r
- generateNPPSTVectorTests(testListerNPPSTVectorOperations, testSrcRandom_32u, 4096*4096);\r
- generateTransposeTests(testListerTranspose, testSrcRandom_32u);\r
- generateTransposeTests(testListerTranspose, testSrcRandom_64u);\r
-\r
- printf("Generating NCV test suites\n");\r
- generateDrawRectsTests(testListerVisualize, testSrcRandom_8u, testSrcRandom_32u, 4096, 4096);\r
- generateDrawRectsTests(testListerVisualize, testSrcRandom_32u, testSrcRandom_32u, 4096, 4096);\r
- generateVectorTests(testListerVectorOperations, testSrcRandom_32u, 4096*4096);\r
- generateHypothesesFiltrationTests(testListerHypFiltration, testSrcRandom_32u, 1024);\r
- generateHaarLoaderTests(testListerHaarLoader);\r
- generateHaarApplicationTests(testListerHaarAppl, testSrcFacesVGA_8u, 1280, 720);\r
-\r
- // Indicate if at least one test failed\r
- bool passed = true;\r
-\r
- // Invoke all tests\r
- passed &= testListerII.invoke();\r
- passed &= testListerSII.invoke();\r
- passed &= testListerRStdDev.invoke();\r
- passed &= testListerResize.invoke();\r
- passed &= testListerNPPSTVectorOperations.invoke();\r
- passed &= testListerTranspose.invoke();\r
- passed &= testListerVisualize.invoke();\r
- passed &= testListerVectorOperations.invoke();\r
- passed &= testListerHypFiltration.invoke();\r
- passed &= testListerHaarLoader.invoke();\r
- passed &= testListerHaarAppl.invoke();\r
-\r
- return passed;\r
-}\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// Intel License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000, Intel Corporation, all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other materials provided with the distribution.\r
-//\r
-// * The name of Intel Corporation may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or implied warranties, including, but not limited to, the implied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-#include "cvconfig.h"\r
-\r
-class CV_NVidiaTestsCaller : public CvTest\r
-{\r
-public:\r
- CV_NVidiaTestsCaller() : CvTest("GPU-NVidia", "NVidia") {}\r
- virtual ~CV_NVidiaTestsCaller() {}\r
-\r
-protected:\r
- \r
- void run( int )\r
- { \r
-#if defined(HAVE_CUDA)\r
- bool main_nvidia();\r
-\r
- // Invoke all NVIDIA Staging tests and obtain the result\r
- bool passed = main_nvidia();\r
-\r
- if (passed)\r
- ts->set_failed_test_info(CvTS::OK);\r
- else\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
-\r
-#else\r
- ts->set_failed_test_info(CvTS::SKIPPED);\r
-#endif\r
- } \r
-} CV_NVidiaTestsCaller_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-
-using namespace std;
-using namespace cv;
-using namespace cv::gpu;
-
-struct CV_AsyncGpuMatTest : public CvTest
-{
- CV_AsyncGpuMatTest() : CvTest( "GPU-AsyncGpuMatOperator", "async" )
- {
- }
-
- void run(int)
- {
- try
- {
- CudaMem src(Mat::zeros(100, 100, CV_8UC1));
-
- GpuMat gpusrc;
- GpuMat gpudst0, gpudst1(100, 100, CV_8UC1);
-
- CudaMem cpudst0;
- CudaMem cpudst1;
-
- Stream stream0, stream1;
-
- stream0.enqueueUpload(src, gpusrc);
- bitwise_not(gpusrc, gpudst0, GpuMat(), stream0);
- stream0.enqueueDownload(gpudst0, cpudst0);
-
- stream1.enqueueMemSet(gpudst1, Scalar::all(128));
- stream1.enqueueDownload(gpudst1, cpudst1);
-
- stream0.waitForCompletion();
- stream1.waitForCompletion();
-
- Mat cpu_gold0(100, 100, CV_8UC1, Scalar::all(255));
- Mat cpu_gold1(100, 100, CV_8UC1, Scalar::all(128));
-
- if (norm(cpudst0, cpu_gold0, NORM_INF) > 0 || norm(cpudst1, cpu_gold1, NORM_INF) > 0)
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
- else
- ts->set_failed_test_info(CvTS::OK);
- }
- catch(cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
- }
-} CV_AsyncGpuMatTest_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <iterator>
-#include <limits>
-#include <numeric>
-
-using namespace cv;
-using namespace std;
-using namespace gpu;
-
-class CV_GpuMatOpConvertToTest : public CvTest
-{
- public:
- CV_GpuMatOpConvertToTest() : CvTest( "GPU-MatOperatorConvertTo", "convertTo" ) {}
- ~CV_GpuMatOpConvertToTest() {}
-
- protected:
- void run(int);
-};
-
-void CV_GpuMatOpConvertToTest::run(int /* start_from */)
-{
- const Size img_size(67, 35);
-
- const char* types_str[] = {"CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F"};
-
- bool passed = true;
- try
- {
- int lastType = CV_32F;
-
- if (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))\r
- lastType = CV_64F;
-
- for (int i = 0; i <= lastType && passed; ++i)
- {
- for (int j = 0; j <= lastType && passed; ++j)
- {
- for (int c = 1; c < 5 && passed; ++c)
- {
- const int src_type = CV_MAKETYPE(i, c);
- const int dst_type = j;
-
- cv::RNG rng(*ts->get_rng());
-
- Mat cpumatsrc(img_size, src_type);
- rng.fill(cpumatsrc, RNG::UNIFORM, Scalar::all(0), Scalar::all(300));
-
- GpuMat gpumatsrc(cpumatsrc);
- Mat cpumatdst;
- GpuMat gpumatdst;
-
- cpumatsrc.convertTo(cpumatdst, dst_type, 0.5, 3.0);
- gpumatsrc.convertTo(gpumatdst, dst_type, 0.5, 3.0);
-
- double r = norm(cpumatdst, gpumatdst, NORM_INF);
- if (r > 1)
- {
- ts->printf(CvTS::LOG,
- "\nFAILED: SRC_TYPE=%sC%d DST_TYPE=%s NORM = %f\n",
- types_str[i], c, types_str[j], r);
- passed = false;
- }
- }
- }
- }
- }
- catch(cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- ts->set_failed_test_info(passed ? CvTS::OK : CvTS::FAIL_GENERIC);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_GpuMatOpConvertToTest CV_GpuMatOpConvertToTest_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-#include <string>
-#include <iostream>
-#include <fstream>
-#include <iterator>
-#include <limits>
-#include <numeric>
-#include <iomanip> // for cout << setw()
-
-using namespace cv;
-using namespace std;
-using namespace gpu;
-
-class CV_GpuMatOpCopyToTest : public CvTest
-{
- public:
- CV_GpuMatOpCopyToTest() : CvTest( "GPU-MatOperatorCopyTo", "copyTo" )
- {
- rows = 234;
- cols = 123;
- }
- ~CV_GpuMatOpCopyToTest() {}
-
- protected:
- void run(int);
- template <typename T>
- void print_mat(const T & mat, const std::string & name) const;
- bool compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat);
-
- private:
- int rows;
- int cols;
-};
-
-template<typename T>
-void CV_GpuMatOpCopyToTest::print_mat(const T & mat, const std::string & name) const { cv::imshow(name, mat); }
-
-bool CV_GpuMatOpCopyToTest::compare_matrix(cv::Mat & cpumat, gpu::GpuMat & gpumat)
-{
- Mat cmat(cpumat.size(), cpumat.type(), Scalar::all(0));
- GpuMat gmat(cmat);
-
- Mat cpumask(cpumat.size(), CV_8U);
-
- cv::RNG rng(*ts->get_rng());
-
- rng.fill(cpumask, RNG::NORMAL, Scalar::all(0), Scalar::all(127));
-
- threshold(cpumask, cpumask, 0, 127, THRESH_BINARY);
-
- GpuMat gpumask(cpumask);
-
- //int64 time = getTickCount();
- cpumat.copyTo(cmat, cpumask);
- //int64 time1 = getTickCount();
- gpumat.copyTo(gmat, gpumask);
- //int64 time2 = getTickCount();
-
- //std::cout << "\ntime cpu: " << std::fixed << std::setprecision(12) << 1.0 / double((time1 - time) / (double)getTickFrequency());
- //std::cout << "\ntime gpu: " << std::fixed << std::setprecision(12) << 1.0 / double((time2 - time1) / (double)getTickFrequency());
- //std::cout << "\n";
-
-#ifdef PRINT_MATRIX
- print_mat(cmat, "cpu mat");
- print_mat(gmat, "gpu mat");
- print_mat(cpumask, "cpu mask");
- print_mat(gpumask, "gpu mask");
- cv::waitKey(0);
-#endif
-
- double ret = norm(cmat, gmat);
-
- if (ret < 1.0)
- return true;
- else
- {
- ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);
- return false;
- }
-}
-
-void CV_GpuMatOpCopyToTest::run( int /* start_from */)
-{
- bool is_test_good = true;
-
- try
- {
- int lastType = CV_32F;
-
- if (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))\r
- lastType = CV_64F;
-
- for (int i = 0 ; i <= lastType; i++)
- {
- Mat cpumat(rows, cols, i);
- cpumat.setTo(Scalar::all(127));
-
- GpuMat gpumat(cpumat);
-
- is_test_good &= compare_matrix(cpumat, gpumat);
- }
- }
- catch(const cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- if (is_test_good == true)
- ts->set_failed_test_info(CvTS::OK);
- else
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_GpuMatOpCopyToTest CV_GpuMatOpCopyTo_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-#include <limits>
-
-using namespace cv;
-using namespace std;
-using namespace gpu;
-
-class CV_GpuMatOpSetToTest : public CvTest
-{
-public:
- CV_GpuMatOpSetToTest();
- ~CV_GpuMatOpSetToTest() {}
-
-protected:
- void run(int);
-
- bool testSetTo(cv::Mat& cpumat, gpu::GpuMat& gpumat, const cv::Mat& cpumask = cv::Mat(), const cv::gpu::GpuMat& gpumask = cv::gpu::GpuMat());
-
-private:
- int rows;
- int cols;
- Scalar s;
-};
-
-CV_GpuMatOpSetToTest::CV_GpuMatOpSetToTest(): CvTest( "GPU-MatOperatorSetTo", "setTo" )
-{
- rows = 35;
- cols = 67;
-
- s.val[0] = 127.0;
- s.val[1] = 127.0;
- s.val[2] = 127.0;
- s.val[3] = 127.0;
-}
-
-bool CV_GpuMatOpSetToTest::testSetTo(cv::Mat& cpumat, gpu::GpuMat& gpumat, const cv::Mat& cpumask, const cv::gpu::GpuMat& gpumask)
-{
- cpumat.setTo(s, cpumask);
- gpumat.setTo(s, gpumask);
-
- double ret = norm(cpumat, gpumat, NORM_INF);
-
- if (ret < std::numeric_limits<double>::epsilon())
- return true;
- else
- {
- ts->printf(CvTS::LOG, "\nNorm: %f\n", ret);
- return false;
- }
-}
-
-void CV_GpuMatOpSetToTest::run( int /* start_from */)
-{
- bool is_test_good = true;
-
- try
- {
- cv::Mat cpumask(rows, cols, CV_8UC1);
- cv::RNG rng(*ts->get_rng());
- rng.fill(cpumask, RNG::UNIFORM, cv::Scalar::all(0.0), cv::Scalar(1.5));
- cv::gpu::GpuMat gpumask(cpumask);
-
- int lastType = CV_32F;
-
- if (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE))\r
- lastType = CV_64F;
-
- for (int i = 0; i <= lastType; i++)
- {
- for (int cn = 1; cn <= 4; ++cn)
- {
- int mat_type = CV_MAKETYPE(i, cn);
- Mat cpumat(rows, cols, mat_type, Scalar::all(0));
- GpuMat gpumat(cpumat);
- is_test_good &= testSetTo(cpumat, gpumat, cpumask, gpumask);
- }
- }
- }
- catch(const cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- if (is_test_good == true)
- ts->set_failed_test_info(CvTS::OK);
- else
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
-}
-
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_GpuMatOpSetToTest CV_GpuMatOpSetTo_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////\r
-//\r
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
-//\r
-// By downloading, copying, installing or using the software you agree to this license.\r
-// If you do not agree to this license, do not download, install,\r
-// copy or use the software.\r
-//\r
-//\r
-// License Agreement\r
-// For Open Source Computer Vision Library\r
-//\r
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
-// Third party copyrights are property of their respective owners.\r
-//\r
-// Redistribution and use in source and binary forms, with or without modification,\r
-// are permitted provided that the following conditions are met:\r
-//\r
-// * Redistribution's of source code must retain the above copyright notice,\r
-// this list of conditions and the following disclaimer.\r
-//\r
-// * Redistribution's in binary form must reproduce the above copyright notice,\r
-// this list of conditions and the following disclaimer in the documentation\r
-// and/or other GpuMaterials provided with the distribution.\r
-//\r
-// * The name of the copyright holders may not be used to endorse or promote products\r
-// derived from this software without specific prior written permission.\r
-//\r
-// This software is provided by the copyright holders and contributors "as is" and\r
-// any express or bpied warranties, including, but not limited to, the bpied\r
-// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
-// In no event shall the Intel Corporation or contributors be liable for any direct,\r
-// indirect, incidental, special, exemplary, or consequential damages\r
-// (including, but not limited to, procurement of substitute goods or services;\r
-// loss of use, data, or profits; or business interruption) however caused\r
-// and on any theory of liability, whether in contract, strict liability,\r
-// or tort (including negligence or otherwise) arising in any way out of\r
-// the use of this software, even if advised of the possibility of such damage.\r
-//\r
-//M*/\r
-\r
-#include "gputest.hpp"\r
-\r
-#include <iostream>\r
-#include <string>\r
-#include <vector>\r
-\r
-using namespace std;\r
-using namespace cv;\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Merge\r
-\r
-struct CV_MergeTest : public CvTest\r
-{\r
- CV_MergeTest() : CvTest("GPU-Merge", "merge") {}\r
- void can_merge(size_t rows, size_t cols);\r
- void can_merge_submatrixes(size_t rows, size_t cols);\r
- void run(int);\r
-};\r
-\r
-\r
-void CV_MergeTest::can_merge(size_t rows, size_t cols)\r
-{\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
- for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- vector<Mat> src;\r
- for (size_t i = 0; i < num_channels; ++i)\r
- src.push_back(Mat(rows, cols, depth, Scalar::all(static_cast<double>(i))));\r
- \r
- Mat dst(rows, cols, CV_MAKETYPE(depth, num_channels)); \r
-\r
- cv::merge(src, dst); \r
-\r
- vector<gpu::GpuMat> dev_src;\r
- for (size_t i = 0; i < num_channels; ++i)\r
- dev_src.push_back(gpu::GpuMat(src[i]));\r
-\r
- gpu::GpuMat dev_dst(rows, cols, CV_MAKETYPE(depth, num_channels));\r
- cv::gpu::merge(dev_src, dev_dst); \r
-\r
- Mat host_dst = dev_dst;\r
-\r
- double err = norm(dst, host_dst, NORM_INF);\r
-\r
- if (err > 1e-3)\r
- {\r
- //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
- //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
- //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
- //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
- //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
-}\r
-\r
-\r
-void CV_MergeTest::can_merge_submatrixes(size_t rows, size_t cols)\r
-{\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
- for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- vector<Mat> src;\r
- for (size_t i = 0; i < num_channels; ++i) \r
- {\r
- Mat m(rows * 2, cols * 2, depth, Scalar::all(static_cast<double>(i)));\r
- src.push_back(m(Range(rows / 2, rows / 2 + rows), Range(cols / 2, cols / 2 + cols)));\r
- }\r
-\r
- Mat dst(rows, cols, CV_MAKETYPE(depth, num_channels)); \r
-\r
- cv::merge(src, dst); \r
-\r
- vector<gpu::GpuMat> dev_src;\r
- for (size_t i = 0; i < num_channels; ++i)\r
- dev_src.push_back(gpu::GpuMat(src[i]));\r
-\r
- gpu::GpuMat dev_dst(rows, cols, CV_MAKETYPE(depth, num_channels));\r
- cv::gpu::merge(dev_src, dev_dst);\r
-\r
- Mat host_dst = dev_dst;\r
-\r
- double err = norm(dst, host_dst, NORM_INF);\r
-\r
- if (err > 1e-3)\r
- {\r
- //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
- //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
- //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
- //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
- //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
-}\r
-\r
-void CV_MergeTest::run(int) \r
-{\r
- try\r
- {\r
- can_merge(1, 1);\r
- can_merge(1, 7);\r
- can_merge(53, 7);\r
- can_merge_submatrixes(1, 1);\r
- can_merge_submatrixes(1, 7);\r
- can_merge_submatrixes(53, 7);\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw; \r
- } \r
-}\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Split\r
-\r
-struct CV_SplitTest : public CvTest\r
-{\r
- CV_SplitTest() : CvTest("GPU-Split", "split") {}\r
- void can_split(size_t rows, size_t cols); \r
- void can_split_submatrix(size_t rows, size_t cols);\r
- void run(int);\r
-};\r
-\r
-void CV_SplitTest::can_split(size_t rows, size_t cols)\r
-{\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
- for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- Mat src(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0)); \r
- vector<Mat> dst;\r
- cv::split(src, dst); \r
-\r
- gpu::GpuMat dev_src(src);\r
- vector<gpu::GpuMat> dev_dst;\r
- cv::gpu::split(dev_src, dev_dst);\r
-\r
- if (dev_dst.size() != dst.size())\r
- {\r
- ts->printf(CvTS::CONSOLE, "Bad output sizes");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
-\r
- for (size_t i = 0; i < num_channels; ++i)\r
- {\r
- Mat host_dst = dev_dst[i];\r
- double err = norm(dst[i], host_dst, NORM_INF);\r
-\r
- if (err > 1e-3)\r
- {\r
- //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
- //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
- //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
- //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
- //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- }\r
-}\r
-\r
-void CV_SplitTest::can_split_submatrix(size_t rows, size_t cols)\r
-{\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
- for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- Mat src_data(rows * 2, cols * 2, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0)); \r
- Mat src(src_data(Range(rows / 2, rows / 2 + rows), Range(cols / 2, cols / 2 + cols)));\r
- vector<Mat> dst;\r
- cv::split(src, dst); \r
-\r
- gpu::GpuMat dev_src(src);\r
- vector<gpu::GpuMat> dev_dst;\r
- cv::gpu::split(dev_src, dev_dst);\r
-\r
- if (dev_dst.size() != dst.size())\r
- {\r
- ts->printf(CvTS::CONSOLE, "Bad output sizes");\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- }\r
-\r
- for (size_t i = 0; i < num_channels; ++i)\r
- {\r
- Mat host_dst = dev_dst[i];\r
- double err = norm(dst[i], host_dst, NORM_INF);\r
-\r
- if (err > 1e-3)\r
- {\r
- //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
- //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
- //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
- //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
- //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
- }\r
-}\r
-\r
-void CV_SplitTest::run(int)\r
-{\r
- try \r
- {\r
- can_split(1, 1);\r
- can_split(1, 7);\r
- can_split(7, 53);\r
- can_split_submatrix(1, 1);\r
- can_split_submatrix(1, 7);\r
- can_split_submatrix(7, 53);\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw; \r
- } \r
-}\r
-\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Split and merge\r
-\r
-struct CV_SplitMergeTest : public CvTest\r
-{\r
- CV_SplitMergeTest() : CvTest("GPU-SplitMerge", "split merge") {}\r
- void can_split_merge(size_t rows, size_t cols); \r
- void run(int);\r
-};\r
-\r
-void CV_SplitMergeTest::can_split_merge(size_t rows, size_t cols) {\r
- bool double_ok = gpu::TargetArchs::builtWith(gpu::NATIVE_DOUBLE) && \r
- gpu::DeviceInfo().supports(gpu::NATIVE_DOUBLE);\r
- size_t depth_end = double_ok ? CV_64F : CV_32F;\r
-\r
- for (size_t num_channels = 1; num_channels <= 4; ++num_channels)\r
- for (size_t depth = CV_8U; depth <= depth_end; ++depth)\r
- {\r
- Mat orig(rows, cols, CV_MAKETYPE(depth, num_channels), Scalar(1.0, 2.0, 3.0, 4.0)); \r
- gpu::GpuMat dev_orig(orig);\r
- vector<gpu::GpuMat> dev_vec;\r
- cv::gpu::split(dev_orig, dev_vec);\r
-\r
- gpu::GpuMat dev_final(rows, cols, CV_MAKETYPE(depth, num_channels));\r
- cv::gpu::merge(dev_vec, dev_final);\r
-\r
- double err = cv::norm((Mat)dev_orig, (Mat)dev_final, NORM_INF);\r
- if (err > 1e-3)\r
- {\r
- //ts->printf(CvTS::CONSOLE, "\nNorm: %f\n", err);\r
- //ts->printf(CvTS::CONSOLE, "Depth: %d\n", depth);\r
- //ts->printf(CvTS::CONSOLE, "Rows: %d\n", rows);\r
- //ts->printf(CvTS::CONSOLE, "Cols: %d\n", cols);\r
- //ts->printf(CvTS::CONSOLE, "NumChannels: %d\n", num_channels);\r
- ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
- return;\r
- }\r
- }\r
-}\r
-\r
-\r
-void CV_SplitMergeTest::run(int) \r
-{\r
- try \r
- {\r
- can_split_merge(1, 1);\r
- can_split_merge(1, 7);\r
- can_split_merge(7, 53);\r
- }\r
- catch(const cv::Exception& e)\r
- {\r
- if (!check_and_treat_gpu_exception(e, ts))\r
- throw; \r
- } \r
-}\r
-\r
-\r
-/////////////////////////////////////////////////////////////////////////////\r
-/////////////////// tests registration /////////////////////////////////////\r
-/////////////////////////////////////////////////////////////////////////////\r
-\r
-// If we comment some tests, we may foget/miss to uncomment it after.\r
-// Placing all test definitions in one place \r
-// makes us know about what tests are commented.\r
-\r
-\r
-CV_SplitTest split_test;\r
-CV_MergeTest merge_test;\r
-CV_SplitMergeTest split_merge_test;\r
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-#include <iostream>
-#include <string>
-
-#include "opencv2/highgui/highgui.hpp"
-
-using namespace cv;
-using namespace cv::gpu;
-
-struct CV_GpuStereoBMTest : public CvTest
-{
- CV_GpuStereoBMTest() : CvTest( "GPU-StereoBM", "StereoBM" ){}
- ~CV_GpuStereoBMTest() {}
-
-
- void run_stress()
- {
- RNG rng;
-
- for(int i = 0; i < 10; ++i)
- {
- int winSize = cvRound(rng.uniform(2, 11)) * 2 + 1;
-
- for(int j = 0; j < 10; ++j)
- {
- int ndisp = cvRound(rng.uniform(5, 32)) * 8;
-
- for(int s = 0; s < 10; ++s)
- {
- int w = cvRound(rng.uniform(1024, 2048));
- int h = cvRound(rng.uniform(768, 1152));
-
- for(int p = 0; p < 2; ++p)
- {
- //int winSize = winsz[i];
- //int disp = disps[j];
- Size imgSize(w, h);//res[s];
- int preset = p;
-
- printf("Preset = %d, nidsp = %d, winsz = %d, width = %d, height = %d\n", p, ndisp, winSize, imgSize.width, imgSize.height);
-
- GpuMat l(imgSize, CV_8U);
- GpuMat r(imgSize, CV_8U);
-
- GpuMat disparity;
- StereoBM_GPU bm(preset, ndisp, winSize);
- bm(l, r, disparity);
-
-
- }
- }
- }
- }
- }
-
- void run(int )
- {
- /*run_stress();
- return;*/
-
- 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_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
-
- if (img_l.empty() || img_r.empty() || img_reference.empty())
- {
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
- return;
- }
-
- try
- {
- cv::gpu::GpuMat disp;
- cv::gpu::StereoBM_GPU bm(0, 128, 19);
- bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
-
- disp.convertTo(disp, img_reference.type());
- double norm = cv::norm(disp, img_reference, cv::NORM_INF);
-
- //cv::imwrite(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", disp);
-
- /*cv::imshow("disp", disp);
- cv::imshow("img_reference", img_reference);
-
- cv::Mat diff = (cv::Mat)disp - (cv::Mat)img_reference;
- cv::imshow("diff", diff);
- cv::waitKey();*/
-
- if (norm >= 100)
- {
- ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
- return;
- }
- }
- catch(const cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- ts->set_failed_test_info(CvTS::OK);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_GpuStereoBMTest CV_GpuStereoBM_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-
-using namespace cv;
-using namespace std;
-
-struct CV_AsyncStereoBMTest : public CvTest
-{
- public:
- CV_AsyncStereoBMTest() : CvTest( "GPU-AsyncStereoBM", "asyncStereoBM" ) {}
- ~CV_AsyncStereoBMTest() {}
-
- void run( int /* start_from */)
- {
- 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_reference = cv::imread(std::string(ts->get_data_path()) + "stereobm/aloe-disp.png", 0);
-
- if (img_l.empty() || img_r.empty() || img_reference.empty())
- {
- ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
- return;
- }
-
- try
- {
- cv::gpu::GpuMat disp;
- cv::gpu::StereoBM_GPU bm(0, 128, 19);
-
- cv::gpu::Stream stream;
-
- for (size_t i = 0; i < 50; i++)
- {
- bm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp, stream);
- }
-
- stream.waitForCompletion();
- disp.convertTo(disp, img_reference.type());
- double norm = cv::norm(disp, img_reference, cv::NORM_INF);
-
- if (norm >= 100)
- {
- ts->printf(CvTS::LOG, "\nStereoBM norm = %f\n", norm);
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
- return;
- }
- }
- catch(const cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- ts->set_failed_test_info(CvTS::OK);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_AsyncStereoBMTest CV_AsyncStereoBMTest_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-#include <iostream>
-#include <string>
-
-struct CV_GpuStereoBPTest : public CvTest
-{
- CV_GpuStereoBPTest() : CvTest( "GPU-StereoBP", "StereoBP" ){}
- ~CV_GpuStereoBPTest() {}
-
- void 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");
- cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobp/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;
- }
-
- try
- {
- {cv::Mat temp; cv::cvtColor(img_l, temp, CV_BGR2BGRA); cv::swap(temp, img_l);}
- {cv::Mat temp; cv::cvtColor(img_r, temp, CV_BGR2BGRA); cv::swap(temp, img_r);}
-
- cv::gpu::GpuMat disp;
- cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
-
- bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
-
- //cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);
-
- disp.convertTo(disp, img_template.type());
-
- double norm = cv::norm(disp, img_template, cv::NORM_INF);
- if (norm >= 0.5)
- {
- ts->printf(CvTS::LOG, "\nStereoBP norm = %f\n", norm);
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
- return;
- }
- }
- catch(const cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- ts->set_failed_test_info(CvTS::OK);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_GpuStereoBPTest CV_GpuStereoBP_test;
+++ /dev/null
-/*M///////////////////////////////////////////////////////////////////////////////////////
-//
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
-//
-// By downloading, copying, installing or using the software you agree to this license.
-// If you do not agree to this license, do not download, install,
-// copy or use the software.
-//
-//
-// Intel License Agreement
-// For Open Source Computer Vision Library
-//
-// Copyright (C) 2000, Intel Corporation, all rights reserved.
-// Third party copyrights are property of their respective owners.
-//
-// Redistribution and use in source and binary forms, with or without modification,
-// are permitted provided that the following conditions are met:
-//
-// * Redistribution's of source code must retain the above copyright notice,
-// this list of conditions and the following disclaimer.
-//
-// * Redistribution's in binary form must reproduce the above copyright notice,
-// this list of conditions and the following disclaimer in the documentation
-// and/or other materials provided with the distribution.
-//
-// * The name of Intel Corporation may not be used to endorse or promote products
-// derived from this software without specific prior written permission.
-//
-// This software is provided by the copyright holders and contributors "as is" and
-// any express or implied warranties, including, but not limited to, the implied
-// warranties of merchantability and fitness for a particular purpose are disclaimed.
-// In no event shall the Intel Corporation or contributors be liable for any direct,
-// indirect, incidental, special, exemplary, or consequential damages
-// (including, but not limited to, procurement of substitute goods or services;
-// loss of use, data, or profits; or business interruption) however caused
-// and on any theory of liability, whether in contract, strict liability,
-// or tort (including negligence or otherwise) arising in any way out of
-// the use of this software, even if advised of the possibility of such damage.
-//
-//M*/
-
-#include "gputest.hpp"
-#include <iostream>
-#include <string>
-
-struct CV_GpuStereoCSBPTest : public CvTest
-{
- CV_GpuStereoCSBPTest() : CvTest( "GPU-StereoCSBP", "ConstantSpaceStereoBP" ){}
- ~CV_GpuStereoCSBPTest() {}
-
- void 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;
- }
-
- try
- {
- {cv::Mat temp; cv::cvtColor(img_l, temp, CV_BGR2BGRA); cv::swap(temp, img_l);}
- {cv::Mat temp; cv::cvtColor(img_r, temp, CV_BGR2BGRA); cv::swap(temp, img_r);}
-
- cv::gpu::GpuMat disp;
- cv::gpu::StereoConstantSpaceBP bpm(128, 16, 4, 4);
-
- bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);
-
- //cv::imwrite(std::string(ts->get_data_path()) + "csstereobp/aloe-disp.png", disp);
-
- disp.convertTo(disp, img_template.type());
-
- double norm = cv::norm(disp, img_template, cv::NORM_INF);
- if (norm >= 0.5)
- {
- ts->printf(CvTS::LOG, "\nConstantSpaceStereoBP norm = %f\n", norm);
- ts->set_failed_test_info(CvTS::FAIL_GENERIC);
- return;
- }
- }
- catch(const cv::Exception& e)
- {
- if (!check_and_treat_gpu_exception(e, ts))
- throw;
- return;
- }
-
- ts->set_failed_test_info(CvTS::OK);
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////
-/////////////////// tests registration /////////////////////////////////////
-/////////////////////////////////////////////////////////////////////////////
-
-CV_GpuStereoCSBPTest CV_GpuCSStereoBP_test;