I Am trying to get certain numbers from my OCR text detector. So far I have not been able to successfully extract the numbers with a certain format. The number looks similar to this 5225 6128 3265 4455 generally, the format could be like this XXXX XXXX XXXX XXXX
I need a string match regex to get such a number. NOTE: There are other numbers from picture source I need to avoid capturing Here is the method
List<? extends Text> textComponents = text.getComponents();
for (Text currentText : textComponents) {
float left = translateX(currentText.getBoundingBox().left);
float bottom = translateY(currentText.getBoundingBox().bottom);
canvas.drawText(currentText.getValue(),left,bottom,sTectPaint);
// get certain type of text
if(currentText !=null && currentText.getValue() != null) {
if (currentText.getValue().matches("^[0-9]+(0-9]+[0-9]+[0-9]") || currentText.getValue().contains("0123456789")) {
Log.e("number", currentText.getValue());
myNum = "";
myNum = currentText.getValue();
}
}
}