Debian || Ubuntu編譯安裝OpenCV(Only C++ without Python!)

Debian源碼編譯安裝OpenCV C++版本

Only compile opencv c++, without python and java.

  • first step: install dependency.

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev qtbase5-dev libtiff-dev

  • second step: download opencv source code.

In Linux operate system, you can use this command line: wget https://github.com/opencv/opencv/archive/4.1.0.zip, or use git clone https://github.com/opencv/opencv.git

  • third step

Entire the opencv source code directory and make a directory build, and you can also use another name, it’s no matter.

  • forth step: without build python and java model

In CMakeLists.txt file, delete the python model and java model.
Delete python model
Delete Java Model
Entire the directory that you made just a minute ago, and in this directory, execute the following command:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=~/${your_directory}
I suggest the CMAKE_INSTALL_PREFIX opencv in a directory that you want to install and don’t use : /usr/local directory, because if you want to uninstall this version of opencv, you can only delete the directory that you installed opencv.
In this blog, I use the following command to install OpenCV in my laptop:

  • cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/home/wangheng/app/opencv4
    Maybe you want to install with CUDA or CUDNN, you can add the string: -D WITH_CUDA=ON and so on.
    在這裏插入圖片描述
  • finally make -j2 ; make install
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章