Tuesday, 11 January 2022

how to process the text returned by firebase ML text recognition

I am using the firebase ML vision to read RC details from the image.

implementation "com.google.android.gms:play-services-mlkit-text-recognition:17.0.1"


private fun Activity.recognizeText(imageSting: String) {
    var image: InputImage? = null
    try {
        image = InputImage.fromFilePath(getContext(), Uri.fromFile(File(imageSting)))
    } catch (e: IOException) {
        e.printStackTrace()
    }
    // [START get_detector_default]
    val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
    // [END get_detector_default]

    // [START run_detector]
    val result = recognizer.process(image)
        .addOnSuccessListener { visionText ->
           processTextBlock(visionText)
       
        }
        .addOnFailureListener { e ->
          
            Log.d("test", e.localizedMessage);
        }
}

it works fine and text is returned successfully.

enter image description here

list of data is returened with cornerPoints and boundingBox how map data correclty .. ex- Reg. No. with actual value

Government of 1Tamil Nadu
Certificate of Registration
O
Reg. No.
Date of Reg.
TNO6P7094
30-06-2015
Reg. Valid Till
29-06-2030
Chassis No.
ME4JF504FFT459059
Engine No.
JF50ET 2460128
Owner
02
Sr. No.
Owner Name
NIKIL KUMAR ROY
Fuel Used
PETROL
Son/Daughter/Wife of
MANIK ROY
Address
NO 456/HPTRAILWAY
COLONY 4TH STREET
AYANAVARAM Chennai TN 600023


from how to process the text returned by firebase ML text recognition

No comments:

Post a Comment