TheJadav

How to add opencv in android studio

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library

OpenCV

OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code.

Why OpenCV

OpenCV have too many use cases, like image processing, face recognition, and other too. But I am using it here for image processing.

Add OpenCV library

OpenCV library can not be imported with build.gradle implementation url. The are providing source code or module project to us, which we need to add in our application.

I have tried regular method to import it like File -> New -> Import Module, but It is not showing Next or Finish button. Before we go further, if you have not downloaded module file then please visit https://opencv.org/releases/  and download it for android.

You will get zip file, extract it and navigate copy sdk folder in your projects root directory.

Make it module

To make sdk folder as module, we need to modify settings.gradle file. Append below line in file and wait for sync

include ':app' , ':opencv'

Now we can see sdk folder as module folder. So we can add module dependency to our app module and use openCV in our module.

To add module dependency we can right-click on project name -> Open Module Settings -> Dependencies

Share this content:

Share:

More Posts

How does data persistence work in Android?

Data persistence in Android is the ability to save data to the device so that it can be accessed later, even if the app is closed or the device is restarted. There are several ways to achieve data persistence in Android

Fragments and Activities: Two Pillars of Android Development

Fragments and Activities are both important components of Android development. Fragments are a good choice for creating reusable and dynamic UIs, while Activities are a good choice for managing the lifecycle of an app’s UI and implementing core features.

Table of Contents

Send Us A Message