首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >用C++和CUDA读取GPU上的视频

用C++和CUDA读取GPU上的视频
EN

Stack Overflow用户
提问于 2021-01-15 17:02:22
回答 2查看 2K关注 0票数 0

大家好,谢谢你们的回答。

首先,正如@zkoza@talonmies所指出的那样,Jetson与ARCH 7.2兼容,而不是与Jetson的案例中使用的ARCH 5.3兼容。

To @Yunus =>我的代码中的fname只有myvideo.MOV,因为我在电影的同一剧目中执行我的代码,我还尝试使用从internet上的示例中获取的.mp4文件导致同样的错误。是的,正如您指出的,我的NVCUVID不在cmake命令之后,正如您在我最初的文章中看到的,与CUDA相对应的行是

代码语言:javascript
复制
 NVIDIA CUDA: YES (ver 10.2, CUFFT CUBLAS FAST_MATH)

而不是

代码语言:javascript
复制
 NVIDIA CUDA: YES (ver 10.2, CUFFT NVCUVID CUBLAS FAST_MATH)

我不知道缺少哪些依赖项,但我在这里也看到NVCUVID被废弃了:https://docs.nvidia.com/cuda/video-decoder/index.html

cuda第6步的例子很好:)我目前正在用cuda 10.2制作opencv 4.3.0,如果这解决了我的问题,我将更新我的答案。

编辑: --不幸的是,使用Ubuntu18.04上的openCV 4.3.0和Cuda10.2,问题完全相同,但是我想补充一下,我使用以下命令进行编译:

代码语言:javascript
复制
g++ video_reader.cpp -o vr.exe `pkg-config --cflags --libs opencv4`

因为g++本身给了我这个错误:

代码语言:javascript
复制
video_reader.cpp:3:10: fatal error: opencv2/opencv_modules.hpp: No such file or directory
 #include "opencv2/opencv_modules.hpp"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

所以,也许我的编译命令就是问题所在?

端编辑

To @user2986898和@einpoklum =>,我运行了cv::getBuildInformation()和其他两个函数:设备数量和兼容设备数量。设备和兼容设备的数量为1台,如预期的那样,生成信息如下:

