Skip to content

Commit 34bca4d

Browse files
committed
Merge branch 4.x
2 parents f88a05c + 2ddfbb8 commit 34bca4d

File tree

26 files changed

+487
-387
lines changed

26 files changed

+487
-387
lines changed

modules/cudaarithm/CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,41 @@ set(the_description "CUDA-accelerated Operations on Matrices")
77
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow)
88

99
set(extra_dependencies "")
10-
set(optional_dependencies "")
1110
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
1211
if(UNIX AND NOT BUILD_SHARED_LIBS AND CUDA_VERSION_STRING VERSION_GREATER_EQUAL 9.2 AND CUDA_VERSION_STRING VERSION_LESS 13.0 AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.23)
1312
set(CUDA_FFT_LIB_EXT "_static_nocallback")
1413
endif()
15-
list(APPEND extra_dependencies CUDA::cudart_static CUDA::nppial${CUDA_LIB_EXT} CUDA::nppc${CUDA_LIB_EXT} CUDA::nppitc${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppidei${CUDA_LIB_EXT})
14+
list(APPEND extra_dependencies CUDA::cudart${CUDA_LIB_EXT} CUDA::nppial${CUDA_LIB_EXT} CUDA::nppc${CUDA_LIB_EXT} CUDA::nppitc${CUDA_LIB_EXT} CUDA::nppig${CUDA_LIB_EXT} CUDA::nppist${CUDA_LIB_EXT} CUDA::nppidei${CUDA_LIB_EXT})
1615
if(HAVE_CUBLAS)
17-
list(APPEND optional_dependencies CUDA::cublas${CUDA_LIB_EXT})
16+
list(APPEND extra_dependencies CUDA::cublas${CUDA_LIB_EXT})
1817
if(NOT CUDA_VERSION VERSION_LESS 10.1)
19-
list(APPEND optional_dependencies CUDA::cublasLt${CUDA_LIB_EXT})
18+
list(APPEND extra_dependencies CUDA::cublasLt${CUDA_LIB_EXT})
2019
endif()
2120
endif()
2221
if(HAVE_CUFFT)
2322
# static version requires seperable compilation which is incompatible with opencv's current library structure
2423
# the cufft_static_nocallback variant does not requires seperable compilation. callbacks are currently not used.
25-
list(APPEND optional_dependencies CUDA::cufft${CUDA_FFT_LIB_EXT})
24+
list(APPEND extra_dependencies CUDA::cufft${CUDA_FFT_LIB_EXT})
2625
endif()
2726
else()
2827
if(HAVE_CUBLAS)
29-
list(APPEND optional_dependencies ${CUDA_cublas_LIBRARY})
28+
list(APPEND extra_dependencies ${CUDA_cublas_LIBRARY})
3029
endif()
3130
if(HAVE_CUFFT)
32-
list(APPEND optional_dependencies ${CUDA_cufft_LIBRARY})
31+
list(APPEND extra_dependencies ${CUDA_cufft_LIBRARY})
3332
endif()
3433
endif()
3534

36-
ocv_add_module(cudaarithm opencv_core ${extra_dependencies} OPTIONAL opencv_cudev ${optional_dependencies} WRAP python)
35+
ocv_add_module(cudaarithm opencv_core OPTIONAL opencv_cudev WRAP python)
3736

3837
ocv_module_include_directories()
3938
ocv_glob_module_sources()
4039

41-
ocv_create_module()
40+
ocv_create_module(${extra_dependencies})
4241

43-
ocv_add_accuracy_tests(DEPENDS_ON opencv_imgproc)
42+
set(test_libs "")
43+
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
44+
list(APPEND test_libs CUDA::cudart${CUDA_LIB_EXT})
45+
endif()
46+
ocv_add_accuracy_tests(${test_libs} DEPENDS_ON opencv_imgproc)
4447
ocv_add_perf_tests(DEPENDS_ON opencv_imgproc)

modules/cudabgsegm/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ endif()
55
set(the_description "CUDA-accelerated Background Segmentation")
66

77
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow)
8+
9+
ocv_define_module(cudabgsegm opencv_video WRAP python)
10+
811
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
9-
ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS})
12+
ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT})
1013
endif()
11-
ocv_define_module(cudabgsegm opencv_video WRAP python)

