[JAVA] Note Book: OpenCV with CUDA Install On Windows10

Install Opencv. CUDA enablement and settings.

environment ・ Windows 10 ・ Cpu ryzen 3700x ・ Gpu ncvidia-rtx3900

software ・ Anaconda ・ Ninja ・ Cmake ・ Git ・ Opencv-4.5.0 ・ Ant 1.8.2 ・ Open-jdk-15 ・ Cuda 11 ・ Cudnn 8.4 ・ Visual studio 2019

instalacion

cmd.exe


cmake  -G "Visual Studio 16 2019" -A x64 -S . -B "build64"
cmake -DCMAKE_INSTALL_PREFIX=/tools/opt/opencv build64 -DWITH_CUDA=ON -DOPENCV_DNN_CUDA=ON -DOPENCV_EXTRA_MODULES_PATH=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv_contrib/modules -DDVTK_DIR=C:/tools/opt/vtk -DLAPACK_LIBRARIES=C:/tools/opt/lapack-release/lapack.lib -DOpenBLAS_INCLUDE_DIR=C:/tools/opt/openblas/include/openblas -DOpenBLAS_LIB=C:/tools/opt/openblas/lib/openblas.lib -DOPENCV_JAVA_SOURCE_VERSION=14 -DOPENCV_JAVA_TARGET_VERSION=14 --build build64
cmake --build build64 --config Release --target install

@rem settings. looks like this. cmake with -D option. 
WITH_CUDA=ON
OPENCV_DNN_CUDA=ON
OPENCV_EXTRA_MODULES_PATH=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv_contrib/modules
DVTK_DIR=C:/tools/opt/vtk
LAPACK_LIBRARIES=C:/tools/opt/lapack-release/lapack.lib
OpenBLAS_INCLUDE_DIR=C:/tools/opt/openblas/include/openblas
OpenBLAS_LIB=C:/tools/opt/openblas/lib/openblas.lib
@rem settings

Build Settings : cmake -L

cmd


C:\tools\opencv\opencv-4.5.0-bin-win.work\opencv\build\build64>cmake -L
CMake Warning:
  No source or binary directory provided.  Both will be assumed to be the
  same as the current working directory, but note that this warning will
  become a fatal error in future CMake releases.
CMake Error: The source directory "C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv/build/build64" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
-- Cache values
ANT_EXECUTABLE:FILEPATH=C:/tools/apache-ant-1.8.2-bin/bin/ant.bat
BUILD_CUDA_STUBS:BOOL=ON
BUILD_DOCS:BOOL=OFF
BUILD_EXAMPLES:BOOL=OFF
BUILD_IPP_IW:BOOL=ON
BUILD_ITT:BOOL=ON
BUILD_JASPER:BOOL=ON
BUILD_JAVA:BOOL=ON
BUILD_JPEG:BOOL=ON
BUILD_LIST:STRING=
BUILD_OPENEXR:BOOL=ON
BUILD_OPENJPEG:BOOL=ON
BUILD_PACKAGE:BOOL=ON
BUILD_PERF_TESTS:BOOL=ON
BUILD_PNG:BOOL=ON
BUILD_PROTOBUF:BOOL=ON
BUILD_SHARED_LIBS:BOOL=ON
BUILD_TBB:BOOL=OFF
BUILD_TESTS:BOOL=ON
BUILD_TIFF:BOOL=ON
BUILD_USE_SYMLINKS:BOOL=OFF
BUILD_WEBP:BOOL=ON
BUILD_WITH_DEBUG_INFO:BOOL=OFF
BUILD_WITH_DYNAMIC_IPP:BOOL=OFF
BUILD_WITH_STATIC_CRT:BOOL=ON
BUILD_ZLIB:BOOL=ON
BUILD_opencv_apps:BOOL=ON
BUILD_opencv_aruco:BOOL=ON
BUILD_opencv_bgsegm:BOOL=ON
BUILD_opencv_bioinspired:BOOL=ON
BUILD_opencv_calib3d:BOOL=ON
BUILD_opencv_ccalib:BOOL=ON
BUILD_opencv_core:BOOL=ON
BUILD_opencv_cudaarithm:BOOL=ON
BUILD_opencv_cudabgsegm:BOOL=ON
BUILD_opencv_cudacodec:BOOL=ON
BUILD_opencv_cudafeatures2d:BOOL=ON
BUILD_opencv_cudafilters:BOOL=ON
BUILD_opencv_cudaimgproc:BOOL=ON
BUILD_opencv_cudalegacy:BOOL=ON
BUILD_opencv_cudaobjdetect:BOOL=ON
BUILD_opencv_cudaoptflow:BOOL=ON
BUILD_opencv_cudastereo:BOOL=ON
BUILD_opencv_cudawarping:BOOL=ON
BUILD_opencv_cudev:BOOL=ON
BUILD_opencv_datasets:BOOL=ON
BUILD_opencv_dnn:BOOL=ON
BUILD_opencv_dnn_objdetect:BOOL=ON
BUILD_opencv_dnn_superres:BOOL=ON
BUILD_opencv_dpm:BOOL=ON
BUILD_opencv_face:BOOL=ON
BUILD_opencv_features2d:BOOL=ON
BUILD_opencv_flann:BOOL=ON
BUILD_opencv_fuzzy:BOOL=ON
BUILD_opencv_gapi:BOOL=ON
BUILD_opencv_hdf:BOOL=ON
BUILD_opencv_hfs:BOOL=ON
BUILD_opencv_highgui:BOOL=ON
BUILD_opencv_img_hash:BOOL=ON
BUILD_opencv_imgcodecs:BOOL=ON
BUILD_opencv_imgproc:BOOL=ON
BUILD_opencv_intensity_transform:BOOL=ON
BUILD_opencv_java:BOOL=ON
BUILD_opencv_java_bindings_generator:BOOL=ON
BUILD_opencv_js:BOOL=OFF
BUILD_opencv_line_descriptor:BOOL=ON
BUILD_opencv_mcc:BOOL=ON
BUILD_opencv_ml:BOOL=ON
BUILD_opencv_objdetect:BOOL=ON
BUILD_opencv_optflow:BOOL=ON
BUILD_opencv_phase_unwrapping:BOOL=ON
BUILD_opencv_photo:BOOL=ON
BUILD_opencv_plot:BOOL=ON
BUILD_opencv_python_bindings_generator:BOOL=ON
BUILD_opencv_python_tests:BOOL=ON
BUILD_opencv_quality:BOOL=ON
BUILD_opencv_rapid:BOOL=ON
BUILD_opencv_reg:BOOL=ON
BUILD_opencv_rgbd:BOOL=ON
BUILD_opencv_saliency:BOOL=ON
BUILD_opencv_shape:BOOL=ON
BUILD_opencv_stereo:BOOL=ON
BUILD_opencv_stitching:BOOL=ON
BUILD_opencv_structured_light:BOOL=ON
BUILD_opencv_superres:BOOL=ON
BUILD_opencv_surface_matching:BOOL=ON
BUILD_opencv_text:BOOL=ON
BUILD_opencv_tracking:BOOL=ON
BUILD_opencv_ts:BOOL=ON
BUILD_opencv_video:BOOL=ON
BUILD_opencv_videoio:BOOL=ON
BUILD_opencv_videostab:BOOL=ON
BUILD_opencv_world:BOOL=OFF
BUILD_opencv_xfeatures2d:BOOL=ON
BUILD_opencv_ximgproc:BOOL=ON
BUILD_opencv_xobjdetect:BOOL=ON
BUILD_opencv_xphoto:BOOL=ON
CLAMDBLAS_INCLUDE_DIR:PATH=CLAMDBLAS_INCLUDE_DIR-NOTFOUND
CLAMDBLAS_ROOT_DIR:PATH=CLAMDBLAS_ROOT_DIR-NOTFOUND
CLAMDFFT_INCLUDE_DIR:PATH=CLAMDFFT_INCLUDE_DIR-NOTFOUND
CLAMDFFT_ROOT_DIR:PATH=CLAMDFFT_ROOT_DIR-NOTFOUND
CMAKE_AR:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/lib.exe
CMAKE_CONFIGURATION_TYPES:STRING=Debug;Release
CMAKE_INSTALL_PREFIX:PATH=/tools/opt/opencv
CPU_BASELINE:STRING=SSE3
CPU_DISPATCH:STRING=SSE4_1;SSE4_2;AVX;FP16;AVX2;AVX512_SKX
CUDA_ARCH_BIN:STRING=3.5;3.7;5.0;5.2;6.0;6.1;7.0;7.5;8.0;8.6
CUDA_ARCH_PTX:STRING=
CUDA_ENABLE_DEPRECATED_GENERATION:BOOL=OFF
CUDA_FAST_MATH:BOOL=OFF
CUDA_GENERATION:STRING=
CUDA_HOST_COMPILER:FILEPATH=$(VCInstallDir)Tools/MSVC/$(VCToolsVersion)/bin/Host$(Platform)/$(PlatformTarget)
CUDA_TOOLKIT_ROOT_DIR:PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.1
CUDA_USE_STATIC_CUDA_RUNTIME:BOOL=ON
CV_DISABLE_OPTIMIZATION:BOOL=OFF
CV_ENABLE_INTRINSICS:BOOL=ON
CV_TRACE:BOOL=ON
Caffe_INCLUDE_DIR:PATH=Caffe_INCLUDE_DIR-NOTFOUND
Caffe_LIBS:FILEPATH=Caffe_LIBS-NOTFOUND
Ceres_DIR:PATH=Ceres_DIR-NOTFOUND
DC1394_INCLUDE:PATH=DC1394_INCLUDE-NOTFOUND
DC1394_LIBRARY:FILEPATH=DC1394_LIBRARY-NOTFOUND
DVTK_DIR:PATH=C:/tools/opt/vtk
EIGEN_INCLUDE_PATH:PATH=EIGEN_INCLUDE_PATH-NOTFOUND
ENABLE_BUILD_HARDENING:BOOL=OFF
ENABLE_CCACHE:BOOL=OFF
ENABLE_CONFIG_VERIFICATION:BOOL=OFF
ENABLE_FAST_MATH:BOOL=OFF
ENABLE_FLAKE8:BOOL=OFF
ENABLE_IMPL_COLLECTION:BOOL=OFF
ENABLE_INSTRUMENTATION:BOOL=OFF
ENABLE_LTO:BOOL=OFF
ENABLE_NOISY_WARNINGS:BOOL=OFF
ENABLE_PIC:BOOL=ON
ENABLE_PRECOMPILED_HEADERS:BOOL=ON
ENABLE_PYLINT:BOOL=OFF
ENABLE_SOLUTION_FOLDERS:BOOL=ON
EXECUTABLE_OUTPUT_PATH:PATH=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv/build/build64/bin
Eigen3_DIR:PATH=Eigen3_DIR-NOTFOUND
GSTREAMER_app_LIBRARY:FILEPATH=GSTREAMER_app_LIBRARY-NOTFOUND
GSTREAMER_base_LIBRARY:FILEPATH=GSTREAMER_base_LIBRARY-NOTFOUND
GSTREAMER_glib_INCLUDE_DIR:PATH=GSTREAMER_glib_INCLUDE_DIR-NOTFOUND
GSTREAMER_glib_LIBRARY:FILEPATH=GSTREAMER_glib_LIBRARY-NOTFOUND
GSTREAMER_glibconfig_INCLUDE_DIR:PATH=GSTREAMER_glibconfig_INCLUDE_DIR-NOTFOUND
GSTREAMER_gobject_LIBRARY:FILEPATH=GSTREAMER_gobject_LIBRARY-NOTFOUND
GSTREAMER_gst_INCLUDE_DIR:PATH=GSTREAMER_gst_INCLUDE_DIR-NOTFOUND
GSTREAMER_gstreamer_LIBRARY:FILEPATH=GSTREAMER_gstreamer_LIBRARY-NOTFOUND
GSTREAMER_pbutils_LIBRARY:FILEPATH=GSTREAMER_pbutils_LIBRARY-NOTFOUND
GSTREAMER_riff_LIBRARY:FILEPATH=GSTREAMER_riff_LIBRARY-NOTFOUND
Glog_LIBS:FILEPATH=Glog_LIBS-NOTFOUND
INSTALL_CREATE_DISTRIB:BOOL=OFF
INSTALL_C_EXAMPLES:BOOL=OFF
INSTALL_PDB:BOOL=ON
INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL:BOOL=ON
INSTALL_PYTHON_EXAMPLES:BOOL=OFF
INSTALL_TESTS:BOOL=OFF
LAPACK_CBLAS_H:STRING=
LAPACK_IMPL:STRING=Unknown
LAPACK_INCLUDE_DIR:PATH=
LAPACK_LAPACKE_H:STRING=
LAPACK_LIBRARIES:STRING=C:/tools/opt/lapack-release/lapack.lib
Lept_LIBRARY:FILEPATH=Lept_LIBRARY-NOTFOUND
MKL_INCLUDE_DIRS:PATH=MKL_ROOT_DIR-NOTFOUND/include
MKL_ROOT_DIR:PATH=MKL_ROOT_DIR-NOTFOUND
MKL_WITH_OPENMP:BOOL=OFF
MKL_WITH_TBB:BOOL=OFF
M_LIBRARY:FILEPATH=M_LIBRARY-NOTFOUND
OGRE_DIR:PATH=OGRE_DIR-NOTFOUND
OPENCL_FOUND:BOOL=ON
OPENCV_CMAKE_MACRO_WIN32_WINNT:STRING=0x0601
OPENCV_CONFIG_FILE_INCLUDE_DIR:PATH=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv/build/build64
OPENCV_DNN_CUDA:BOOL=ON
OPENCV_DNN_OPENCL:BOOL=ON
OPENCV_DOWNLOAD_PATH:PATH=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv/.cache
OPENCV_DUMP_HOOKS_FLOW:BOOL=OFF
OPENCV_ENABLE_ALLOCATOR_STATS:BOOL=ON
OPENCV_ENABLE_ATOMIC_LONG_LONG:BOOL=ON
OPENCV_ENABLE_MEMALIGN:BOOL=ON
OPENCV_ENABLE_MEMORY_SANITIZER:BOOL=OFF
OPENCV_ENABLE_NONFREE:BOOL=OFF
OPENCV_EXTRA_MODULES_PATH:PATH=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv_contrib/modules
OPENCV_FORCE_3RDPARTY_BUILD:BOOL=OFF
OPENCV_GENERATE_PKGCONFIG:BOOL=OFF
OPENCV_GENERATE_SETUPVARS:BOOL=ON
OPENCV_IPP_GAUSSIAN_BLUR:BOOL=OFF
OPENCV_JAVADOC_DESTINATION:STRING=C:/tools/opencv/opencv-4.5.0-bin-win.work/opencv/build/build64/doc/doxygen/html/javadoc
OPENCV_JAVADOC_LINK_URL:STRING=
OPENCV_JAVA_SOURCE_VERSION:STRING=
OPENCV_JAVA_TARGET_VERSION:STRING=
OPENCV_MATHJAX_RELPATH:STRING=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0
OPENCV_MSVC_PARALLEL:STRING=ON
OPENCV_PYTHON3_VERSION:BOOL=OFF
OPENCV_TIMESTAMP:STRING=2020-10-30T12:53:50Z
OPENCV_WARNINGS_ARE_ERRORS:BOOL=OFF
OPJ_DISABLE_TPSOT_FIX:BOOL=OFF
OPJ_USE_THREAD:BOOL=ON
OpenCV_HAL_DIR:PATH=OpenCV_HAL_DIR-NOTFOUND
PROTOBUF_UPDATE_FILES:BOOL=OFF
PYTHON2_EXECUTABLE:FILEPATH=
PYTHON2_INCLUDE_DIR:PATH=
PYTHON2_INCLUDE_DIR2:PATH=
PYTHON2_LIBRARY:FILEPATH=
PYTHON2_LIBRARY_DEBUG:FILEPATH=
PYTHON2_NUMPY_INCLUDE_DIRS:PATH=
PYTHON2_PACKAGES_PATH:PATH=
PYTHON3_EXECUTABLE:FILEPATH=C:/tools/pleiades-2020-09/pleiades/python/3/python.exe
PYTHON3_INCLUDE_DIR:PATH=
PYTHON3_INCLUDE_DIR2:PATH=
PYTHON3_LIBRARY:FILEPATH=
PYTHON3_LIBRARY_DEBUG:FILEPATH=
PYTHON3_NUMPY_INCLUDE_DIRS:PATH=
PYTHON3_PACKAGES_PATH:PATH=C:/tools/pleiades-2020-09/pleiades/python/3/Lib/site-packages
Tesseract_DIR:PATH=Tesseract_DIR-NOTFOUND
Tesseract_INCLUDE_DIR:PATH=Tesseract_INCLUDE_DIR-NOTFOUND
Tesseract_LIBRARY:FILEPATH=Tesseract_LIBRARY-NOTFOUND
USE_WIN32_FILEIO:BOOL=ON
VTK_DIR:PATH=VTK_DIR-NOTFOUND
WITH_1394:BOOL=ON
WITH_ADE:BOOL=ON
WITH_ARITH_DEC:BOOL=ON
WITH_ARITH_ENC:BOOL=ON
WITH_CLP:BOOL=OFF
WITH_CUBLAS:BOOL=ON
WITH_CUDA:BOOL=ON
WITH_CUDNN:BOOL=ON
WITH_CUFFT:BOOL=ON
WITH_DIRECTX:BOOL=ON
WITH_DSHOW:BOOL=ON
WITH_EIGEN:BOOL=ON
WITH_FFMPEG:BOOL=ON
WITH_FREETYPE:BOOL=OFF
WITH_GDAL:BOOL=OFF
WITH_GDCM:BOOL=OFF
WITH_GSTREAMER:BOOL=ON
WITH_HALIDE:BOOL=OFF
WITH_HPX:BOOL=OFF
WITH_IMGCODEC_HDR:BOOL=ON
WITH_IMGCODEC_PFM:BOOL=ON
WITH_IMGCODEC_PXM:BOOL=ON
WITH_IMGCODEC_SUNRASTER:BOOL=ON
WITH_INF_ENGINE:BOOL=OFF
WITH_IPP:BOOL=ON
WITH_ITT:BOOL=ON
WITH_JASPER:BOOL=ON
WITH_JPEG:BOOL=ON
WITH_LAPACK:BOOL=ON
WITH_LIBREALSENSE:BOOL=OFF
WITH_MATLAB:BOOL=OFF
WITH_MFX:BOOL=OFF
WITH_MSMF:BOOL=ON
WITH_MSMF_DXVA:BOOL=ON
WITH_NGRAPH:BOOL=OFF
WITH_NVCUVID:BOOL=OFF
WITH_OPENCL:BOOL=ON
WITH_OPENCLAMDBLAS:BOOL=ON
WITH_OPENCLAMDFFT:BOOL=ON
WITH_OPENCL_D3D11_NV:BOOL=ON
WITH_OPENCL_SVM:BOOL=OFF
WITH_OPENEXR:BOOL=ON
WITH_OPENGL:BOOL=OFF
WITH_OPENJPEG:BOOL=ON
WITH_OPENMP:BOOL=OFF
WITH_OPENNI:BOOL=OFF
WITH_OPENNI2:BOOL=OFF
WITH_OPENVX:BOOL=OFF
WITH_PLAIDML:BOOL=OFF
WITH_PNG:BOOL=ON
WITH_PROTOBUF:BOOL=ON
WITH_PVAPI:BOOL=OFF
WITH_QT:BOOL=OFF
WITH_QUIRC:BOOL=ON
WITH_TBB:BOOL=OFF
WITH_TESSERACT:BOOL=ON
WITH_TIFF:BOOL=ON
WITH_VTK:BOOL=ON
WITH_VULKAN:BOOL=OFF
WITH_WEBP:BOOL=ON
WITH_WIN32UI:BOOL=ON
WITH_XIMEA:BOOL=OFF
ccitt:BOOL=ON
gflags_DIR:PATH=gflags_DIR-NOTFOUND
logluv:BOOL=ON
lzw:BOOL=ON
mdi:BOOL=ON
next:BOOL=ON
old-jpeg:BOOL=OFF
opencv_dnn_PERF_CAFFE:BOOL=OFF
opencv_dnn_PERF_CLCAFFE:BOOL=OFF
packbits:BOOL=ON
thunder:BOOL=ON
C:\tools\opencv\opencv-4.5.0-bin-win.work\opencv\build\build64>

