Skip to content

Commit 22ee5c0

Browse files
author
Rob Timpe
committed
Fix errors when building with cuda stubs
Fixes two errors when building with the options WITH_CUDA=ON and BUILD_CUDA_STUBS=ON on a machine without CUDA. In the cudaarithm module, make sure cuda_runtime.h only gets included when CUDA is installed. In the stitching module, don't assume that cuda is present just because cudaarithm and cudawarping are present (as is the case when building with the above options).
1 parent 7f3d8de commit 22ee5c0

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

modules/cudaarithm/src/lut.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
#include "precomp.hpp"
66

7-
#include "lut.hpp"
8-
97
using namespace cv;
108
using namespace cv::cuda;
119

@@ -15,6 +13,9 @@ Ptr<LookUpTable> cv::cuda::createLookUpTable(InputArray) { throw_no_cuda(); retu
1513

1614
#else /* !defined (HAVE_CUDA) || defined (CUDA_DISABLER) */
1715

16+
// lut.hpp includes cuda_runtime.h and can only be included when we have CUDA
17+
#include "lut.hpp"
18+
1819
Ptr<LookUpTable> cv::cuda::createLookUpTable(InputArray lut)
1920
{
2021
return makePtr<LookUpTableImpl>(lut);

modules/stitching/src/blenders.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type)
219219
num_bands_ = 0;
220220
setNumBands(num_bands);
221221

222-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
222+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
223223
can_use_gpu_ = try_gpu && cuda::getCudaEnabledDeviceCount();
224224
gpu_feed_idx_ = 0;
225225
#else
@@ -246,7 +246,7 @@ void MultiBandBlender::prepare(Rect dst_roi)
246246

247247
Blender::prepare(dst_roi);
248248

249-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
249+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
250250
if (can_use_gpu_)
251251
{
252252
gpu_initialized_ = false;
@@ -332,7 +332,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
332332

333333
UMat img;
334334

335-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
335+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
336336
// If using gpu save the top left coordinate when running first time after prepare
337337
if (can_use_gpu_)
338338
{
@@ -353,7 +353,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
353353
{
354354
img = _img.getUMat();
355355
}
356-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
356+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
357357
else
358358
{
359359
gpu_img_ = _img.getGpuMat();
@@ -394,7 +394,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
394394
int bottom = br_new.y - tl.y - img.rows;
395395
int right = br_new.x - tl.x - img.cols;
396396

397-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
397+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
398398
if (can_use_gpu_)
399399
{
400400
if (!gpu_initialized_)
@@ -603,7 +603,7 @@ void MultiBandBlender::feed(InputArray _img, InputArray mask, Point tl)
603603
void MultiBandBlender::blend(InputOutputArray dst, InputOutputArray dst_mask)
604604
{
605605
Rect dst_rc(0, 0, dst_roi_final_.width, dst_roi_final_.height);
606-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
606+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
607607
if (can_use_gpu_)
608608
{
609609
if (!gpu_initialized_)
@@ -850,7 +850,7 @@ void createLaplacePyr(InputArray img, int num_levels, std::vector<UMat> &pyr)
850850

851851
void createLaplacePyrGpu(InputArray img, int num_levels, std::vector<UMat> &pyr)
852852
{
853-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
853+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
854854
pyr.resize(num_levels + 1);
855855

856856
std::vector<cuda::GpuMat> gpu_pyr(num_levels + 1);
@@ -891,7 +891,7 @@ void restoreImageFromLaplacePyr(std::vector<UMat> &pyr)
891891

892892
void restoreImageFromLaplacePyrGpu(std::vector<UMat> &pyr)
893893
{
894-
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
894+
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
895895
if (pyr.empty())
896896
return;
897897

0 commit comments

Comments
 (0)