modules/cudacodec/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ endif()
3232

3333
if(HAVE_NVCUVID OR HAVE_NVCUVENC)
3434
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
35-
list(APPEND extra_libs CUDA::cuda_driver)
35+
list(APPEND extra_libs CUDA::cuda_driver CUDA::cudart${CUDA_LIB_EXT})
3636
else()
3737
list(APPEND extra_libs ${CUDA_CUDA_LIBRARY})
3838
endif()

modules/cudacodec/include/opencv2/cudacodec.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,9 @@ class CV_EXPORTS_W NVSurfaceToColorConverter {
392392
* @param outputFormat The requested output color format.
393393
* @param bitDepth The requested bit depth of the output frame.
394394
* @param planar Request seperate planes for each color plane.
395-
* @param videoFullRangeFlag Indicates if the black level, luma and chroma of the source are represented using the full or limited range (AKA TV or "analogue" range) of values as defined in Annex E of the ITU-T Specification.
396395
* @param stream Stream for the asynchronous version.
397396
*/
398-
virtual bool convert(InputArray yuv, OutputArray color, const SurfaceFormat surfaceFormat, const ColorFormat outputFormat, const BitDepth bitDepth = BitDepth::UNCHANGED, const bool planar = false, const bool videoFullRangeFlag = false, cuda::Stream& stream = cuda::Stream::Null()) = 0;
397+
CV_WRAP virtual bool convert(InputArray yuv, OutputArray color, const SurfaceFormat surfaceFormat, const ColorFormat outputFormat, const BitDepth bitDepth = BitDepth::UNCHANGED, const bool planar = false, cuda::Stream& stream = cuda::Stream::Null()) = 0;
399398
};
400399

401400
/** @brief Creates a NVSurfaceToColorConverter.

modules/cudacodec/misc/python/test/test_cudacodec.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def test_reader(self):
6060

6161
# Change color format
6262
ret, colour_code = reader.getVideoReaderProps(cv.cudacodec.VideoReaderProps_PROP_COLOR_FORMAT)
63-
self.assertTrue(ret and colour_code == cv.cudacodec.ColorFormat_BGRA)
64-
colour_code_gs = cv.cudacodec.ColorFormat_GRAY
63+
self.assertTrue(ret and colour_code == cv.cudacodec.BGRA)
64+
colour_code_gs = cv.cudacodec.GRAY
6565
reader.set(colour_code_gs)
6666
ret, colour_code = reader.getVideoReaderProps(cv.cudacodec.VideoReaderProps_PROP_COLOR_FORMAT)
6767
self.assertTrue(ret and colour_code == colour_code_gs)
@@ -91,6 +91,14 @@ def test_reader(self):
9191
else:
9292
self.skipTest(e.err)
9393

94+
def test_NVSurfaceToColorConverter(self):
95+
converter = cv.cudacodec.createNVSurfaceToColorConverter(cv.cudacodec.ColorSpaceStandard_BT601,False)
96+
bgr_sz = (1920,1080)
97+
nv12_sz = (1920, int(1.5*1080))
98+
blank_nv12_frame = cv.cuda.GpuMat(nv12_sz,cv.CV_8U)
99+
ret, bgr = converter.convert(blank_nv12_frame, cv.cudacodec.SF_NV12, cv.cudacodec.BGR)
100+
self.assertTrue(ret == True and bgr.size() == bgr_sz)
101+
94102
def test_map_histogram(self):
95103
hist = cv.cuda_GpuMat((1,256), cv.CV_8UC1)
96104
hist.setTo(1)
@@ -107,7 +115,7 @@ def test_writer(self):
107115
encoder_params_in.gopLength = 10
108116
stream = cv.cuda.Stream()
109117
sz = (1920,1080)
110-
writer = cv.cudacodec.createVideoWriter(fname, sz, cv.cudacodec.H264, 30, cv.cudacodec.ColorFormat_BGR,
118+
writer = cv.cudacodec.createVideoWriter(fname, sz, cv.cudacodec.H264, 30, cv.cudacodec.BGR,
111119
encoder_params_in, stream=stream)
112120
blankFrameIn = cv.cuda.GpuMat(sz,cv.CV_8UC3)
113121
writer.write(blankFrameIn)

0 commit comments

Comments
 (0)