Issue 1:
System information (version)

OpenCV => 4.5.2

Operating System / Platform => Windows 10 x64

Compiler => Visual Studio 2019 (19.29.30038.1 for x64)

Detailed description

I was following https://haroonshakeel.medium.com/build-opencv-4-4-0-with-cuda-gpu-support-on-windows-10-without-tears-aa85d470bcd0 to compile OpenCV with CUDA support but for 4.5.2, but it does not compile.

Partial build log:

24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(19): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(19): error : explicit type is missing ("int" assumed)
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(20): error : expected a "{"
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(22): error : identifier "data" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(23): warning : missing return statement at end of non-void function "GpuData"
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(25): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(27): error : identifier "data" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(33): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(33): error : identifier "SizeArray" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(36): error : identifier "SizeArray" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(39): error : more than one conversion function from "lambda [](unsigned int)->__nv_bool" to "<error-type>" applies:
24> function "lambda [](unsigned int)->__nv_bool::operator __nv_bool (*)(unsigned int)() const"
24> function "lambda [](unsigned int)->__nv_bool::operator __nv_bool (*)(unsigned int)() const"
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(47): error : identifier "size" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(47): error : identifier "type" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(47): error : identifier "empty" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(47): error : identifier "external" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(47): error : identifier "isContinuous" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(47): error : identifier "isSubmatrix" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(50): error : identifier "release" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(52): error : identifier "setFields" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(54): error : identifier "data_" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(54): error : identifier "GpuData" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(54): error : identifier "totalMemSize" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(55): error : identifier "data" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(56): error : identifier "offset" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(62): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(64): error : identifier "data" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(65): error : identifier "data_" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(67): error : identifier "flags" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(67): error : identifier "dims" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(67): error : identifier "offset" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(68): error : identifier "size" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(69): error : identifier "step" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(75): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(75): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(105): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(105): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(105): error : a type qualifier is not allowed on a nonmember function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(109): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(109): error : identifier "size" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(109): error : identifier "type" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(111): error : identifier "isContinuous" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(113): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(119): error : identifier "dims" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(121): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(121): error : identifier "step" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(131): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(136): error : identifier "step" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(142): error : "this" may only be used inside a nonstatic member function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(151): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(151): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(151): error : a type qualifier is not allowed on a nonmember function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(155): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(155): error : identifier "size" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(155): error : identifier "type" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(159): error : identifier "isContinuous" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(161): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(167): error : identifier "dims" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(169): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(169): error : identifier "step" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(179): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(184): error : identifier "step" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(190): error : "this" may only be used inside a nonstatic member function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(200): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(209): error : identifier "SizeArray" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(212): error : identifier "create" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(214): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(214): error : identifier "totalMemSize" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(217): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(226): error : identifier "SizeArray" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(229): error : identifier "create" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(232): error : identifier "getDevicePtr" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(232): error : identifier "totalMemSize" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(238): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(238): error : a type qualifier is not allowed on a nonmember function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(242): error : identifier "dims" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(242): error : identifier "size" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(242): error : identifier "type" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(245): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(245): error : "this" may only be used inside a nonstatic member function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(253): error : name followed by "::" must be a class or namespace name
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(253): error : a type qualifier is not allowed on a nonmember function
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(257): error : identifier "dims" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(257): error : identifier "size" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(257): error : identifier "type" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(260): error : identifier "GpuMatND" is undefined
24>
24>G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu(260): error : "this" may only be used inside a nonstatic member function
24>
24>85 errors detected in the compilation of "G:/opencv-master/opencv/modules/core/src/cuda/gpu_mat_nd.cu".
24>gpu_mat_nd.cu
24>CMake Error at cuda_compile_1_generated_gpu_mat_nd.cu.obj.Release.cmake:280 (message):
24> Error generating file
24> G:/opencv-master/opencv/build/modules/world/CMakeFiles/cuda_compile_1.dir/__/core/src/cuda/Release/cuda_compile_1_generated_gpu_mat_nd.cu.obj
24>

nvcc --version output:

Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:54:10_Pacific_Daylight_Time_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.relgpu_drvr455TC455_06.29190527_0

Issue 2:
System information (version)

OpenCV => 4.4.0

Operating System / Platform => Windows 64 Bit

Compiler => Visual Studio 2019

CUDA => 11.1

Detailed description

I was following https://haroonshakeel.medium.com/build-opencv-4-4-0-with-cuda-gpu-support-on-windows-10-without-tears-aa85d470bcd0 to compile OpenCV with CUDA support, but it does not compile.

Partial build log:

22>G:/opencv_contrib-4.4.0/modules/cudaarithm/src/cuda/bitwise_scalar.cu(93): error : NPPTypeTraits is not a template
22>
22>G:/opencv_contrib-4.4.0/modules/cudaarithm/src/cuda/bitwise_scalar.cu(95): error : expected a type specifier
22>
22>G:/opencv_contrib-4.4.0/modules/cudaarithm/src/cuda/bitwise_scalar.cu(95): error : identifier "NppiSize" is undefined
22>
22>G:/opencv_contrib-4.4.0/modules/cudaarithm/src/cuda/bitwise_scalar.cu(95): error : function returning function is not allowed
22>
22>G:/opencv_contrib-4.4.0/modules/cudaarithm/src/cuda/bitwise_scalar.cu(98): error : class "<unnamed>::NppBitwiseCFunc<0, 3>" has no member "func_t"
22> detected during processing of template argument list for "<unnamed>::NppBitwiseC" based on template arguments <0, 3>
22>(135): here

nvcc --version output:

Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:54:10_Pacific_Daylight_Time_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.relgpu_drvr455TC455_06.29190527_0```