Do you like this article? Share it with this link. Thanks!
Install OpenCV on Ubuntu or Debian is a bit long but very easy. You can install OpenCV from the Ubuntu or Debian repository or from the official site.
You can install OpenCV from the Ubuntu or Debian repository: sudo apt-get install libopencv-dev python3-opencv
. However, you will probably not have installed the latest version of OpenCV and you may miss some features.
To install the latest version of OpenCV be sure that you have removed the library from the repository with sudo apt-get autoremove libopencv-dev python-opencv
and follow the steps below.
The most simple and elegant way to install a library is running an installation script.
Download the installation script install-opencv.sh, open your terminal and execute:
bash install-opencv.sh
Type your sudo password and you will have installed OpenCV. This operation may take a long time due to the packages to be installed and the compilation process.
Go to your OpenCV directory and execute a C++ example:
cd build/bin
./example_cpp_edge ../../samples/data/fruits.jpg
Now, go to your OpenCV directory and execute a Python example:
cd samples/python
python3 video.py
Finally, go to your OpenCV directory and execute a Java example:
cd samples/java/ant
ant -DocvJarDir=../../../build/bin -DocvLibDir=../../../build/lib
Download the files demo.cpp and CMakeLists.txt and put them into a folder. Now, open your terminal, go to the folder and execute:
mkdir build && cd build && cmake .. && make
Finally, run the demo: ./demo
.
And that's it! You have installed OpenCV, run some examples, and compiled OpenCV code!
Do you like this article? Share it with this link. Thanks!