Git Product home page Git Product logo

mlkittextrecognize's Introduction

MLKitTextRecognize

App will:

Utilize the ML Kit Text Recognition API to detect text in images.

You'll learn:

How we can use Firebase ML Kit SDK in Android with Machine learning capability.

     private fun runTextRecognition() {
        val image = mSelectedImage?.let { FirebaseVisionImage.fromBitmap(it) }
        val detector = FirebaseVision.getInstance().visionTextDetector
        button_text.isEnabled = false
        image?.let {
            detector.detectInImage(it)
                    .addOnSuccessListener {
                        button_text.isEnabled = true
                        processTextRecognitionResult(it)
                    }
                    .addOnFailureListener {
                        button_text.isEnabled = true
                        showToast(it.localizedMessage)
                    }
        }


     }
  • Get texts elements result from FirebaseVisionText :
     private fun processTextRecognitionResult(firebaseVisionText: FirebaseVisionText?) {
        firebaseVisionText?.let {
            val blocks = firebaseVisionText.blocks
            when (blocks.size) {
                0 -> showToast("No texts found")
                else -> {
                    graphic_overlay.clear()
                    for (block in blocks.indices) {
                        val lines = blocks[block].lines
                        for (line in lines.indices) {
                            val elements = lines[line].elements
                            for (element in elements.indices) {
                                val textGraphic = TextGraphic(graphic_overlay, elements[element])
                                graphic_overlay.add(textGraphic)
                            }
                        }
                    }
                }
            }
        }
     }

Output:

Image One result Image Two result Image Three result

NOTE:

To successfully sync this project, need to set up this app into your Firebase project. Kindly follow below link to "Add Firebase to Your Android Project": https://firebase.google.com/docs/android/setup

References:

Built With

  • Android Studio - The Official IDE for Android
  • Kotlin - The Official Language for Android ❤️
  • Gradle - Build tool for Android Studio

Pull Requests

I welcome and encourage all pull requests to learn something new.

Find this project useful ? ❤️

Support it by clicking the ⭐️ button on the upper right of this page. ✌️

Images credits

https://unsplash.com/

mlkittextrecognize's People

Contributors

pranaypatel512 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.