代码语言:javascript
复制
General configuration for OpenCV 4.5.1 =====================================
  Version control:               unknown

  Extra modules:
    Location (extra):            /home/dronemaitre/Documents/opencv_cpp/opencv_contrib/modules
    Version control (extra):     unknown

  Platform:
    Timestamp:                   2021-01-18T10:12:44Z
    Host:                        Linux 4.9.140-tegra aarch64
    CMake:                       3.10.2
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  CPU/HW features:
    Baseline:                    NEON FP16

  C/C++:
    Built as dynamic libs?:      YES
    C++ standard:                11
    C++ Compiler:                /usr/bin/c++  (ver 7.5.0)
    C++ flags (Release):         -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -fvisibility-inlines-hidden -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/cc
    C flags (Release):           -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -ffast-math -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections    -fvisibility=hidden -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):      -Wl,--gc-sections -Wl,--as-needed  
    Linker flags (Debug):        -Wl,--gc-sections -Wl,--as-needed  
    ccache:                      NO
    Precompiled headers:         NO
    Extra dependencies:          m pthread /usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so cudart_static dl rt nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cudnn cufft -L/usr/local/cuda-10.2/lib64 -L/usr/lib/aarch64-linux-gnu
    3rdparty dependencies:

  OpenCV modules:
    To be built:                 alphamat aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform line_descriptor mcc ml objdetect optflow phase_unwrapping photo plot python2 python3 quality rapid reg rgbd saliency sfm shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
    Disabled:                    world
    Disabled by dependency:      -
    Unavailable:                 cnn_3dobj java julia matlab ovis viz
    Applications:                tests perf_tests apps
    Documentation:               NO
    Non-free algorithms:         NO

  GUI: 
    QT:                          YES (ver 5.9.5)
      QT OpenGL support:         YES (Qt5::OpenGL 5.9.5)
    GTK+:                        NO
    OpenGL support:              YES (/usr/lib/aarch64-linux-gnu/libGL.so /usr/lib/aarch64-linux-gnu/libGLU.so)
    VTK support:                 NO

  Media I/O: 
    ZLib:                        /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.11)
    JPEG:                        /usr/lib/aarch64-linux-gnu/libjpeg.so (ver 80)
    WEBP:                        build (ver encoder: 0x020f)
    PNG:                         /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.6.34)
    TIFF:                        /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.9)
    JPEG 2000:                   build (ver 2.3.1)
    OpenEXR:                     build (ver 2.3.0)
    HDR:                         YES
    SUNRASTER:                   YES
    PXM:                         YES
    PFM:                         YES

  Video I/O:
    DC1394:                      YES (2.2.5)
    FFMPEG:                      YES
      avcodec:                   YES (57.107.100)
      avformat:                  YES (57.83.100)
      avutil:                    YES (55.78.100)
      swscale:                   YES (4.8.100)
      avresample:                YES (3.7.0)
    GStreamer:                   YES (1.14.5)
    v4l/v4l2:                    YES (linux/videodev2.h)

  Parallel framework:            TBB (ver 2017.0 interface 9107)

  Trace:                         YES (with Intel ITT)

  Other third-party libraries:
    Lapack:                      NO
    Eigen:                       YES (ver 3.3.4)
    Custom HAL:                  YES (carotene (ver 0.0.1))
    Protobuf:                    build (3.5.1)

  NVIDIA CUDA:                   YES (ver 10.2, CUFFT CUBLAS FAST_MATH)
    NVIDIA GPU arch:             72
    NVIDIA PTX archs:

  cuDNN:                         YES (ver 8.0.0)

  OpenCL:                        YES (no extra features)
    Include path:                /home/dronemaitre/Documents/opencv_cpp/opencv/3rdparty/include/opencl/1.2
    Link libraries:              Dynamic load

  Python 2:
    Interpreter:                 /usr/bin/python2.7 (ver 2.7.17)
    Libraries:                   /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.17)
    numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.13.3)
    install path:                lib/python2.7/dist-packages/cv2/python-2.7

  Python 3:
    Interpreter:                 /usr/bin/python3 (ver 3.6.9)
    Libraries:                   /usr/lib/aarch64-linux-gnu/libpython3.6m.so (ver 3.6.9)
    numpy:                       /usr/lib/python3/dist-packages/numpy/core/include (ver 1.13.3)
    install path:                lib/python3.6/dist-packages/cv2/python-3.6

  Python (for build):            /usr/bin/python2.7

  Java:                          
    ant:                         NO
    JNI:                         NO
    Java wrappers:               NO
    Java tests:                  NO

  Install to:                    /usr/local
-----------------------------------------------------------------

Cuda似乎是由OpenCV找到的,但是在这里我们可以再次看到,NVCUVID并没有被添加,所以我将-D NVCUVID=ON放在这里,正如您所说的,它可能会被忽略,因为它与我的配置不兼容。编辑:运行在构建文件夹中的 ccmake命令为我提供了以下输出:

