OpenCV (Open Source Computer Vision Library) is a library of open-source programming functions that helps programmers develop software for real-time computer vision to analyze medical images, detect and recognize faces, stitch street view images, surveillance video, and more. This post shows you two ways to install OpenCV on Ubuntu. You can either install from the Ubuntu repository or install from the source. Either way should work for you. Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices. To get started with installing OpenCV, use the method below:

Install from Ubuntu Repository

The easiest way to install OpenCV on Ubuntu is by using the Ubuntu repository to install it. All its packages will be downloaded and installed via simple commands. To install it from the Ubuntu repository, run the commands below: Running the commands above will download and compile all required packages for OpenCV and install them. After installing, you can begin using OpenCV functions in your applications. To verify if OpenCV is installed, run the commands below: You should see similar output as below which is the version number of OpenCV installed. This is how to install OpenCV via Ubuntu default repositories.

Installing from Source

Those who want to customize OpenCV installation can install from its source. Using this method is recommended which can be tailored to particular system configurations and can give you control over how it is installed. To install from the source, run the commands below to install the required and optional packages to support OpenCV. After installing the packages above, run the commands below to create a folder for opencv_base in your home directory. Next, change into the directory and clone the OpenCV repository at Github to download the latest version. Once the download is complete, change into the ~/opencv_base/OpenCV folder and run the commands below: After running the commands above, setup OpenCV with Make by running the commands below: After the make command above, you should see similar lines as below. Next, run the commands below to complete the compilation and install OpenCV. The make -j2 command option should represent the number of CPU cores your computer has. My system has 2 processors, so I used the number 2. If yours has a higher number of processors, replace 2 with the number your system can handle. That should do it. To check whether OpenCV has been installed successfully type the following command and you should see the OpenCV version You should see similar output as below: That’s it! Conclusion: This post shows you how to install OpenCV via Ubuntu default repositories and how to install it from its source code. If you find any error above, please report it in the comment form. You may also like the post below:


title: “How To Install Opencv On Ubuntu Linux” ShowToc: true date: “2022-11-30” author: “Jon Foster”


OpenCV (Open Source Computer Vision Library) is a library of open-source programming functions that helps programmers develop software for real-time computer vision to analyze medical images, detect and recognize faces, stitch street view images, surveillance video, and more. This post shows you two ways to install OpenCV on Ubuntu. You can either install from the Ubuntu repository or install from the source. Either way should work for you. If you’re a student or new user looking for a Linux system to start learning on, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners and folks looking for easier Linux distribution to use. Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices. To get started with installing OpenCV, use the method below:

Install from Ubuntu Repository

The easiest way to install OpenCV on Ubuntu is by using the Ubuntu repository to install it. All its packages will be downloaded and installed via simple commands. To install it from the Ubuntu repository, run the commands below: Running the commands above will download and compile all required packages for OpenCV and install them. After installing, you can begin using OpenCV functions in your applications. To verify if OpenCV is installed, run the commands below: You should see similar output as below which is the version number of OpenCV installed. This is how to install OpenCV via Ubuntu default repositories.

Installing from Source

Those who want to customize OpenCV installation can install from its source. Using this method is recommended which can be tailored to particular system configurations and can give you control over how it is installed. To install from the source, run the commands below to install the required and optional packages to support OpenCV. After installing the packages above, run the commands below to create a folder for opencv_base in your home directory. Next, change into the directory and clone the OpenCV repository at Github to download the latest version. Once the download is complete, change into ~/opencv_base/opencv folder and run the commands below: After running the commands above, setup OpenCV with Make by running the commands below: After the make command above, you should see similar lines as below. Next, run the commands below to complete the compilation and install OpenCV. The make -j2 command option should represent the number of CPU cores your computer has. My system has 2 processors, so I used the number 2. If yours has a higher number of processors, replace 2 with the number your system can handle. That should do it. To check whether OpenCV has been installed successfully type the following command and you should see the OpenCV version You should see similar output as below: That’s it! Conclusion: This post shows you how to install OpenCV via Ubuntu default repositories and how to install it from its source code. If you find any error above, please report it in the comment form. You may also like the post below: