1 first of all, to prepare two different versions OpenCV (such 2. . 4 .9 and 3. 1.0 ) 2 cmake- GUI provided CMAKE_INSTALL_PREFIX 2.4 . . 9 installation path: / usr / local / opencv2 3.1 . 0 installation path: / usr / loacl / opencv3 . 3 is mounted such in accordance 2. 4.9 New Build CMake - GUI .. selection CMAKE_INSTALL_PREFIX / usr / local / opencv2 --------------------------- --------- generally can not be directly written bashrc opencv environment, so we need to manually switch when you need to use opencv 2.4 .9 words, in the terminal input: Export PKG_CONFIG_PATH= $ PKG_CONFIG_PATH: / usr / local / opencv2 / lib / pkgconfig Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: / usr / local / opencv2 / lib take effect: sudo ldconfig when you need to use OpenCV 3.1 , then .0, enter in a terminal: Export PKG_CONFIG_PATH = $ PKG_CONFIG_PATH: / usr / local / opencv3 / lib / the pkgconfig Export the LD_LIBRARY_PATH = $ the LD_LIBRARY_PATH: / usr / local / opencv3 / lib . 5 CMakeLists.txt provided opencv3. 1.0 need to manually set to find opencv- config.cmake sET (CMAKE_PREFIX_PATH " / usr / local / opencv3 / report this content share / OpenCV " ) original link: HTTPS: //blog.csdn.net/u012986684/article/details/77490824 ------------------------------------- ---------------------------------- setting management under normal circumstances not directly opencv environment written bashrc, so we required to be switched manually when you need to use OpenCV 2.4 .9 words, in the terminal input: Export PKG_CONFIG_PATH = $ PKG_CONFIG_PATH: / usr / local / opencv2 / lib / the pkgconfig Export the LD_LIBRARY_PATH = $ the LD_LIBRARY_PATH: / usr / local / opencv2 / lib commencement sudo ldconfig when you need to use OpenCV 3.1 .0, then enter in a terminal: Export PKG_CONFIG_PATH = $ PKG_CONFIG_PATH: / usr / local / opencv3 / lib / pkgconfig Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: / usr / local / opencv3 / lib Original link: HTTPS: // blog.csdn.net/u012986684/article/details/77490824 ------------------------------ ----------------------- HTTPS: // blog.csdn.net/mhsszm/article/details/88558470 installed by this method has two advantages: 1 ) is in each opencv version can be switched back and forth freely, and very easy to transplant. For example, according to the above method, we have two versions of the make install opencv in different folders, such as: / Home / install / opencv- 2.4 . 10 / Build-install, / Home / install / opencv- 3.4 . 0 / Build- install now just change the ~ / .bashrc will be able to switch between the two versions. opencv3 #. 4.0 Export the PATH = / Home / oeasy / the install / opencv- 3.4 . 0/build_install/bin:$PATH export LD_LIBRARY_PATH=/home/install/opencv-3.4.0/build_install/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=/home/install/opencv-3.4.0/build_install/lib/pkgconfig #opencv2.4.10 #export PATH=/home/oeasy/opencv-2.4.10/build_install/bin:$PATH #export LD_LIBRARY_PATH=/home/install/opencv-2.4.10/build_install/lib:$LD_LIBRARY_PATH #export PKG_CONFIG_PATH=/home/install/opencv-2.4. 10 / build_install / lib / the pkgconfig after switching, Source ~ / .bashrc, enough. 2 ) very easy to transplant because opencv to compile a long time, according to the above method can be done to compile a version compiled once and can easily be deployed on more than one computer under the same platform. To a new computer, all this stuff as long as build_install folder replication. Then on the new computer corresponding ~ / .bashrc add environmental variables, ok. Opencv image is more than a google protobuf too, involves multiple versions, different versions to be switched, according to the above method may be, the available long in mind. Original link: HTTPS: // blog.csdn.net/mhsszm/article/details/88558470 ------------------------------ ---------------------------------------- sudo gedit / etc / bash.bashrc Source / etc / bash.bashrc pkg -config - cflags - libs OpenCV pkg-config --modversion opencv --------------------------------- source bin/activate cd opencv4.1.1 cd opencv-4.1.1 cd samples/cpp/example_cmake cmake . ---------------------------- g++ deep_sort_app.cpp -o deep_sort_111 `pkg-config --cflags --libs opencv` ============================================= 安装OPENCV wget -O opencv_contrib.zip https://github.com/Itseez/opencv/archive/3.4.2.zip wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.2.zip after decompression opencv_contrib- 3.4 .1 mobile channel opencv- 3.4 at .1 document directory; enter OpenCV - 3.4 .1 document, external compilation mode, enter the following Code: mkdir Build; CD Build; key is cmake code, because you ubuntu system configuration varies, and therefore the following more generic code may be used: cmake -D = CMAKE_BUILD_TYPE the RELEASE \ -DCMAKE_INSTALL_PREFIX = / usr / local / \ - = DINSTALL_PYTHON_EXAMPLES the ON \ -DINSTALL_C_EXAMPLES = the ON \ -DPYTHON_EXCUTABLE = / usr / bin / Python \ -DOPENCV_EXTRA_MODULES_PATH = / Home / LXY / OpenCV / opencv- 3.4 . 2 / opencv_contrib- 3.4 . 2/modules \ (3.1)创建build文件夹 mkdir build cd build (3.2)cmake一下 #cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. #cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=~/opencv-3.4.2/build/installed -DWITH_CUDA=OFF .. (建立opencv-3.4.2/build/installed这几个文件夹) cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3.4.2 -D OPENCV_EXTRA_MODULES_PATH=/home/u/opencv-3.4.2/opencv_contrib-3.4 . 2 / modules .. Note: If you have already compiled in a new folder, but the error will appear before, and then delete the cmakecache.txt compiler can not error, continue. . . ( 3.3 ) at the make sudo make after sudo make install # completes OpenCV compilation process is over ( 3.4 compiler environment) to configure some of OpenCV first step: the system environment 1 . First add the path to the OpenCV library, which allows the system to find : the sudo the gedit /etc/ld.so.conf.d/ opencv.conf 2 . added just at the end of the file: / usr / local / lib . 3 . configured such that the path just takes effect: the sudo the ldconfig Step Two: configure the bash . 1 open bash.bashrc the sudo the gedit /etc/bash.bashrc the sudo the gedit ~ # / .bashrc 2 . at the end of adding the most #@多版本OpenCV切换 https://blog.csdn.net/learning_tortosie/article/details/80594399 #export PKG_CONFIG_PATH=~/opencv-3.4.1/build/installed/lib/pkgconfig #export LD_LIBRARY_PATH=~/opencv-3.4.1/build/installed/lib export PKG_CONFIG_PATH=/usr/local/opencv3.4.2/lib/pkgconfig export LD_LIBRARY_PATH=/usr/local/opencv3.4.2/lib 3.使配置生效 source /etc/bash.bashrc # source ~/.bashrc (3.5)查询OpenCV版本 pkg-config --modversion opencv # 3. If the output 4.2 , it indicates that the configuration is successful. If the preceding is not an error, the output is not 3. 4.2 , may not be configured to take effect, restart the computer pkg -config OpenCV - modversion ======================== ================== solve pip install third-party packages appear socket.timeout: The read operation timed out timeout issues PIP3 install OpenCV -contrib-== Python 3.4 . 5.20 PIP3 - - default -timeout = 100 the install-contrib-OpenCV Python == 3.4 . 5.20