--- /dev/null
+set(the_target "opencv_test_${name}") \r
+project(${the_target})\r
+\r
+include_directories("${CMAKE_CURRENT_SOURCE_DIR}/../include"\r
+ "${CMAKE_CURRENT_SOURCE_DIR}/.."\r
+ "${CMAKE_CURRENT_BINARY_DIR}") \r
+\r
+set(test_deps opencv_${name} opencv_ts opencv_highgui ${DEPS})\r
+foreach(d ${test_deps})\r
+ if(${d} MATCHES "opencv_")\r
+ if(${d} MATCHES "opencv_lapack")\r
+ else()\r
+ string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../../" d_dir ${d})\r
+ include_directories("${d_dir}/include")\r
+ endif()\r
+ endif()\r
+endforeach()\r
+\r
+file(GLOB test_srcs "*.cpp")\r
+file(GLOB test_hdrs "*.h*")\r
+\r
+add_executable(${the_target} ${test_srcs} ${test_hdrs})\r
+\r
+if(PCHSupport_FOUND)\r
+ set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/test_precomp.hpp)\r
+ if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*")\r
+ if(${CMAKE_GENERATOR} MATCHES "Visual*")\r
+ set(${the_target}_pch "test_precomp.cpp")\r
+ endif() \r
+ add_native_precompiled_header(${the_target} ${pch_header})\r
+ elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles")\r
+ add_precompiled_header(${the_target} ${pch_header})\r
+ endif()\r
+endif()\r
+\r
+# Additional target properties\r
+set_target_properties(${the_target} PROPERTIES\r
+ DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"\r
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"\r
+ )\r
+\r
+add_dependencies(${the_target} ${test_deps})\r
+\r
+# Add the required libraries for linking:\r
+target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${test_deps})\r
+\r
+enable_testing()\r
+get_target_property(LOC ${the_target} LOCATION)\r
+add_test(${the_target} "${LOC}")\r
+\r
+if(WIN32)\r
+ install(TARGETS ${the_target} RUNTIME DESTINATION bin COMPONENT main)\r
+endif()
\ No newline at end of file
--- /dev/null
+#ifndef __OPENCV_TEST_PRECOMP_HPP__\r
+#define __OPENCV_TEST_PRECOMP_HPP__\r
+\r
+#include "opencv2/ts/ts.hpp"\r
+#include "opencv2/gpu/gpu.hpp"\r
+#include "opencv2/highgui/highgui.hpp"\r
+\r
+static inline bool check_and_treat_gpu_exception(const cv::Exception& e, cvtest::TS* ts)\r
+{\r
+ switch (e.code)\r
+ {\r
+ case CV_GpuNotSupported: \r
+ ts->printf(cvtest::TS::LOG, "\nGpu not supported by the library"); \r
+ break;\r
+\r
+ case CV_GpuApiCallError: \r
+ ts->printf(cvtest::TS::LOG, "\nGPU Error: %s", e.what());\r
+ break;\r
+\r
+ case CV_GpuNppCallError: \r
+ ts->printf(cvtest::TS::LOG, "\nNPP Error: %s", e.what());\r
+ break;\r
+\r
+ default:\r
+ return false;\r
+ }\r
+ ts->set_failed_test_info(cvtest::TS::FAIL_GENERIC); \r
+ return true;\r
+}\r
+\r
+#endif\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 "test_precomp.hpp"\r
+\r
+struct CV_GpuStereoBPTest : public cvtest::BaseTest\r
+{\r
+ void run(int )\r
+ {\r
+ cv::Mat img_l = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-L.png");\r
+ cv::Mat img_r = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-R.png");\r
+ cv::Mat img_template = cv::imread(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", 0);\r
+\r
+ if (img_l.empty() || img_r.empty() || img_template.empty())\r
+ {\r
+ ts->set_failed_test_info(cvtest::TS::FAIL_MISSING_TEST_DATA);\r
+ return;\r
+ }\r
+\r
+ try\r
+ {\r
+ {cv::Mat temp; cv::cvtColor(img_l, temp, CV_BGR2BGRA); cv::swap(temp, img_l);}\r
+ {cv::Mat temp; cv::cvtColor(img_r, temp, CV_BGR2BGRA); cv::swap(temp, img_r);}\r
+\r
+ cv::gpu::GpuMat disp;\r
+ cv::gpu::StereoBeliefPropagation bpm(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);\r
+\r
+ bpm(cv::gpu::GpuMat(img_l), cv::gpu::GpuMat(img_r), disp);\r
+\r
+ //cv::imwrite(std::string(ts->get_data_path()) + "stereobp/aloe-disp.png", disp);\r
+\r
+ disp.convertTo(disp, img_template.type());\r
+\r
+ double norm = cv::norm(disp, img_template, cv::NORM_INF);\r
+ if (norm >= 0.5)\r
+ {\r
+ ts->printf(cvtest::TS::LOG, "\nStereoBP norm = %f\n", norm);\r
+ ts->set_failed_test_info(cvtest::TS::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(cvtest::TS::OK);\r
+ }\r
+};\r
+\r
+TEST(StereoBP, StereoBP) { CV_GpuStereoBPTest test; test.safe_run(); }
\ No newline at end of file