代码语言:javascript
复制
ANT_EXECUTABLE                   ANT_EXECUTABLE-NOTFOUND                                           
 Atlas_BLAS_LIBRARY               /usr/lib/aarch64-linux-gnu/libatlas.so                            
 Atlas_CBLAS_INCLUDE_DIR          /usr/include/aarch64-linux-gnu                                    
 Atlas_CBLAS_LIBRARY              /usr/lib/aarch64-linux-gnu/libcblas.so                            
 Atlas_CLAPACK_INCLUDE_DIR        Atlas_CLAPACK_INCLUDE_DIR-NOTFOUND                                
 Atlas_LAPACK_LIBRARY             /usr/lib/aarch64-linux-gnu/liblapack.so                           
 BUILD_CUDA_STUBS                 OFF
 BUILD_DOCS                       OFF
 BUILD_EXAMPLES                   OFF
 BUILD_ITT                        ON 
 BUILD_JASPER                     OFF
 BUILD_JAVA                       ON 
 BUILD_JPEG                       OFF
 BUILD_LIST                          
 BUILD_OPENEXR                    OFF
 BUILD_PACKAGE                    ON 
 BUILD_PERF_TESTS                 ON 
 BUILD_PNG                        OFF
 BUILD_PROTOBUF                   ON 
 BUILD_SHARED_LIBS                ON 
 BUILD_TBB                        OFF
 BUILD_TESTS                      ON 
 BUILD_TIFF                       OFF
 BUILD_USE_SYMLINKS               OFF
 BUILD_WEBP                       OFF
 BUILD_WITH_DEBUG_INFO            OFF
 BUILD_WITH_DYNAMIC_IPP           OFF
 BUILD_ZLIB                       OFF
 BUILD_opencv_alphamat            ON 
 BUILD_opencv_apps                ON 
 BUILD_opencv_aruco               ON 
 BUILD_opencv_bgsegm              ON 
 BUILD_opencv_bioinspired         ON 
 BUILD_opencv_calib3d             ON 
 BUILD_opencv_ccalib              ON 
 BUILD_opencv_core                ON 
 BUILD_opencv_cudaarithm          ON 
 BUILD_opencv_cudabgsegm          ON 
 BUILD_opencv_cudacodec           ON 
 BUILD_opencv_cudafeatures2d      ON 
 BUILD_opencv_cudafilters         ON 
 BUILD_opencv_cudaimgproc         ON 
 BUILD_opencv_cudalegacy          ON 
 BUILD_opencv_cudaobjdetect       ON 
 BUILD_opencv_cudaoptflow         ON 
 BUILD_opencv_cudastereo          ON 
 BUILD_opencv_cudawarping         ON 
 BUILD_opencv_cudev               ON 
 BUILD_opencv_cvv                 ON 
 BUILD_opencv_datasets            ON 
 BUILD_opencv_dnn                 ON 
 BUILD_opencv_dnn_objdetect       ON 
 BUILD_opencv_dnn_superres        ON 
 BUILD_opencv_dpm                 ON 
 BUILD_opencv_face                ON 
 BUILD_opencv_features2d          ON 
 BUILD_opencv_flann               ON 
 BUILD_opencv_freetype            ON 
 BUILD_opencv_fuzzy               ON 
 BUILD_opencv_gapi                ON 
 BUILD_opencv_hdf                 ON 
 BUILD_opencv_hfs                 ON 
 BUILD_opencv_highgui             ON 
 BUILD_opencv_img_hash            ON 
 BUILD_opencv_imgcodecs           ON 
 BUILD_opencv_imgproc             ON 
 BUILD_opencv_intensity_transfo   ON 
 BUILD_opencv_java_bindings_gen   ON 
 BUILD_opencv_js                  OFF
 BUILD_opencv_line_descriptor     ON 
 BUILD_opencv_ml                  ON 
 BUILD_opencv_objdetect           ON 
 BUILD_opencv_optflow             ON 
 BUILD_opencv_phase_unwrapping    ON 
 BUILD_opencv_photo               ON 
 BUILD_opencv_plot                ON 
 BUILD_opencv_python2             ON 
 BUILD_opencv_python3             ON 
 BUILD_opencv_python_bindings_g   ON 
 BUILD_opencv_python_tests        ON 
 BUILD_opencv_quality             ON 
 BUILD_opencv_rapid               ON 
 BUILD_opencv_reg                 ON 
 BUILD_opencv_rgbd                ON 
 BUILD_opencv_saliency            ON 
 BUILD_opencv_sfm                 ON 
 BUILD_opencv_shape               ON 
 BUILD_opencv_stereo              ON 
 BUILD_opencv_stitching           ON 
 BUILD_opencv_structured_light    ON 
 BUILD_opencv_superres            ON 
 BUILD_opencv_surface_matching    ON 
 BUILD_opencv_text                ON 
 BUILD_opencv_tracking            ON 
 BUILD_opencv_ts                  ON 
 BUILD_opencv_video               ON 
 BUILD_opencv_videoio             ON 
 BUILD_opencv_videostab           ON 
 BUILD_opencv_world               OFF
 BUILD_opencv_xfeatures2d         ON  
 BUILD_opencv_ximgproc            ON 
 BUILD_opencv_xobjdetect          ON 
 BUILD_opencv_xphoto              ON 
 CAROTENE_NS                      carotene_o4t                                                      
 CCACHE_PROGRAM                   CCACHE_PROGRAM-NOTFOUND                                           
 CLAMDBLAS_INCLUDE_DIR            CLAMDBLAS_INCLUDE_DIR-NOTFOUND                                    
 CLAMDBLAS_ROOT_DIR               CLAMDBLAS_ROOT_DIR-NOTFOUND                                       
 CLAMDFFT_INCLUDE_DIR             CLAMDFFT_INCLUDE_DIR-NOTFOUND                                     
 CLAMDFFT_ROOT_DIR                CLAMDFFT_ROOT_DIR-NOTFOUND                                        
 CMAKE_BUILD_TYPE                 RELEASE                                                           
 CMAKE_CONFIGURATION_TYPES        Debug;Release                                                     
 CMAKE_INSTALL_PREFIX             /usr/local                                                        
 CPU_BASELINE                     NEON;FP16                                                         
 CPU_BASELINE_DISABLE             ;VFPV3                                                            
 CPU_BASELINE_REQUIRE             ;NEON                                                             
 CPU_DISPATCH                        
 CUDA_ARCH_BIN                    7.2
 CUDA_ARCH_PTX                       
 CUDA_FAST_MATH                   ON 
 CUDA_GENERATION                     
 CUDA_HOST_COMPILER               /usr/bin/cc                                                       
 CUDA_TOOLKIT_ROOT_DIR            /usr/local/cuda-10.2                                              
 CUDA_USE_STATIC_CUDA_RUNTIME     ON 
 CUDA_rt_LIBRARY                  /usr/lib/aarch64-linux-gnu/librt.so                               
 CV_DISABLE_OPTIMIZATION          OFF
 CV_ENABLE_INTRINSICS             ON 
 CV_TRACE                         ON 
 Caffe_INCLUDE_DIR                Caffe_INCLUDE_DIR-NOTFOUND                                        
 Caffe_LIBS                       Caffe_LIBS-NOTFOUND                                               
 Ceres_DIR                        Ceres_DIR-NOTFOUND                                                
 ENABLE_BUILD_HARDENING           OFF
 ENABLE_CCACHE                    ON 
 ENABLE_CONFIG_VERIFICATION       OFF
 ENABLE_COVERAGE                  OFF
 ENABLE_FAST_MATH                 ON 
 ENABLE_FLAKE8                    OFF
 ENABLE_GNU_STL_DEBUG             OFF
 ENABLE_IMPL_COLLECTION           OFF
 ENABLE_INSTRUMENTATION           OFF
 ENABLE_LTO                       OFF
 ENABLE_NEON                      ON 
 ENABLE_NOISY_WARNINGS            OFF
 ENABLE_OMIT_FRAME_POINTER        ON 
 ENABLE_PIC                       ON 
 ENABLE_PRECOMPILED_HEADERS       OFF
 ENABLE_PROFILING                 OFF
 ENABLE_PYLINT                    OFF
 ENABLE_SOLUTION_FOLDERS          OFF
 ENABLE_VFPV3                     OFF
 EXECUTABLE_OUTPUT_PATH           /home/dronemaitre/Documents/opencv_cpp/opencv/build/bin           
 Eigen3_DIR                       /usr/lib/cmake/eigen3                                             
 GENERATE_ABI_DESCRIPTOR          OFF
 Glog_LIBS                        /usr/lib/aarch64-linux-gnu/libglog.so                             
 HDF5_C_LIBRARY_dl                /usr/lib/aarch64-linux-gnu/libdl.so                               
 HDF5_C_LIBRARY_hdf5              /usr/lib/aarch64-linux-gnu/hdf5/serial/libhdf5.so                 
 HDF5_C_LIBRARY_m                 /usr/lib/aarch64-linux-gnu/libm.so                                
 HDF5_C_LIBRARY_pthread           /usr/lib/aarch64-linux-gnu/libpthread.so                          
 HDF5_C_LIBRARY_sz                /usr/lib/aarch64-linux-gnu/libsz.so                               
 HDF5_C_LIBRARY_z                 /usr/lib/aarch64-linux-gnu/libz.so                                
 INSTALL_CREATE_DISTRIB           OFF
 INSTALL_C_EXAMPLES               OFF
 INSTALL_PYTHON_EXAMPLES          OFF
 INSTALL_TESTS                    OFF
 INSTALL_TO_MANGLED_PATHS         OFF
 LAPACKE_INCLUDE_DIR              LAPACKE_INCLUDE_DIR-NOTFOUND                                      
 LAPACK_CBLAS_H                      
 LAPACK_IMPL                      Unknown                                                           
 LAPACK_INCLUDE_DIR                  
 LAPACK_LAPACKE_H                    
 LAPACK_LIBRARIES                    
 Lept_LIBRARY                     Lept_LIBRARY-NOTFOUND                                             
 MKL_INCLUDE_DIRS                 MKL_ROOT_DIR-NOTFOUND/include                                     
 MKL_LAPACKE_INCLUDE_DIR          MKL_LAPACKE_INCLUDE_DIR-NOTFOUND                                  
 MKL_ROOT_DIR                     MKL_ROOT_DIR-NOTFOUND                                             
 MKL_WITH_OPENMP                  OFF
 MKL_WITH_TBB                     OFF
 OGRE_DIR                         OGRE_DIR-NOTFOUND                                                 
 OPENCL_FOUND                     ON 
 OPENCV_CONFIG_FILE_INCLUDE_DIR   /home/dronemaitre/Documents/opencv_cpp/opencv/build               
 OPENCV_DNN_CUDA                  OFF
 OPENCV_DNN_OPENCL                ON 
 OPENCV_DOWNLOAD_PATH             /home/dronemaitre/Documents/opencv_cpp/opencv/.cache              
 OPENCV_DUMP_HOOKS_FLOW           OFF
 OPENCV_ENABLE_ALLOCATOR_STATS    ON 
 OPENCV_ENABLE_ATOMIC_LONG_LONG   OFF
 OPENCV_ENABLE_MEMALIGN           ON 
 OPENCV_ENABLE_MEMORY_SANITIZER   OFF
 OPENCV_ENABLE_NONFREE            OFF
 OPENCV_EXTRA_MODULES_PATH        /home/dronemaitre/Documents/opencv_cpp/opencv_contrib/modules     
 OPENCV_FORCE_3RDPARTY_BUILD      OFF
 OPENCV_FORCE_PYTHON_LIBS         OFF
 OPENCV_GENERATE_PKGCONFIG        ON 
 OPENCV_GENERATE_SETUPVARS        ON 
 OPENCV_JAVA_SOURCE_VERSION          
 OPENCV_JAVA_TARGET_VERSION          
 OPENCV_MATHJAX_RELPATH           https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0              
 OPENCV_PYTHON3_VERSION           OFF
 OPENCV_TIMESTAMP                 2021-01-18T12:55:10Z                                              
 OPENCV_WARNINGS_ARE_ERRORS       OFF
 OPENEXR_INCLUDE_PATH             OPENEXR_INCLUDE_PATH-NOTFOUND   
 OpenCV_HAL_DIR                   OpenCV_HAL_DIR-NOTFOUND                                           
 OpenJPEG_DIR                     OpenJPEG_DIR-NOTFOUND                                             
 PROTOBUF_UPDATE_FILES            OFF
 PYTHON2_EXECUTABLE               /usr/bin/python2.7                                                
 PYTHON2_INCLUDE_DIR              /usr/include/python2.7                                            
 PYTHON2_INCLUDE_DIR2                
 PYTHON2_LIBRARY                  /usr/lib/aarch64-linux-gnu/libpython2.7.so                        
 PYTHON2_LIBRARY_DEBUG               
 PYTHON2_NUMPY_INCLUDE_DIRS       /usr/lib/python2.7/dist-packages/numpy/core/include               
 PYTHON2_PACKAGES_PATH            lib/python2.7/dist-packages                                       
 PYTHON3_EXECUTABLE               /usr/bin/python3                                                  
 PYTHON3_INCLUDE_DIR              /usr/include/python3.6m                                           
 PYTHON3_INCLUDE_DIR2                
 PYTHON3_LIBRARY                  /usr/lib/aarch64-linux-gnu/libpython3.6m.so                       
 PYTHON3_LIBRARY_DEBUG               
 PYTHON3_NUMPY_INCLUDE_DIRS       /usr/lib/python3/dist-packages/numpy/core/include                 
 PYTHON3_PACKAGES_PATH            lib/python3.6/dist-packages                                       
 Qt5Concurrent_DIR                /usr/lib/aarch64-linux-gnu/cmake/Qt5Concurrent                    
 Qt5Core_DIR                      /usr/lib/aarch64-linux-gnu/cmake/Qt5Core                          
 Qt5Gui_DIR                       /usr/lib/aarch64-linux-gnu/cmake/Qt5Gui                           
 Qt5OpenGL_DIR                    /usr/lib/aarch64-linux-gnu/cmake/Qt5OpenGL                        
 Qt5Test_DIR                      /usr/lib/aarch64-linux-gnu/cmake/Qt5Test                          
 Qt5Widgets_DIR                   /usr/lib/aarch64-linux-gnu/cmake/Qt5Widgets                       
 Qt5_DIR                          /usr/lib/aarch64-linux-gnu/cmake/Qt5                              
 TBB_DIR                          TBB_DIR-NOTFOUND                                                  
 TBB_ENV_INCLUDE                  /usr/include                                                      
 TBB_ENV_LIB                      /usr/lib/aarch64-linux-gnu/libtbb.so                              
 TBB_ENV_LIB_DEBUG                TBB_ENV_LIB_DEBUG-NOTFOUND                                        
 TBB_VER_FILE                     /usr/include/tbb/tbb_stddef.h                                     
 Tesseract_DIR                    Tesseract_DIR-NOTFOUND                                            
 Tesseract_INCLUDE_DIR            Tesseract_INCLUDE_DIR-NOTFOUND                                    
 Tesseract_LIBRARY                Tesseract_LIBRARY-NOTFOUND                                        
 VTK_DIR                          VTK_DIR-NOTFOUND                                                  
 WEBP_INCLUDE_DIR                 WEBP_INCLUDE_DIR-NOTFOUND                                         
 WITH_1394                        ON 
 WITH_ADE                         ON 
 WITH_ARAVIS                      OFF
 WITH_CAROTENE                    ON 
 WITH_CLP                         OFF
 WITH_CUBLAS                      ON 
 WITH_CUDA                        ON 
 WITH_CUDNN                       ON 
 WITH_CUFFT                       ON 
 WITH_EIGEN                       ON 
 WITH_FFMPEG                      ON 
 WITH_FREETYPE                    OFF
 WITH_GDAL                        OFF
 WITH_GDCM                        OFF
 WITH_GPHOTO2                     OFF
 WITH_GSTREAMER                   ON         
 WITH_GTK                         ON 
 WITH_GTK_2_X                     OFF
 WITH_HALIDE                      OFF
 WITH_HPX                         OFF
 WITH_IMGCODEC_HDR                ON 
 WITH_IMGCODEC_PFM                ON 
 WITH_IMGCODEC_PXM                ON 
 WITH_IMGCODEC_SUNRASTER          ON 
 WITH_INF_ENGINE                  OFF
 WITH_ITT                         ON 
 WITH_JASPER                      ON 
 WITH_JPEG                        ON 
 WITH_LAPACK                      ON 
 WITH_LIBREALSENSE                OFF
 WITH_MATLAB                      OFF
 WITH_MFX                         OFF
 WITH_NGRAPH                      OFF
 WITH_NVCUVID                     ON 
 WITH_OPENCL                      ON 
 WITH_OPENCLAMDBLAS               ON 
 WITH_OPENCLAMDFFT                ON 
 WITH_OPENCL_SVM                  OFF
 WITH_OPENEXR                     ON 
 WITH_OPENGL                      ON 
 WITH_OPENJPEG                    ON 
 WITH_OPENMP                      OFF
 WITH_OPENNI                      OFF
 WITH_OPENNI2                     OFF
 WITH_OPENVX                      OFF
 WITH_PLAIDML                     OFF
 WITH_PNG                         ON 
 WITH_PROTOBUF                    ON 
 WITH_PTHREADS_PF                 ON 
 WITH_PVAPI                       OFF
 WITH_QT                          ON 
 WITH_QUIRC                       ON 
 WITH_TBB                         ON 
 WITH_TENGINE                     OFF
 WITH_TESSERACT                   ON 
 WITH_TIFF                        ON 
 WITH_V4L                         ON 
 WITH_VA                          OFF
 WITH_VA_INTEL                    OFF
 WITH_VTK                         ON 
 WITH_VULKAN                      OFF
 WITH_WEBP                        ON 
 WITH_XIMEA                       OFF
 WITH_XINE                        OFF
 opencv_dnn_PERF_CAFFE            OFF
 opencv_dnn_PERF_CLCAFFE          OFF     

