From ce0e595a4f6b674d0d7898e80bba28e81f5f009b Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 15 Jan 2015 16:09:53 +0300 Subject: [PATCH] move the rest cuda functions to cuda legacy --- modules/cuda/include/opencv2/cuda.hpp | 28 ---------------- modules/cudalegacy/CMakeLists.txt | 3 +- .../cudalegacy/include/opencv2/cudalegacy.hpp | 32 +++++++++++++++++++ .../perf/perf_calib3d.cpp | 6 ++++ modules/{cuda => cudalegacy}/src/calib3d.cpp | 2 +- .../{cuda => cudalegacy}/src/cuda/calib3d.cu | 0 modules/cudalegacy/src/precomp.hpp | 4 +++ .../test/test_calib3d.cpp | 4 ++- modules/cudalegacy/test/test_precomp.hpp | 2 ++ samples/gpu/performance/tests.cpp | 2 +- 10 files changed, 51 insertions(+), 32 deletions(-) rename modules/{cuda => cudalegacy}/perf/perf_calib3d.cpp (98%) rename modules/{cuda => cudalegacy}/src/calib3d.cpp (99%) rename modules/{cuda => cudalegacy}/src/cuda/calib3d.cu (100%) rename modules/{cuda => cudalegacy}/test/test_calib3d.cpp (98%) diff --git a/modules/cuda/include/opencv2/cuda.hpp b/modules/cuda/include/opencv2/cuda.hpp index 1a5d17d46..40483f485 100644 --- a/modules/cuda/include/opencv2/cuda.hpp +++ b/modules/cuda/include/opencv2/cuda.hpp @@ -63,34 +63,6 @@ namespace cv { namespace cuda { //! @addtogroup cuda_calib3d //! @{ -CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, - GpuMat& dst, Stream& stream = Stream::Null()); - -CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, - const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, - Stream& stream = Stream::Null()); - -/** @brief Finds the object pose from 3D-2D point correspondences. - -@param object Single-row matrix of object points. -@param image Single-row matrix of image points. -@param camera_mat 3x3 matrix of intrinsic camera parameters. -@param dist_coef Distortion coefficients. See undistortPoints for details. -@param rvec Output 3D rotation vector. -@param tvec Output 3D translation vector. -@param use_extrinsic_guess Flag to indicate that the function must use rvec and tvec as an -initial transformation guess. It is not supported for now. -@param num_iters Maximum number of RANSAC iterations. -@param max_dist Euclidean distance threshold to detect whether point is inlier or not. -@param min_inlier_count Flag to indicate that the function must stop if greater or equal number -of inliers is achieved. It is not supported for now. -@param inliers Output vector of inlier indices. - */ -CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat, - const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false, - int num_iters=100, float max_dist=8.0, int min_inlier_count=100, - std::vector* inliers=NULL); - //! @} }} // namespace cv { namespace cuda { diff --git a/modules/cudalegacy/CMakeLists.txt b/modules/cudalegacy/CMakeLists.txt index 0ef6e359b..7fe342e11 100644 --- a/modules/cudalegacy/CMakeLists.txt +++ b/modules/cudalegacy/CMakeLists.txt @@ -6,4 +6,5 @@ set(the_description "CUDA-accelerated Computer Vision (legacy)") ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4130 /wd4324 /wd4512 /wd4310 -Wundef -Wmissing-declarations -Wuninitialized -Wshadow) -ocv_define_module(cudalegacy opencv_core opencv_video OPTIONAL opencv_objdetect opencv_imgproc opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc) +ocv_define_module(cudalegacy opencv_core opencv_video + OPTIONAL opencv_objdetect opencv_imgproc opencv_calib3d opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc) diff --git a/modules/cudalegacy/include/opencv2/cudalegacy.hpp b/modules/cudalegacy/include/opencv2/cudalegacy.hpp index 18f55eba7..c27a1161f 100644 --- a/modules/cudalegacy/include/opencv2/cudalegacy.hpp +++ b/modules/cudalegacy/include/opencv2/cudalegacy.hpp @@ -251,6 +251,38 @@ CV_EXPORTS void connectivityMask(const GpuMat& image, GpuMat& mask, const cv::Sc //! performs connected componnents labeling. CV_EXPORTS void labelComponents(const GpuMat& mask, GpuMat& components, int flags = 0, Stream& stream = Stream::Null()); +// +// Calib3d +// + +CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, + GpuMat& dst, Stream& stream = Stream::Null()); + +CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, + const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, + Stream& stream = Stream::Null()); + +/** @brief Finds the object pose from 3D-2D point correspondences. + +@param object Single-row matrix of object points. +@param image Single-row matrix of image points. +@param camera_mat 3x3 matrix of intrinsic camera parameters. +@param dist_coef Distortion coefficients. See undistortPoints for details. +@param rvec Output 3D rotation vector. +@param tvec Output 3D translation vector. +@param use_extrinsic_guess Flag to indicate that the function must use rvec and tvec as an +initial transformation guess. It is not supported for now. +@param num_iters Maximum number of RANSAC iterations. +@param max_dist Euclidean distance threshold to detect whether point is inlier or not. +@param min_inlier_count Flag to indicate that the function must stop if greater or equal number +of inliers is achieved. It is not supported for now. +@param inliers Output vector of inlier indices. + */ +CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat, + const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false, + int num_iters=100, float max_dist=8.0, int min_inlier_count=100, + std::vector* inliers=NULL); + //! @} }} diff --git a/modules/cuda/perf/perf_calib3d.cpp b/modules/cudalegacy/perf/perf_calib3d.cpp similarity index 98% rename from modules/cuda/perf/perf_calib3d.cpp rename to modules/cudalegacy/perf/perf_calib3d.cpp index 4148b5191..0e708ce4f 100644 --- a/modules/cuda/perf/perf_calib3d.cpp +++ b/modules/cudalegacy/perf/perf_calib3d.cpp @@ -42,6 +42,10 @@ #include "perf_precomp.hpp" +#ifdef HAVE_OPENCV_CALIB3D + +#include "opencv2/calib3d.hpp" + using namespace std; using namespace testing; using namespace perf; @@ -133,3 +137,5 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, CPU_SANITY_CHECK(tvec, 1e-6); } } + +#endif diff --git a/modules/cuda/src/calib3d.cpp b/modules/cudalegacy/src/calib3d.cpp similarity index 99% rename from modules/cuda/src/calib3d.cpp rename to modules/cudalegacy/src/calib3d.cpp index eaadb9343..7d8c816fa 100644 --- a/modules/cuda/src/calib3d.cpp +++ b/modules/cudalegacy/src/calib3d.cpp @@ -45,7 +45,7 @@ using namespace cv; using namespace cv::cuda; -#if !defined HAVE_CUDA || defined(CUDA_DISABLER) +#if !defined HAVE_CUDA || !defined HAVE_OPENCV_CALIB3D || defined(CUDA_DISABLER) void cv::cuda::transformPoints(const GpuMat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_no_cuda(); } diff --git a/modules/cuda/src/cuda/calib3d.cu b/modules/cudalegacy/src/cuda/calib3d.cu similarity index 100% rename from modules/cuda/src/cuda/calib3d.cu rename to modules/cudalegacy/src/cuda/calib3d.cu diff --git a/modules/cudalegacy/src/precomp.hpp b/modules/cudalegacy/src/precomp.hpp index a15e9f03c..9eda7e01d 100644 --- a/modules/cudalegacy/src/precomp.hpp +++ b/modules/cudalegacy/src/precomp.hpp @@ -56,6 +56,10 @@ # include "opencv2/objdetect.hpp" #endif +#ifdef HAVE_OPENCV_CALIB3D +# include "opencv2/calib3d.hpp" +#endif + #ifdef HAVE_OPENCV_CUDAARITHM # include "opencv2/cudaarithm.hpp" #endif diff --git a/modules/cuda/test/test_calib3d.cpp b/modules/cudalegacy/test/test_calib3d.cpp similarity index 98% rename from modules/cuda/test/test_calib3d.cpp rename to modules/cudalegacy/test/test_calib3d.cpp index 7208b10ba..7a73f817e 100644 --- a/modules/cuda/test/test_calib3d.cpp +++ b/modules/cudalegacy/test/test_calib3d.cpp @@ -42,7 +42,9 @@ #include "test_precomp.hpp" -#ifdef HAVE_CUDA +#if defined HAVE_CUDA && defined HAVE_OPENCV_CALIB3D + +#include "opencv2/calib3d.hpp" using namespace cvtest; diff --git a/modules/cudalegacy/test/test_precomp.hpp b/modules/cudalegacy/test/test_precomp.hpp index 5169ef2bb..727b40d83 100644 --- a/modules/cudalegacy/test/test_precomp.hpp +++ b/modules/cudalegacy/test/test_precomp.hpp @@ -74,6 +74,8 @@ #include "opencv2/core/private.cuda.hpp" +#include "opencv2/opencv_modules.hpp" + #include "cvconfig.h" #include "NCVTest.hpp" diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index 9e8bfd28c..b4bf4cfbe 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -3,7 +3,7 @@ #include "opencv2/highgui.hpp" #include "opencv2/calib3d.hpp" #include "opencv2/video.hpp" -#include "opencv2/cuda.hpp" +#include "opencv2/cudalegacy.hpp" #include "opencv2/cudaimgproc.hpp" #include "opencv2/cudaarithm.hpp" #include "opencv2/cudawarping.hpp"