OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it integrated with various libraries, such as Numpy, python is capable of processing the OpenCV array structure for analysis. To Identify image patterns and their various features we use vector space and perform mathematical operations on these features.
OpenCV is a library used for real-time image processing through a camera. It is used to do various image processing operations like image capturing, applying real-time filters like Snapchat and Instagram, cropping of images and many more.
Applications of OpenCV
There are lots of applications that are solved using OpenCV, some of them are listed below
- face recognition
- Automated inspection and surveillance
- number of people – count (foot traffic in a mall, etc)
- Vehicle counting on highways along with their speeds
- Interactive art installations
- Anomaly (defect) detection in the manufacturing process (the odd defective products)
- Street view image stitching
- Video/image search and retrieval
- Image/video I/O, processing, display (core, imgproc, highgui)
- Object/feature detection (objdetect, features2d, nonfree)
- Geometry-based monocular or stereo computer vision (calib3d, stitching, videostab)
- Computational photography (photo, video, superres)
- Machine learning & clustering (ml, flann)
- CUDA acceleration (GPU)
Steps Required to Add OpenCV library into Android Application
Here are the steps required to perform in the same way to add OpenCV library:
- First of all, go to the official website of OpenCV i.e https://opencv.org/releases/ here you will see various releases with the version name mention above it. You need to download the same version of OpenCV as your android studio version.
- Here download the android package you will see the android package option there as shown in the image below:
- Just click on the android option there and you will be redirected to the page where the download will start automatically.
- After downloading the android package with the version same as with your android studio you have to extract the zip folder to your desired location.
- Now open Android Studio and create a new project.
- After creating a new project go to File > New > Import-Module
- Now click on Import-Module as you will see a dialog box like below:
- Now, import the module of OpenCV. So open the location where you extracted the OpenCV library so go to that location. In this case download location was This PC > downloads.
- Then go to SDK
- Then click on java
- Go to the location > OpenCV > SDK >java and done, the android studio will automatically fetch the module from there.
- Click on Next > finish. Now you have to modify the project structure also.
- So go to File > Project Structure > Dependencies in All Dependencies folder click on the + icon then add the module dependency.
- Click on the app and then select the OpenCV dependency and then next then OK.
- Now, some files are needed for the android project.
- So go to app > New > folder > JNI folder
- Then check the Change Folder Location then rename src/main/JNI to src/main/jniLibs then finish.
- Then go to the android studio and the paste all the copied folder into the newly created JNI folder. And all done!
Now OpenCV is added into the android project. If one wants to check that whether it is added successfully he/she can do this by writing the below code into the MainActivity.
Log.d(“Check”,”OpenCv configured successfully”);
Log.d(“Check”,”OpenCv doesn’t configured successfully”);