Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions modules/cudaarithm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,41 @@ set(the_description "CUDA-accelerated Operations on Matrices")
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow)

set(extra_dependencies "")
set(optional_dependencies "")
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
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)
set(CUDA_FFT_LIB_EXT "_static_nocallback")
endif()
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})
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})
if(HAVE_CUBLAS)
list(APPEND optional_dependencies CUDA::cublas${CUDA_LIB_EXT})
list(APPEND extra_dependencies CUDA::cublas${CUDA_LIB_EXT})
if(NOT CUDA_VERSION VERSION_LESS 10.1)
list(APPEND optional_dependencies CUDA::cublasLt${CUDA_LIB_EXT})
list(APPEND extra_dependencies CUDA::cublasLt${CUDA_LIB_EXT})
endif()
endif()
if(HAVE_CUFFT)
# static version requires seperable compilation which is incompatible with opencv's current library structure
# the cufft_static_nocallback variant does not requires seperable compilation. callbacks are currently not used.
list(APPEND optional_dependencies CUDA::cufft${CUDA_FFT_LIB_EXT})
list(APPEND extra_dependencies CUDA::cufft${CUDA_FFT_LIB_EXT})
endif()
else()
if(HAVE_CUBLAS)
list(APPEND optional_dependencies ${CUDA_cublas_LIBRARY})
list(APPEND extra_dependencies ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUFFT)
list(APPEND optional_dependencies ${CUDA_cufft_LIBRARY})
list(APPEND extra_dependencies ${CUDA_cufft_LIBRARY})
endif()
endif()

ocv_add_module(cudaarithm opencv_core ${extra_dependencies} OPTIONAL opencv_cudev ${optional_dependencies} WRAP python)
ocv_add_module(cudaarithm opencv_core OPTIONAL opencv_cudev WRAP python)

ocv_module_include_directories()
ocv_glob_module_sources()

ocv_create_module()
ocv_create_module(${extra_dependencies})

ocv_add_accuracy_tests(DEPENDS_ON opencv_imgproc)
set(test_libs "")
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
list(APPEND test_libs CUDA::cudart${CUDA_LIB_EXT})
endif()
ocv_add_accuracy_tests(${test_libs} DEPENDS_ON opencv_imgproc)
ocv_add_perf_tests(DEPENDS_ON opencv_imgproc)
6 changes: 4 additions & 2 deletions modules/cudabgsegm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ endif()
set(the_description "CUDA-accelerated Background Segmentation")

ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow)

ocv_define_module(cudabgsegm opencv_video WRAP python)

if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
ocv_module_include_directories(${CUDAToolkit_INCLUDE_DIRS})
ocv_target_link_libraries(${the_module} PRIVATE CUDA::cudart${CUDA_LIB_EXT})
endif()
ocv_define_module(cudabgsegm opencv_video WRAP python)
2 changes: 1 addition & 1 deletion modules/cudacodec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ endif()

if(HAVE_NVCUVID OR HAVE_NVCUVENC)
if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
list(APPEND extra_libs CUDA::cuda_driver)
list(APPEND extra_libs CUDA::cuda_driver CUDA::cudart${CUDA_LIB_EXT})
else()
list(APPEND extra_libs ${CUDA_CUDA_LIBRARY})
endif()
Expand Down
3 changes: 1 addition & 2 deletions modules/cudacodec/include/opencv2/cudacodec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,9 @@ class CV_EXPORTS_W NVSurfaceToColorConverter {
* @param outputFormat The requested output color format.
* @param bitDepth The requested bit depth of the output frame.
* @param planar Request seperate planes for each color plane.
* @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.
* @param stream Stream for the asynchronous version.
*/
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;
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;
};

/** @brief Creates a NVSurfaceToColorConverter.
Expand Down
14 changes: 11 additions & 3 deletions modules/cudacodec/misc/python/test/test_cudacodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def test_reader(self):

# Change color format
ret, colour_code = reader.getVideoReaderProps(cv.cudacodec.VideoReaderProps_PROP_COLOR_FORMAT)
self.assertTrue(ret and colour_code == cv.cudacodec.ColorFormat_BGRA)
colour_code_gs = cv.cudacodec.ColorFormat_GRAY
self.assertTrue(ret and colour_code == cv.cudacodec.BGRA)
colour_code_gs = cv.cudacodec.GRAY
reader.set(colour_code_gs)
ret, colour_code = reader.getVideoReaderProps(cv.cudacodec.VideoReaderProps_PROP_COLOR_FORMAT)
self.assertTrue(ret and colour_code == colour_code_gs)
Expand Down Expand Up @@ -91,6 +91,14 @@ def test_reader(self):
else:
self.skipTest(e.err)

def test_NVSurfaceToColorConverter(self):
converter = cv.cudacodec.createNVSurfaceToColorConverter(cv.cudacodec.ColorSpaceStandard_BT601,False)
bgr_sz = (1920,1080)
nv12_sz = (1920, int(1.5*1080))
blank_nv12_frame = cv.cuda.GpuMat(nv12_sz,cv.CV_8U)
ret, bgr = converter.convert(blank_nv12_frame, cv.cudacodec.SF_NV12, cv.cudacodec.BGR)
self.assertTrue(ret == True and bgr.size() == bgr_sz)

def test_map_histogram(self):
hist = cv.cuda_GpuMat((1,256), cv.CV_8UC1)
hist.setTo(1)
Expand All @@ -107,7 +115,7 @@ def test_writer(self):
encoder_params_in.gopLength = 10
stream = cv.cuda.Stream()
sz = (1920,1080)
writer = cv.cudacodec.createVideoWriter(fname, sz, cv.cudacodec.H264, 30, cv.cudacodec.ColorFormat_BGR,
writer = cv.cudacodec.createVideoWriter(fname, sz, cv.cudacodec.H264, 30, cv.cudacodec.BGR,
encoder_params_in, stream=stream)
blankFrameIn = cv.cuda.GpuMat(sz,cv.CV_8UC3)
writer.write(blankFrameIn)
Expand Down
Loading
Loading