Commit 2c8af20b authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

removed obsolete tests

parent 8be541ee
# ----------------------------------------------------------------------------
# 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()
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*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>
using namespace cv;
using namespace cv::gpu;
using namespace std;
const string FEATURES2D_DIR = "features2d";
const string IMAGE_FILENAME = "aloe.png";
const string VALID_FILE_NAME = "surf.xml.gz";
class CV_GPU_SURFTest : public CvTest
{
public:
CV_GPU_SURFTest() :
CvTest( "GPU-SURF", "SURF_GPU")
{
}
protected:
bool isSimilarKeypoints(const KeyPoint& p1, const KeyPoint& p2);
void compareKeypointSets(const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints,
const Mat& validDescriptors, const Mat& calcDescriptors);
void emptyDataTest(SURF_GPU& fdetector);
void regressionTest(SURF_GPU& fdetector);
virtual void run(int);
};
void CV_GPU_SURFTest::emptyDataTest(SURF_GPU& fdetector)
{
GpuMat image;
vector<KeyPoint> keypoints;
vector<float> descriptors;
try
{
fdetector(image, GpuMat(), keypoints, descriptors);
}
catch(...)
{
ts->printf( CvTS::LOG, "detect() on empty image must not generate exception (1).\n" );
ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );
}
if( !keypoints.empty() )
{
ts->printf( CvTS::LOG, "detect() on empty image must return empty keypoints vector (1).\n" );
ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );
return;
}
if( !descriptors.empty() )
{
ts->printf( CvTS::LOG, "detect() on empty image must return empty descriptors vector (1).\n" );
ts->set_failed_test_info( CvTS::FAIL_INVALID_OUTPUT );
return;
}
}
bool CV_GPU_SURFTest::isSimilarKeypoints(const KeyPoint& p1, const KeyPoint& p2)
{
const float maxPtDif = 1.f;
const float maxSizeDif = 1.f;
const float maxAngleDif = 2.f;
const float maxResponseDif = 0.1f;
float dist = (float)norm( p1.pt - p2.pt );
return (dist < maxPtDif &&
fabs(p1.size - p2.size) < maxSizeDif &&
abs(p1.angle - p2.angle) < maxAngleDif &&
abs(p1.response - p2.response) < maxResponseDif &&
p1.octave == p2.octave &&
p1.class_id == p2.class_id );
}
void CV_GPU_SURFTest::compareKeypointSets(const vector<KeyPoint>& validKeypoints, const vector<KeyPoint>& calcKeypoints,
const Mat& validDescriptors, const Mat& calcDescriptors)
{
if (validKeypoints.size() != calcKeypoints.size())
{
ts->printf(CvTS::LOG, "Keypoints sizes doesn't equal (validCount = %d, calcCount = %d).\n",
validKeypoints.size(), calcKeypoints.size());
ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
return;
}
if (validDescriptors.size() != calcDescriptors.size())
{
ts->printf(CvTS::LOG, "Descriptors sizes doesn't equal.\n");
ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);
return;
}
for (size_t v = 0; v < validKeypoints.size(); v++)
{
int nearestIdx = -1;
float minDist = std::numeric_limits<float>::max();
for (size_t c = 0; c < calcKeypoints.size(); c++)
{
float curDist = (float)norm(calcKeypoints[c].pt - validKeypoints[v].pt);
if (curDist < minDist)
{
minDist = curDist;
nearestIdx = c;
}
}
assert(minDist >= 0);
if (!isSimilarKeypoints(validKeypoints[v], calcKeypoints[nearestIdx]))
{
ts->printf(CvTS::LOG, "Bad keypoints accuracy.\n");
ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );
return;
}
if (norm(validDescriptors.row(v), calcDescriptors.row(nearestIdx), NORM_L2) > 1.5f)
{
ts->printf(CvTS::LOG, "Bad descriptors accuracy.\n");
ts->set_failed_test_info( CvTS::FAIL_BAD_ACCURACY );
return;
}
}
}
void CV_GPU_SURFTest::regressionTest(SURF_GPU& fdetector)
{
string imgFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + IMAGE_FILENAME;
string resFilename = string(ts->get_data_path()) + FEATURES2D_DIR + "/" + VALID_FILE_NAME;
// Read the test image.
GpuMat image(imread(imgFilename, 0));
if (image.empty())
{
ts->printf( CvTS::LOG, "Image %s can not be read.\n", imgFilename.c_str() );
ts->set_failed_test_info( CvTS::FAIL_INVALID_TEST_DATA );
return;
}
FileStorage fs(resFilename, FileStorage::READ);
// Compute keypoints.
GpuMat mask(image.size(), CV_8UC1, Scalar::all(1));
mask(Range(0, image.rows / 2), Range(0, image.cols / 2)).setTo(Scalar::all(0));
vector<KeyPoint> calcKeypoints;
GpuMat calcDespcriptors;
fdetector(image, mask, calcKeypoints, calcDespcriptors);
if (fs.isOpened()) // Compare computed and valid keypoints.
{
// Read validation keypoints set.
vector<KeyPoint> validKeypoints;
Mat validDespcriptors;
read(fs["keypoints"], validKeypoints);
read(fs["descriptors"], validDespcriptors);
if (validKeypoints.empty() || validDespcriptors.empty())
{
ts->printf(CvTS::LOG, "Validation file can not be read.\n");
ts->set_failed_test_info(CvTS::FAIL_INVALID_TEST_DATA);
return;
}
compareKeypointSets(validKeypoints, calcKeypoints, validDespcriptors, calcDespcriptors);
}
else // Write detector parameters and computed keypoints as validation data.
{
fs.open(resFilename, FileStorage::WRITE);
if (!fs.isOpened())
{
ts->printf(CvTS::LOG, "File %s can not be opened to write.\n", resFilename.c_str());
ts->set_failed_test_info(CvTS::FAIL_INVALID_TEST_DATA);
return;
}
else
{
write(fs, "keypoints", calcKeypoints);
write(fs, "descriptors", (Mat)calcDespcriptors);
}
}
}
void CV_GPU_SURFTest::run( int /*start_from*/ )
{
try
{
SURF_GPU fdetector;
emptyDataTest(fdetector);
regressionTest(fdetector);
}
catch(cv::Exception& e)
{
if (!check_and_treat_gpu_exception(e, ts))
throw;
return;
}
}
CV_GPU_SURFTest CV_GPU_SURF_test;
This diff is collapsed.
/*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*/
#ifndef _GPU_TEST_H_
#define _GPU_TEST_H_
#if defined WIN32 || defined _WIN32
#include <windows.h>
#undef min
#undef max
#endif
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include "cxts.h"
/****************************************************************************************/
/* Warnings Disabling */
/****************************************************************************************/
#if _MSC_VER > 1000
#pragma warning(disable : 4514) /* unreferenced inline function has been */
/* removed */
#pragma warning(disable : 4127) /* conditional expression is constant */
/* for no warnings in _ASSERT */
#pragma warning(disable : 4996) /* deprecated function */
#endif
static inline bool check_and_treat_gpu_exception(const cv::Exception& e, CvTS* ts)
{
switch (e.code)
{
case CV_GpuNotSupported:
ts->printf(CvTS::LOG, "\nGpu not supported by the library");
break;
case CV_GpuApiCallError:
ts->printf(CvTS::LOG, "\nGPU Error: %s", e.what());
break;
case CV_GpuNppCallError:
ts->printf(CvTS::LOG, "\nNPP Error: %s", e.what());
break;
default:
return false;
}
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
return true;
}
#endif
/* End of file. */
/*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. */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*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 <iostream>
#include <string>
#include <iosfwd>
#include "gputest.hpp"
using namespace cv;
using namespace cv::gpu;
using namespace std;
struct CV_GpuMeanShiftSegmentationTest : public CvTest {
CV_GpuMeanShiftSegmentationTest() : CvTest( "GPU-MeanShiftSegmentation", "MeanShiftSegmentation" ) {}
void run(int)
{
try
{
bool cc12_ok = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);
if (!cc12_ok)
{
ts->printf(CvTS::CONSOLE, "\nCompute capability 1.2 is required");
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
return;
}
Mat img_rgb = imread(string(ts->get_data_path()) + "meanshift/cones.png");
if (img_rgb.empty())
{
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
return;
}
Mat img;
cvtColor(img_rgb, img, CV_BGR2BGRA);
for (int minsize = 0; minsize < 2000; minsize = (minsize + 1) * 4)
{
stringstream path;
path << ts->get_data_path() << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;
if (TargetArchs::builtWith(FEATURE_SET_COMPUTE_20) && DeviceInfo().supports(FEATURE_SET_COMPUTE_20))
path << ".png";
else
path << "_CC1X.png";
Mat dst;
meanShiftSegmentation((GpuMat)img, dst, 10, 10, minsize);
Mat dst_rgb;
cvtColor(dst, dst_rgb, CV_BGRA2BGR);
//imwrite(path.str(), dst_rgb);
Mat dst_ref = imread(path.str());
if (dst_ref.empty())
{
ts->set_failed_test_info(CvTS::FAIL_MISSING_TEST_DATA);
return;
}
if (CheckSimilarity(dst_rgb, dst_ref, 1e-3f) != CvTS::OK)
{
ts->printf(CvTS::LOG, "\ndiffers from image *minsize%d.png\n", minsize);
ts->set_failed_test_info(CvTS::FAIL_BAD_ACCURACY);
}
}
}
catch (const cv::Exception& e)
{
if (!check_and_treat_gpu_exception(e, ts))
throw;
return;
}
ts->set_failed_test_info(CvTS::OK);
}
int CheckSimilarity(const Mat& m1, const Mat& m2, float max_err)
{
Mat diff;
cv::matchTemplate(m1, m2, diff, CV_TM_CCORR_NORMED);
float err = abs(diff.at<float>(0, 0) - 1.f);
if (err > max_err)
return CvTS::FAIL_INVALID_OUTPUT;
return CvTS::OK;
}
} ms_segm_test;
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual
* property and proprietary rights in and to this software and
* related documentation and any modifications thereto.
* Any use, reproduction, disclosure, or distribution of this
* software and related documentation without an express license
* agreement from NVIDIA Corporation is strictly prohibited.
*/
#ifndef _testhypothesescompact_h_
#define _testhypothesescompact_h_
#include "NCVTest.hpp"
#include "NCVTestSourceProvider.hpp"
class TestCompact : public NCVTestProvider
{
public:
TestCompact(std::string testName, NCVTestSourceProvider<Ncv32u> &src,
Ncv32u length, Ncv32u badElem, Ncv32u badElemPercentage);
virtual bool init();
virtual bool process();
virtual bool deinit();
virtual bool toString(std::ofstream &strOut);
private:
TestCompact(const TestCompact&);
TestCompact& operator=(const TestCompact&);
NCVTestSourceProvider<Ncv32u> &src;
Ncv32u length;
Ncv32u badElem;
Ncv32u badElemPercentage;
};
#endif // _testhypothesescompact_h_
This diff is collapsed.
/*
* Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual
* property and proprietary rights in and to this software and
* related documentation and any modifications thereto.
* Any use, reproduction, disclosure, or distribution of this
* software and related documentation without an express license
* agreement from NVIDIA Corporation is strictly prohibited.
*/
#ifndef _testdrawrects_h_
#define _testdrawrects_h_
#include "NCVTest.hpp"
#include "NCVTestSourceProvider.hpp"
template <class T>
class TestDrawRects : public NCVTestProvider
{
public:
TestDrawRects(std::string testName, NCVTestSourceProvider<T> &src, NCVTestSourceProvider<Ncv32u> &src32u,
Ncv32u width, Ncv32u height, Ncv32u numRects, T color);
virtual bool init();
virtual bool process();
virtual bool deinit();
virtual bool toString(std::ofstream &strOut);
private:
TestDrawRects(const TestDrawRects&);
TestDrawRects& operator=(const TestDrawRects&);
NCVTestSourceProvider<T> &src;
NCVTestSourceProvider<Ncv32u> &src32u;
Ncv32u width;
Ncv32u height;
Ncv32u numRects;
T color;
};
#endif // _testdrawrects_h_
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment