I am working on a project that scans text on a product(ex. a lays packet) using the Google ML kit.
So, the Text Recognition API is already implemented in the ML kit, all I need to do is use methods to process the image, and display text.
But the purpose is to display just the name of the product, and the price of the product. So I have a code that runs well, and displays all the text, but I need to filter it.
I have managed to display the price by writing a code to search for strings like “Rs.”, or “MRP”, in the recognized text. It works well. The piece of code:
val textTaskResult = textRecognizer.process(inputImage)
.addOnSuccessListener {text ->
//process completed, dismiss dialog
progressDialog.dismiss()
//get the recognized text
val recognizedText = text.text
//set the recognized text to edit text
val strl = recognizedText.split("n").toTypedArray()
for(x in strl) {
if (x.contains("Rs")) {
recognizedTextEt.setText(x)
}
}
When it comes to displaying the product name, assuming the product name is usually the biggest block of text in most cases, I was able to implement this. But there are cases when the brand name is the biggest block. Please help me figure out a method/logic to handle it in such cases.
I am using Kotlin and building the project on Android Studio.