mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
added the module for testing gpu, by default turned off
This commit is contained in:
parent
ace7c7e93c
commit
c3f1a6e78a
@ -4,3 +4,10 @@ add_subdirectory(cv)
|
||||
add_subdirectory(cxcore)
|
||||
add_subdirectory(ml)
|
||||
add_subdirectory(cxts)
|
||||
|
||||
set (BUILD_TESTS_GPU OFF CACHE BOOL "Build tests GPU")
|
||||
|
||||
if(BUILD_TESTS_GPU AND WITH_CUDA)
|
||||
add_subdirectory(gpu)
|
||||
endif()
|
||||
|
||||
|
51
tests/gpu/CMakeLists.txt
Normal file
51
tests/gpu/CMakeLists.txt
Normal file
@ -0,0 +1,51 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for gputest. See root CMakeLists.txt
|
||||
# ----------------------------------------------------------------------------
|
||||
project(opencv_test_gpu)
|
||||
|
||||
file(GLOB test_srcs "src/*.cpp")
|
||||
source_group("Src" FILES ${test_srcs})
|
||||
file(GLOB test_hdrs "src/*.h*")
|
||||
source_group("Include" FILES ${test_hdrs})
|
||||
|
||||
set(the_target "opencv_test_gpu")
|
||||
|
||||
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/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_CURRENT_SOURCE_DIR}/src"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
include_directories(../cxts)
|
||||
|
||||
add_executable(${the_target} ${test_srcs} ${test_hdrs})
|
||||
|
||||
# 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)
|
||||
|
||||
# Add the required libraries for linking:
|
||||
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_ts opencv_gpu)
|
||||
|
||||
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()
|
||||
|
51
tests/gpu/src/gputest.cpp
Normal file
51
tests/gpu/src/gputest.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/*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;
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
return test_system.run( argc, argv );
|
||||
}
|
||||
|
||||
/* End of file. */
|
67
tests/gpu/src/gputest.hpp
Normal file
67
tests/gpu/src/gputest.hpp
Normal file
@ -0,0 +1,67 @@
|
||||
/*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 _CXCORE_TEST_H_
|
||||
#define _CXCORE_TEST_H_
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
#include <windows.h>
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#include "opencv2/gpu/gpu.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
|
||||
|
||||
#endif /* _CXCORE_TEST_H_ */
|
||||
|
||||
/* End of file. */
|
70
tests/gpu/src/operator_set_to.cpp
Normal file
70
tests/gpu/src/operator_set_to.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
#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_GpuMatOpSetTo : public CvTest
|
||||
{
|
||||
public:
|
||||
CV_GpuMatOpSetTo();
|
||||
~CV_GpuMatOpSetTo();
|
||||
protected:
|
||||
void print_mat(cv::Mat & mat);
|
||||
void run(int);
|
||||
};
|
||||
|
||||
CV_GpuMatOpSetTo::CV_GpuMatOpSetTo(): CvTest( "GpuMatOperatorSetTo", "setTo" ) {}
|
||||
CV_GpuMatOpSetTo::~CV_GpuMatOpSetTo() {}
|
||||
|
||||
void CV_GpuMatOpSetTo::print_mat(cv::Mat & mat)
|
||||
{
|
||||
for (size_t j = 0; j < mat.rows; j++)
|
||||
{
|
||||
for (size_t i = 0; i < mat.cols; i++)
|
||||
{
|
||||
std::cout << " " << int(mat.ptr<unsigned char>(j)[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void CV_GpuMatOpSetTo::run( int /* start_from */)
|
||||
{
|
||||
Mat cpumat(1024, 1024, CV_8U, Scalar::all(0));
|
||||
GpuMat gpumat(cpumat);
|
||||
|
||||
Scalar s(3);
|
||||
|
||||
cpumat.setTo(s);
|
||||
gpumat.setTo(s);
|
||||
|
||||
double ret = norm(cpumat, gpumat);
|
||||
|
||||
/*
|
||||
std::cout << "norm() = " << ret << "\n";
|
||||
|
||||
std::cout << "cpumat: \n";
|
||||
print_mat(cpumat);
|
||||
|
||||
Mat newmat;
|
||||
gpumat.download(newmat);
|
||||
|
||||
std::cout << "gpumat: \n";
|
||||
print_mat(newmat);
|
||||
*/
|
||||
|
||||
if (ret < 1.0)
|
||||
ts->set_failed_test_info(CvTS::OK);
|
||||
else
|
||||
ts->set_failed_test_info(CvTS::FAIL_GENERIC);
|
||||
}
|
||||
|
||||
CV_GpuMatOpSetTo CV_GpuMatOpSetTo_test;
|
Loading…
Reference in New Issue
Block a user