是的,但是要安装它,您需要
多亏了Satya Mallik和Opencv.org,他们编写了定制的bash脚本,无需任何hasel即可安装OpenCV。我们将在这个博客中添加更多内容。
>> wget https://raw.githubusercontent.com/spmallick/learnopencv/master/InstallScripts/installOpenCV-4-on-Ubuntu-18-04.sh
坐好,放松就行了。请查看日志,以防出现任何错误。
好了!您已成功安装OpenCV。
可选:
您可以自定义OpenCV安装。
2.CUDA/无CUDA安装:您可以在OpenCV中找到需要的有用参数,以便根据您的需求进行更好、更优化的编译。在这里找到名单。OpenCV CMakeList和文档。Opencv CMakeList Documentation
对于CUDA支持:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX= $cwd/installation/OpenCV-"$cvVersion" \
-D WITH_TBB=ON \
-D ENABLE_FAST_MATH=1 \
-D CUDA_FAST_MATH=1 \
-D WITH_CUBLAS=1 \
-D WITH_CUDA=ON \
-D BUILD_opencv_cudacodec=OFF \
-D WITH_CUDNN=ON \
-D OPENCV_DNN_CUDA=ON \
-D CUDA_ARCH_BIN=7.5 \
-D WITH_V4L=ON \
-D WITH_QT=OFF \
-D WITH_OPENGL=ON \
-D WITH_GSTREAMER=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D OPENCV_PC_FILE_NAME=opencv.pc \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_PYTHON3_INSTALL_PATH= $cwd/OpenCV-$cvVersion-py3/lib/python3.6/site-packages \
-D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
-D OPENCV_EXTRA_MODULES_PATH= ../../opencv_contrib/modules \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_EXAMPLES=OFF ..
对于非CUDA支持:
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=$cwd/installation/OpenCV-"$cvVersion" \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D WITH_TBB=ON \
-D WITH_V4L=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=$cwd/OpenCV-$cvVersion-py3/lib/python3.6/site-packages \
-D WITH_QT=ON \
-D WITH_OPENGL=ON \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ..
示例:
现在,让我们来谈谈如何与项目集成。了解这一点非常重要。我发现在OpenCV版本管理中很难获得任何有用的资源。
cmake_minimum_required(VERSION 3.1)
project( DisplayImage )
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# For OpenCV 4
SET(OpenCV_DIR /OpenCV-master/lib/cmake/opencv4)
# For OpenCV 3
# SET(OpenCV_DIR "/opencv3.4.8/installation/OpenCV-3.4.8/share/OpenCV/")
# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( DisplayImage main.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
尝试编译并验证安装过程。
# runall.sh script
cmake -S . -B out/build;
cd out/build;
make;
./example
在此处查找我的回购:https://github.com/sauravsolanki/opencv-installationhttps://github.com/sauravsolanki/opencv-installation
参考文献:
原创文章,作者:fendouai,如若转载,请注明出处:https://panchuang.net/2021/07/13/%e5%9c%a82%e4%b8%aaloc%e4%b8%ad%e5%ae%89%e8%a3%85opencv%ef%bc%81/