Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I could't Customize OpencvSharp (including CUDA) #1299

Closed
JH2305 opened this issue Aug 3, 2021 · 1 comment
Closed

I could't Customize OpencvSharp (including CUDA) #1299

JH2305 opened this issue Aug 3, 2021 · 1 comment
Labels

Comments

@JH2305
Copy link

JH2305 commented Aug 3, 2021

Summary of your issue

I want to use CUDA libraries in opencv, so i tried to make customized opencvsharp.

Customizing Opencvsharp Step is here;

  1. prepare Opencv_files (download : opencv453 + opencv_contrib453)

  2. Edit build_windows.ps1 file (added WITH_CUDA = ON)
    function BuildForWindows($platform, $vcpkgPath, $runMsbuild) {
    #$ErrorActionPreference = "Stop"
    $buildDirectory = "build_win_${platform}"
    mkdir $buildDirectory -Force -ErrorAction Stop | Out-Null
    cd $buildDirectory
    pwd
    if ($platform -eq "x64") {
    $msbuildPlatform = "x64"
    $msmfFlag = "ON"
    } else {
    $msbuildPlatform = "Win32"
    $msmfFlag = "OFF" # opencv_videoio430.lib(cap_msmf.obj) : error LNK2001: unresolved external symbol _MFVideoFormat_H263
    }
    cmake -G "Visual Studio 16 2019" -A $msbuildPlatform
    -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=install
    -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=OFF
    -D BUILD_ANDROID_PROJECTS=OFF -D BUILD_ANDROID_EXAMPLES=OFF
    -D BUILD_DOCS=OFF -D BUILD_WITH_DEBUG_INFO=OFF
    -D BUILD_EXAMPLES=OFF -D BUILD_TESTS=OFF
    -D BUILD_PERF_TESTS=OFF -D BUILD_JAVA=OFF
    -D BUILD_opencv_apps=OFF -D BUILD_opencv_datasets=OFF
    -D BUILD_opencv_freetype=OFF -D BUILD_opencv_gapi=OFF
    -D BUILD_opencv_java_bindings_generator=OFF -D BUILD_opencv_js=OFF
    -D BUILD_opencv_js_bindings_generator=OFF -D BUILD_opencv_objc_bindings_generator=OFF
    -D BUILD_opencv_python_bindings_generator=OFF -D BUILD_opencv_python_tests=OFF
    -D BUILD_opencv_ts=OFF -D BUILD_opencv_world=OFF
    -D WITH_MSMF=${msmfFlag} -D WITH_MSMF_DXVA=${msmfFlag}
    -D WITH_QT=OFF -D WITH_FREETYPE=OFF
    -D WITH_TESSERACT=OFF -D WITH_CUDA=ON
    -D Tesseract_INCLUDE_DIR="${vcpkgPath}/installed/${platform}-windows-static/include" -D Tesseract_LIBRARY="${vcpkgPath}/installed/${platform}-windows-static/lib/tesseract41.lib"
    -D Lept_LIBRARY="${vcpkgPath}/installed/${platform}-windows-static/lib/leptonica-1.78.0.lib" -D ENABLE_CXX11=1
    -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules
    -D BUILD_SHARED_LIBS=OFF ../opencv

    if ($runMsbuild) {
    # Developer Powershell for VS 2019
    # Path: C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -noe -c "&{Import-Module """C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"""; Enter-VsDevShell cebe9bd5}"
    # WorkDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\

     msbuild INSTALL.vcxproj /t:build /p:configuration=Release /p:platform=$msbuildPlatform -maxcpucount
     ls
    

    }

    cd ..
    }...~~~

  3. Run the PowerShell script

  4. build OpenCV.sln (ALLBUILD -> INSTALL)

  5. move generated files(in install folder) to opencvsharp\opencv_files\opencv453_win_x64

  6. open OpenCvSharp.sln and configure the project
    -> change project build setting to x64, Release
    -> OpenCvSharpExtern properties - C/C++ - include : ...\opencv_files\opencv453_win_x64\include
    -> OpenCvSharpExtern properties - Linker - Additional library directories :
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\lib\x64;
    ...\opencv_files\opencv453_win_x64\x64\vc16\staticlib
    -> OpenCvSharpExtern properties - Linker - additional dependencies : IlmImf.lib;ippicvmt.lib;ippiw.lib;ittnotify.lib;libjpeg-turbo.lib;libopenjp2.lib;libpng.lib;libprotobuf.lib;libtiff.lib;libwebp.lib;opencv_aruco453.lib;opencv_barcode453.lib;opencv_bgsegm453.lib;opencv_bioinspired453.lib;opencv_calib3d453.lib;opencv_ccalib453.lib;opencv_core453.lib;opencv_cudaarithm453.lib;opencv_cudabgsegm453.lib;opencv_cudacodec453.lib;opencv_cudafeatures2d453.lib;opencv_cudafilters453.lib;opencv_cudaimgproc453.lib;opencv_cudalegacy453.lib;opencv_cudaobjdetect453.lib;opencv_cudaoptflow453.lib;opencv_cudastereo453.lib;opencv_cudawarping453.lib;opencv_cudev453.lib;opencv_dnn_objdetect453.lib;opencv_dnn_superres453.lib;opencv_dnn453.lib;opencv_dpm453.lib;opencv_face453.lib;opencv_features2d453.lib;opencv_flann453.lib;opencv_fuzzy453.lib;opencv_hfs453.lib;opencv_highgui453.lib;opencv_img_hash453.lib;opencv_imgcodecs453.lib;opencv_imgproc453.lib;opencv_intensity_transform453.lib;opencv_line_descriptor453.lib;opencv_mcc453.lib;opencv_ml453.lib;opencv_objdetect453.lib;opencv_optflow453.lib;opencv_phase_unwrapping453.lib;opencv_photo453.lib;opencv_plot453.lib;opencv_quality453.lib;opencv_rapid453.lib;opencv_reg453.lib;opencv_rgbd453.lib;opencv_saliency453.lib;opencv_shape453.lib;opencv_stereo453.lib;opencv_stitching453.lib;opencv_structured_light453.lib;opencv_superres453.lib;opencv_surface_matching453.lib;opencv_text453.lib;opencv_tracking453.lib;opencv_video453.lib;opencv_videoio453.lib;opencv_videostab453.lib;opencv_wechat_qrcode453.lib;opencv_xfeatures2d453.lib;opencv_ximgproc453.lib;opencv_xobjdetect453.lib;opencv_xphoto453.lib;quirc.lib;zlib.lib;cublas.lib;cublasLt.lib;cuda.lib;cudadevrt.lib;cudart.lib;cudart_static.lib;cudnn.lib;cudnn_adv_infer.lib;cudnn_adv_infer64_8.lib;cudnn_adv_train.lib;cudnn_adv_train64_8.lib;cudnn_cnn_infer.lib;cudnn_cnn_infer64_8.lib;cudnn_cnn_train.lib;cudnn_cnn_train64_8.lib;cudnn_ops_infer.lib;cudnn_ops_infer64_8.lib;cudnn_ops_train.lib;cudnn_ops_train64_8.lib;cudnn64_8.lib;cufft.lib;cufftw.lib;curand.lib;cusolver.lib;cusolverMg.lib;cusparse.lib;nppc.lib;nppial.lib;nppicc.lib;nppidei.lib;nppif.lib;nppig.lib;nppim.lib;nppist.lib;nppisu.lib;nppitc.lib;npps.lib;nvblas.lib;nvcuvid.lib;nvencodeapi.lib;nvjpeg.lib;nvml.lib;nvptxcompiler_static.lib;nvrtc.lib;OpenCL.lib;%(AdditionalDependencies)

  7. build OpenCvSharpExtern project

  8. build OpenCvSharp project

  9. result
    -> OpenCvSharpExtern.dll : 877MB
    -> OpenCvSharp.dll : 908KB

  10. I replaced these .dlls to my developing project's nuget package's .dlls

  11. When I rebuild the project, i can import new dll.
    -> but opencvsharp.CUDA is not visible

Environment

Visual Studio 2019 16.10.2
.net framework 4.6.1
OpencvSharp 4.5.3
Opencv 4.5.3
Opencv_Contrib 4.5.3
CUDA 11.1
CUDNN 8.0.4.30

What did you do when you faced the problem?

I typed above

Example code:

not included

Output:

not included

What did you intend to be?

I want to generate Opencvsharp Dlls including CUDA.
Is there something missing?

@stale
Copy link

stale bot commented Jan 31, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 31, 2022
@stale stale bot closed this as completed Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant