Locate OpenCV:
1 | pkg-config --modversion opencv //version |
Uninstall OpenCV:
- go to the compile package and
make uninstall
- if cannot find the compile package,
sudo find / -name "*opencv*" -exec rm -i {} \;
Install OpenCV:
For Windows: C++(Visual Studio)
- Download latest OpenCV from http://sourceforge.net/projects/opencvlibrary/?source=typ_redirect.
- Make a dir named build. Use cmake to generate OpenCV.sln in build.
- Click OpenCV.sln and CMakeTargets->INSTALL->build. You can build it in both debug and release modes.
- In the environmental variables, add D:\Program Files\OpenCV_3.0.0\build\install\x64\vc11 as OPENCV_DIR, add Path with %OPENCV_DIR%\bin.
- Create a OpenCV project. C/C++->General->Additional Include Directories: $(OPENCV_DIR)\..\..\include
- Linker->General->Additional Library Directories: $(OPENCV_DIR)\lib
- Linker->Input->Additional Dependencies: copy all the lib files. *d.lib means debug mode.
Note that there may be some problems for visual studio to recognize the updated environmental variable. Try to restart the visual studio or recreate the project.
For Linux: install for C++
- pre-install packages
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev - download the required version on https://sourceforge.net/projects/opencvlibrary/
- make and install
1
2
3
4
5mkdir build
cd build
cmake .. //cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install
Tips: if you want to install multiple versions of OpenCV, set CMAKE_INSTALL_PREFIX differently for different versions of OpenCV.
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D PYTHON_EXECUTABLE=/usr/bin/python \
-D BUILD_EXAMPLES=ON ..
If want to turn off some modules, use -D BUILD_opencv_xfeatures2d=OFF
Switch between different versions of OpenCV:
switch from version 3.2 to version 2.4 shell
switch from version 2.4 to version 3.2 shell
For Linux: Python(Anaconda)
source activate tgt_env
conda install -c https://conda.binstar.org/menpo opencv
spyder
Then try import cv2