androidkotlinimage-processinggoogle-mlkittext-recognition

How to get a single digit number text position in an image in android?


I am trying to get the number text position from the following transparent image,

Simple image with numbers

But I can't seem to find a solution online. I tried using google's mlkit text recognizer, but it cannot recognise single digits in the image,

    fun getPointFromBitmap(){
        val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
        val image = InputImage.fromBitmap(mBitmap, 0)

        recognizer.process(image)
            .addOnSuccessListener { visionText ->
                for (i in 0 until visionText.textBlocks.size) {
                    Log.v(
                        "LP",
                        "text ${visionText.textBlocks[i].text} boundingBox  ${visionText.textBlocks[i].boundingBox} ponts  ${visionText.textBlocks[i].cornerPoints}"
                    )

                }
            }
            .addOnFailureListener { e ->
                Log.e(
                    "LPError", "${e.message}"
                )
            }
    }

Solution

  • In the upcoming release of ML Kit (early August) we are providing an update to the Text Recognition API. This will also support detection of individual digits as seen in the screenshot below.

    Single digit detections