mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-18 08:44:11 +08:00
Merge pull request #3800 from vrabaud:cuda
Get CUDA code to compile with clang CUDA and without CUDA #3800 Changelist: - there are some syntactic changes: `<< <` -> `<<<`. For some reason, I do not need to change all those in the code. - `::min` -> `std::min` in `__host__` code - `modules/cudaimgproc/src/moments.cpp` needs to have the CUDA code in the `#ifdef` - The signature of `cv::cuda::swapChannels` is not exactly the same as the C++ one in `modules/cudaimgproc/src/color.cpp` - `cv::cuda::FarnebackOpticalFlow::create` needs to be explicit about which FarnebackOpticalFlow it returns ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch
This commit is contained in:
@@ -54,6 +54,8 @@ void cv::cuda::mulAndScaleSpectrums(InputArray, InputArray, OutputArray, int, fl
|
||||
|
||||
void cv::cuda::dft(InputArray, OutputArray, Size, int, Stream&) { throw_no_cuda(); }
|
||||
|
||||
Ptr<DFT> cv::cuda::createDFT(Size, int) { throw_no_cuda(); return Ptr<DFT>(); }
|
||||
|
||||
Ptr<Convolution> cv::cuda::createConvolution(Size) { throw_no_cuda(); return Ptr<Convolution>(); }
|
||||
|
||||
#else /* !defined (HAVE_CUDA) */
|
||||
|
@@ -84,8 +84,13 @@ void cv::cuda::magnitude(InputArray, InputArray, OutputArray, Stream&) { throw_n
|
||||
void cv::cuda::magnitudeSqr(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::magnitudeSqr(InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::phase(InputArray, InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::phase(InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::cartToPolar(InputArray, InputArray, OutputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::cartToPolar(InputArray, OutputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::cartToPolar(InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::polarToCart(InputArray, InputArray, OutputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::polarToCart(InputArray, InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::polarToCart(InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
|
||||
#else
|
||||
|
||||
|
@@ -69,8 +69,10 @@ void cv::cuda::countNonZero(InputArray, OutputArray, Stream&) { throw_no_cuda();
|
||||
|
||||
void cv::cuda::reduce(InputArray, OutputArray, int, int, int, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::cuda::meanStdDev(InputArray, Scalar&, Scalar&) { throw_no_cuda(); }
|
||||
void cv::cuda::meanStdDev(InputArray, OutputArray, InputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::meanStdDev(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::meanStdDev(InputArray, Scalar&, Scalar&, InputArray) { throw_no_cuda(); }
|
||||
void cv::cuda::meanStdDev(InputArray, Scalar&, Scalar&) { throw_no_cuda(); }
|
||||
|
||||
void cv::cuda::rectStdDev(InputArray, InputArray, OutputArray, Rect, Stream&) { throw_no_cuda(); }
|
||||
|
||||
|
@@ -51,7 +51,7 @@ void cv::cuda::cvtColor(InputArray, OutputArray, int, int, Stream&) { throw_no_c
|
||||
|
||||
void cv::cuda::demosaicing(InputArray, OutputArray, int, int, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::cuda::swapChannels(InputOutputArray, const int[], Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::swapChannels(InputOutputArray, const int[4], Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::cuda::gammaCorrection(InputArray, OutputArray, bool, Stream&) { throw_no_cuda(); }
|
||||
|
||||
|
@@ -9,8 +9,8 @@ using namespace cv::cuda;
|
||||
|
||||
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
|
||||
|
||||
void cv::cuda::connectedComponents(InputArray img_, OutputArray labels_, int connectivity,
|
||||
int ltype, ConnectedComponentsAlgorithmsTypes ccltype) { throw_no_cuda(); }
|
||||
void cv::cuda::connectedComponents(InputArray, OutputArray, int, int, ConnectedComponentsAlgorithmsTypes) { throw_no_cuda(); }
|
||||
void cv::cuda::connectedComponents(InputArray, OutputArray, int, int) { throw_no_cuda(); }
|
||||
|
||||
#else /* !defined (HAVE_CUDA) */
|
||||
|
||||
|
@@ -428,7 +428,7 @@ namespace canny
|
||||
cudaSafeCall( cudaMemsetAsync(d_counter, 0, sizeof(int), stream) );
|
||||
|
||||
const dim3 block(128);
|
||||
const dim3 grid(::min(count, 65535u), divUp(count, 65535), 1);
|
||||
const dim3 grid(std::min(count, 65535), divUp(count, 65535), 1);
|
||||
|
||||
edgesHysteresisGlobalKernel<<<grid, block, 0, stream>>>(map, st1, st2, d_counter, count);
|
||||
cudaSafeCall( cudaGetLastError() );
|
||||
@@ -439,7 +439,7 @@ namespace canny
|
||||
cudaSafeCall( cudaMemcpyAsync(&count, d_counter, sizeof(int), cudaMemcpyDeviceToHost, stream) );
|
||||
cudaSafeCall( cudaStreamSynchronize(stream) );
|
||||
|
||||
count = min(count, map.cols * map.rows);
|
||||
count = std::min(count, map.cols * map.rows);
|
||||
|
||||
//std::swap(st1, st2);
|
||||
short2* tmp = st1;
|
||||
|
@@ -302,7 +302,7 @@ namespace cv { namespace cuda { namespace device
|
||||
int totalCount;
|
||||
cudaSafeCall( cudaMemcpy(&totalCount, counterPtr, sizeof(int), cudaMemcpyDeviceToHost) );
|
||||
|
||||
totalCount = ::min(totalCount, maxSize);
|
||||
totalCount = std::min(totalCount, maxSize);
|
||||
|
||||
return totalCount;
|
||||
}
|
||||
@@ -812,7 +812,7 @@ namespace cv { namespace cuda { namespace device
|
||||
int totalCount;
|
||||
cudaSafeCall( cudaMemcpy(&totalCount, counterPtr, sizeof(int), cudaMemcpyDeviceToHost) );
|
||||
|
||||
totalCount = ::min(totalCount, maxSize);
|
||||
totalCount = std::min(totalCount, maxSize);
|
||||
|
||||
return totalCount;
|
||||
}
|
||||
|
@@ -238,7 +238,7 @@ namespace cv { namespace cuda { namespace device
|
||||
cudaSafeCall( cudaMemcpyAsync(&totalCount, counterPtr, sizeof(int), cudaMemcpyDeviceToHost, stream) );
|
||||
cudaSafeCall( cudaStreamSynchronize(stream) );
|
||||
|
||||
totalCount = ::min(totalCount, maxCircles);
|
||||
totalCount = std::min(totalCount, maxCircles);
|
||||
|
||||
return totalCount;
|
||||
}
|
||||
|
@@ -189,7 +189,7 @@ namespace cv { namespace cuda { namespace device
|
||||
|
||||
cudaSafeCall( cudaStreamSynchronize(stream) );
|
||||
|
||||
totalCount = ::min(totalCount, maxSize);
|
||||
totalCount = std::min(totalCount, maxSize);
|
||||
|
||||
if (doSort && totalCount > 0)
|
||||
{
|
||||
|
@@ -241,7 +241,7 @@ namespace cv { namespace cuda { namespace device
|
||||
|
||||
cudaSafeCall( cudaStreamSynchronize(stream) );
|
||||
|
||||
totalCount = ::min(totalCount, maxSize);
|
||||
totalCount = std::min(totalCount, maxSize);
|
||||
return totalCount;
|
||||
}
|
||||
}
|
||||
|
@@ -48,6 +48,7 @@ using namespace cv::cuda;
|
||||
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
|
||||
|
||||
void cv::cuda::calcHist(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
void cv::cuda::calcHist(InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
|
||||
void cv::cuda::equalizeHist(InputArray, OutputArray, Stream&) { throw_no_cuda(); }
|
||||
|
||||
|
@@ -3,15 +3,10 @@
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "cuda/moments.cuh"
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::cuda;
|
||||
|
||||
int cv::cuda::numMoments(const MomentsOrder order) {
|
||||
return order == MomentsOrder::FIRST_ORDER_MOMENTS ? device::imgproc::n1 : order == MomentsOrder::SECOND_ORDER_MOMENTS ? device::imgproc::n12 : device::imgproc::n123;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
cv::Moments convertSpatialMomentsT(Mat spatialMoments, const MomentsOrder order) {
|
||||
switch (order) {
|
||||
@@ -32,10 +27,17 @@ cv::Moments cv::cuda::convertSpatialMoments(Mat spatialMoments, const MomentsOrd
|
||||
}
|
||||
|
||||
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
|
||||
int cv::cuda::numMoments(MomentsOrder) { throw_no_cuda(); return 0; }
|
||||
Moments cv::cuda::moments(InputArray src, const bool binary, const MomentsOrder order, const int momentsType) { throw_no_cuda(); }
|
||||
void spatialMoments(InputArray src, OutputArray moments, const bool binary, const MomentsOrder order, const int momentsType, Stream& stream) { throw_no_cuda(); }
|
||||
void cv::cuda::spatialMoments(InputArray src, OutputArray moments, const bool binary, const MomentsOrder order, const int momentsType, Stream& stream) { throw_no_cuda(); }
|
||||
#else /* !defined (HAVE_CUDA) */
|
||||
|
||||
#include "cuda/moments.cuh"
|
||||
|
||||
int cv::cuda::numMoments(const MomentsOrder order) {
|
||||
return order == MomentsOrder::FIRST_ORDER_MOMENTS ? device::imgproc::n1 : order == MomentsOrder::SECOND_ORDER_MOMENTS ? device::imgproc::n12 : device::imgproc::n123;
|
||||
}
|
||||
|
||||
namespace cv { namespace cuda { namespace device { namespace imgproc {
|
||||
template <typename TSrc, typename TMoments>
|
||||
void moments(const PtrStepSzb src, PtrStepSzb moments, const bool binary, const int order, const int offsetX, const cudaStream_t stream);
|
||||
|
@@ -47,7 +47,7 @@ using namespace cv::cuda;
|
||||
|
||||
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|
||||
|
||||
Ptr<FarnebackOpticalFlow> cv::cuda::FarnebackOpticalFlow::create(int, double, bool, int, int, int, double, int) { throw_no_cuda(); return Ptr<FarnebackOpticalFlow>(); }
|
||||
Ptr<cv::cuda::FarnebackOpticalFlow> cv::cuda::FarnebackOpticalFlow::create(int, double, bool, int, int, int, double, int) { throw_no_cuda(); return Ptr<FarnebackOpticalFlow>(); }
|
||||
|
||||
#else
|
||||
|
||||
|
@@ -52,7 +52,9 @@
|
||||
#include "opencv2/video.hpp"
|
||||
|
||||
#include "opencv2/core/private.cuda.hpp"
|
||||
#if defined HAVE_CUDA
|
||||
#include "opencv2/core/cuda/vec_traits.hpp"
|
||||
#endif
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_CUDALEGACY
|
||||
|
@@ -148,8 +148,8 @@ namespace grid_minmaxloc_detail
|
||||
block = dim3(Policy::block_size_x, Policy::block_size_y);
|
||||
grid = dim3(divUp(cols, block.x * Policy::patch_size_x), divUp(rows, block.y * Policy::patch_size_y));
|
||||
|
||||
grid.x = ::min(grid.x, block.x);
|
||||
grid.y = ::min(grid.y, block.y);
|
||||
grid.x = std::min(grid.x, block.x);
|
||||
grid.y = std::min(grid.y, block.y);
|
||||
}
|
||||
|
||||
template <class Policy, class SrcPtr, typename ResType, class MaskPtr>
|
||||
|
Reference in New Issue
Block a user