1 year ago
#252768
hypertensiune
MLKIT Text recognition not getting all the numbers ( single digit ) from image
I am trying to get a sudoku board from an image using MLKIT Text Recognition but not all numbers are getting recognized.
I thought the lines may interfere with the detection so I removed all the lines ( using the 1st solution from How to remove all lines and borders in an image while keeping text programmatically?) but still numbers are not recognized well.
Does MLKIT have difficulties in recognizing single digit numbers or I am doing something wrong?
This is the code that I'm using:
public static void recognizeTextFromImage(Mat mRGBA){
Bitmap bitmapImage = Bitmap.createBitmap(mRGBA.cols(), mRGBA.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(mRGBA, bitmapImage);
InputImage inImg = InputImage.fromBitmap(bitmapImage, 0);
Task<Text> result = textRecognizer.process(inImg)
.addOnSuccessListener(new OnSuccessListener<Text>() {
@Override
public void onSuccess(Text text) {
Log.e("MLKIT", "Task success");
for(Text.TextBlock block: text.getTextBlocks()){
String blockText = block.getText();
for(Text.Line line: block.getLines()){
for(Text.Element element: line.getElements()){
String elText = element.getText();
android.graphics.Rect rect = element.getBoundingBox();
Log.e("MLKIT", elText);
Imgproc.rectangle(mRGBA, new Point(rect.left, rect.top), new Point(rect.right, rect.bottom), new Scalar(255, 0, 255 ), 1, Imgproc.LINE_AA);
}
}
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.e("MLKIT", "Task fail");
}
});
}
android
google-mlkit
text-recognition
0 Answers
Your Answer