Steps involved in installing OpenCV in Ubuntu are discussed in this article OpenCV is among the best platforms which provides ease to developers in their work. The latest version which is being used nowadays is 4.5.3 released on 17th of July, 2021. It is in C++ but it can be used in other languages with the help of bindings. Here we will discuss about two methods to install OpenCV in Ubuntu either from its own repository or by downloading it from source.
Method 1: Install OpenCV from Default Repository
We can install OpenCV from its own repository and the steps involved in it are discussed. Step 1: First we will update the repository: Step 2: We will install the OpenCV library and python library from the repository by using a single command: Step 3: Installation is verified by checking the version of OpenCV by using the “cv2 module”: In the output it will display the version of the OpenCV.
Method 2: Install OpenCV using Source Code
We can install OpenCV from its original source as well. For this purpose, we have to follow the following steps. Step 1: First we install the files which are necessary for the installation of the OpenCV and for this purpose we install the build tool: Step 2: Now first make the directory using “mkdir” and then clone the OpenCV and OpenCV contribution repository.Clone both of them from the website of github.com: Step 3: We will navigate the file and make a directory there using “mkdir”: Now we will configure and setup the OpenCV build by using “make”: Step 4: Now we should know the number of cores of processor, we can find them out by: In my case it has one core. So now, we start the compilation process by using make command but we will enter the number of cores of the processor with “j” for example in my case I have one core so I’ll write “j1”, likewise if you have 8 cores of processor you can write j8. It will take some time to compile. Step 5: Start the installation setup: To verify the installation of OpenCV we will check the versions of C++ and Python bindings. Similarly, check the version of OpenVC python library.
To Conclude
Instead of spending a lot of time developing code for algorithms, developers use the algorithm from the OpenCV library. It not only provides ease in their job but also saves a lot of time. In this article, we have discussed different methods to install OpenCV either from its repository or from the original source. To download it from its own repository is a little bit fast but from the original source is more reliable as it can access all the latest versions of libraries.