我们可以看到,数据自动化系统是使国际海事组织,但也是NVCUVID,即使我认为它不是直到现在

端编辑

最后,当当前构建结束时,我将尝试ccmake函数,并编辑或发布结果。

再次感谢大家的支持!

EN

回答 2

Stack Overflow用户

发布于 2021-03-02 17:38:43

我花了两个多星期/几十个小时才终于开始工作(我的配置类似)。这就是我所做的(我希望我记得所有的事情):

  1. my system: Ubuntu18.04 on i7-4790 + GTX1050Ti (驱动程序ver ).460.39) +数据自动化系统10.2 + OpenCV 4.5.1 + ffmpeg OpenCV和ffmpeg是在数据自动化系统支持下构建的。

  1. OpenCV构建选项:

代码语言:javascript
复制
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_C_COMPILER=/usr/bin/gcc-7 \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=ON \
    -D INSTALL_C_EXAMPLES=ON \
    -D WITH_TBB=ON \
    -D WITH_CUDA=ON \
    -D WITH_NVCUVID=ON \
    -D WITH_NVCUVENC=OFF \
    -D BUILD_opencv_cudacodec=ON \
    -D WITH_CUDNN=OFF \
    -D OPENCV_DNN_CUDA=OFF \
    -D CUDA_ARCH_BIN=6.1 \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D WITH_CUBLAS=1 \
    -D WITH_V4L=ON \
    -D WITH_QT=ON \
    -D WITH_OPENGL=ON \
    -D WITH_GSTREAMER=ON \
    -D OPENCV_GENERATE_PKGCONFIG=ON \
    -D OPENCV_PC_FILE_NAME=opencv4.pc \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D OPENCV_PYTHON3_INSTALL_PATH=/usr/lib/python3.6/site-packages \
    -D OPENCV_EXTRA_MODULES_PATH=/path/to/opencv_contrib-4.5.1/modules \
    -D PYTHON_EXECUTABLE="/usr/bin/python2" \
    -D PYTHON_DEFAULT_EXECUTABLE="/usr/bin/python3" \
    -D PYTHON3_EXECUTABLE="/usr/bin/python3" \
    -D BUILD_EXAMPLES=ON ..

  1. ffmpeg -我使用了许多关于在数据自动化系统支持下构建ffmepg的广泛可用教程之一,我的构建看起来如下:

