This tutorial guides Android developers in preparing the popular library OpenCV (Open Computer Vision) for use. Through a step-by-step guide, the library will be imported into Android Studio (the official IDE for Android).

Upon installation and setup, OpenCV can be used for performing any of the operations it supports, such as object detection, segmentation, tracking, and more.

At the end of this tutorial, OpenCV is used to apply the Canny filter to an image. The Android Studio project associated with this is available on GitHub here:

ahmedfgad/OpenCVAndroid

Using OpenCV in Android Devices. Contribute to ahmedfgad/OpenCVAndroid development by creating an account on GitHub.

Overview of OpenCV

OpenCV is a vision library built for doing complex, real-time operations on images. It is a free, open source library originally written in C++. It includes interfaces with Python, Java, and MATLAB. With no need to write many lines of code to build an operation, OpenCV already supports building such operations with a simple interface, where the user can write just a few lines of code.

Before discussing importing OpenCV into and Android project, let’s start by building an Android project and make sure that the Android development environment is working as expected.

The points that will be covered in this tutorial are as follows:

  • Building an Android Studio Project
  • Running the Project
  • Editing the Project to Display a Toast Message
  • Downloading OpenCV
  • Importing OpenCV in Android Studio
  • Fixing Possible Gradle Sync Errors
  • Adding OpenCV as a Dependency
  • Adding Native Libraries
  • Using OpenCV for Filtering Images
  • Summary

Building an Android Studio Project

Let’s go through the steps of building a new Android Studio project. The first is to create a new project from the File menu as illustrated in the next figure.

Image for post

By selecting the “New Project” menu item, a new window appears asking for a few details (e.g. app name and project directory). The app name we’ll used for this tutorial is OpenCVAndroid.

Image for post

#2020 oct tutorials # overviews #android #computer vision #java #opencv

A Guide to Preparing OpenCV for Android
1.90 GEEK