image.png

cmake --build build64 --config Release --target install image.png

Recommended Posts

Note Book: OpenCV with CUDA Install On Windows10
Note Book: OpenBLAS Install On Windows10
Note Book: LAPACK Install On Windows 10
Note Book: VTK Install On Windows10
Note Book: OpenCV v4.5.0 with Alphamat Install On Windows10 But it need Eigen
Install Java with zip on Windows
Install Corretto 8 on Windows
Install Docker on Windows 10 PRO
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
Note: Install nginx from official repositories with dnf on CentOS 8
Install Ruby on MSYS2 with pacman
Error when npm install on Windows 7
How to install ImageMagick on Windows 10
Install ruby on Ubuntu 20.04 with rbenv
Install Java 9 on windows 10 and CentOS 7
Note Book: JVM is crash by HighGui #imshow On Windows 10 of Open JDK 11, 14, 15 and 15.01 with OpenCV. But however it's worked on OpenJDK16ea.
Install imagick on macOS Catalina + php 7.4 Note
Install Realtek network driver on Ubuntu Note
Install Java8 with Yum on Amazon Linux
Build OpenCV with Java Wrapper on Ubuntu 18.04
Install NextCloud on CentOS 7 with Alibaba Cloud ECS
Install Java 11 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
How to install NVIDIA driver on Ubuntu 18.04 (Note)
Install Java 14 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install Java 8 (OpenJDK: AdoptOpenJDK) on macOS with Homebrew
Install GitLab on CentOS 8 with no internet connection
Install Java 8 (OpenJDK: Amazon Corretto) on macOS with Homebrew
[Note] I suddenly can't build with Docker for windows.
Creating dynamic content with EC2 + RDS on Windows Server
Install Java 8 (OpenJDK: Zulu Community) on macOS with Homebrew
Install rbenv with apt on ubuntu and put ruby
I struggled with pip install on an M1 Mac