Yaron Vazana

NLP, Algorithms, Machine Learning, Data Science, tutorials, tips and more

  • About
  • Blog
  • Projects
  • Medium

Contact Me

yaronv99 [at] gmail.com

Powered by Genesis

You are here: Home / Android / Android Text Detection Using OpenCV

Android Text Detection Using OpenCV

February 2, 2016 by Yaron 38 Comments

Mobile devices have improved significantly over the past years. They are now capable of running intensive CPU tasks like image processing and object detection algorithms, perform mathematic calculations and even handle a large amount of data efficiently.

In this project I’m going explain how to use the OpenCV library in your android app, and implement a real time text detection algorithm using  the rear phone camera. I will use the OpenCV MSER algorithm which is used to detect points of interest inside an image.

android-text-recognition

OpenCV for Android

For installing OpenCV in your android app please refer to my previous article

MSER

MSER, Maximally Stable Extremal Regions, is an algorithm used for blob detection inside an image. MSER is based on the idea of taking regions which stay nearly the same through a wide range of thresholds. This algorithm is considered to be one of the fastest region detectors which makes it a good choice for mobile devices.

Why is it Good For Text Detection?

  • MSER tends to detect many small regions
  • MSER performs best (among other detectors) in light changed scene
  • MSER gives good results when we scale the image (moving closer to the subject)

The Layout

I start by setting a JavaCameraView object instance inside my layout file

The Fragment

Since I use a fragment, my fragment Class implements the Camera View Listener as follows, I also bind the instance and the listener inside the OnCreateView Method

Text Detection Implementation

MSER algorithm runs on a grayscale image, so I create a grayscale image from my original image and apply the FeatureDetector.MSER in order to find all the keypoints inside the image. I loop this process on each frame that I get from the video stream and then draw a red rectangle around each key point.

Conclusion

This example can be the basic for many other projects using android text detection. On older devices I found it to be working not as smooth as I expected. OpenCV 3.0 brings us a new dedicated Algorithm  Class-specific Extremal Regions used for text detection.

You can find the full source code here

Subscribe to Blog

Subscribe to get the latest posts to your inbox

Cheers

Filed Under: Android, Mobile Tagged With: Android, Apps, Material Design, Mobile, Open CV, Video

I am a data science team lead at Darrow and NLP enthusiastic. My interests range from machine learning modeling to solving challenging data related problems. I believe sharing ideas is where we all become better in what we do. If you’d like to get in touch, feel free to say hello through any of the social platforms. More About Yaron…

SUBSCRIBE TO BLOG

Subscribe to Blog

Subscribe to get the latest posts to your inbox

Recent Posts

  • Training an AutoEncoder to Generate Text Embeddings
  • Using Dockers for your Data Science Dev Environment
  • Identifying Real Estate Opportunities using Machine Learning
  • How to Create a Simple WhatsApp Chatbot in Python using Doc2vec
  • Average Word Vectors – Generate Document / Paragraph / Sentence Embeddings
  • Visualizing Vectors using TensorBoard
  • Training a Doc2Vec Model with Gensim
 

Loading Comments...