代码语言:javascript
复制
    ffmpeg version N-101174-g14dc28e969 Copyright (c) 2000-2021 the FFmpeg developers
      built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
      configuration: --prefix=/home/lg/ffmpeg_build2 --pkg-config-flags=--static --extra-cflags=-I/home/lg/ffmpeg_build2/include --extra-ldflags=-L/home/lg/ffmpeg_build2/lib --extra-libs='-lpthread -lm' --bindir=/home/lg/bin2 --enable-cuda --enable-cuvid --enable-libnpp --extra-cflags=-I/usr/local/cuda/include/ --extra-ldflags=-L/usr/local/cuda/lib64/ --enable-gpl --enable-opencl --enable-opengl --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libfdk-aac --enable-libvpx --enable-libx264 --enable-libx265 --enable-nvenc --enable-vaapi --enable-vdpau --enable-nonfree --cpu=native --extra-cflags='-march=native'

  1. 虽然编译OpenCV 4.5.1是成功的,但使用简单cv::cudacodec::createVideoReader()的c++示例不起作用,错误是

代码语言:javascript
复制
    The function/feature is not implemented) The called functionality is disabled for current build or platform in function 'throw_no_cuda'

  1. 我下载了NVIDIA的Video_Codec_SDK_10.0.26,并将nvcuvid.hcuviddec.hnvEncodeAPI.h从/Interface复制到CUDA的包含dir (在我的例子中是/usr/local/cuda-10.2/targets/x86_64-linux/include)和/usr/inlcude。可能没有必要将所有这些文件都放在两个位置。

  1. 再次重新编译OpenCV。设置这两个选项是至关重要的:

代码语言:javascript
复制
    -D WITH_NVCUVID=ON \
    -D BUILD_opencv_cudacodec=ON \

没有它们,OpenCV就没有安装NVCUVID模块。编译失败时出错,它抱怨cudaVideoCodec_AV1没有声明或类似的东西,在文件opencv_contrib-4.5.1/modules/cudacodec/src/video_decoder.cpp中,第81行。因为我不打算使用AV1,所以我只是删除了这一行。在此之后,编译终于成功了。

  1. 时间来检查数据自动化系统VideoReader样本-解码H264工作!但HEVC没有-错误是未知的FourCC代码在opencv_contrib-4.5.1/modules/cudacodec/src/ffmpeg_video_source.cpp (我的视频有'hev1‘FourCC)。所以我添加了缺失的definitions:

代码语言:javascript
复制
    case CV_FOURCC_MACRO('H', '2', '6', '5'): // fallthru
    case CV_FOURCC_MACRO('h', '2', '6', '5'): // fallthru
    case CV_FOURCC_MACRO('h', 'e', 'v', 'c'): return HEVC;

改为:

代码语言:javascript
复制
    case CV_FOURCC_MACRO('H', '2', '6', '5'): // fallthru
    case CV_FOURCC_MACRO('h', '2', '6', '5'): // fallthru
    case CV_FOURCC_MACRO('h', 'e', 'v', '1'): // fallthru
    case CV_FOURCC_MACRO('h', 'v', 'c', '1'): // fallthru
    case CV_FOURCC_MACRO('h', 'e', 'v', 'c'): return HEVC;

然后最后一次重新编译OpenCV,最后一切正常工作。

票数 3
EN

Stack Overflow用户

发布于 2021-01-16 09:57:31

(这个答案只是推测性的;如果您发布有关CMake构建日志的信息,我将(可能)编辑它。)

OpenCV告诉你它有no_cuda,即CUDA functionality is disabled for current build or platform

这意味着两件事中的一件:

  1. 尽管您的“最佳意图”设置了一堆CMake标志,但您的OpenCV是在没有CUDA支持的情况下构建的。这是很有可能的,因为有时-D值会被忽略以支持检测到的内容,或者在没有特定设置的情况下无法应用。您应该尝试在构建目录中使用ccmake,看看会出现什么。
  2. 构建是启用CUDA的,但是OpenCV代码无法找到CUDA驱动程序、CUDA运行时库或可用的响应性GPU等等。我不是OpenCV专家,但假设它提供了一些日志记录功能,我会检查一下。@ using 2986898还指出,您可以使用cv::getBuildInformation()函数.

在运行时获取构建信息。

构建OpenCV的测试或示例并检查这些测试是否有效也可能是有用的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65740367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档