You can use a regular expression and use it to match every text line that it detects. if there is a match with your regular expression credit card number, do whatever you want. No touch required.
You can try this regex (taken from this question )
^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$
in the next method
@Override public void receiveDetections(Detector.Detections<TextBlock> detections) { mGraphicOverlay.clear(); SparseArray<TextBlock> items = detections.getDetectedItems(); for (int i = 0; i < items.size(); ++i) { TextBlock item = items.valueAt(i); if (item != null && item.getValue() != null) { List<Line> textComponents = (List<Line>) item.getComponents(); for (Line currentText : textComponents) { String text = currentText.getValue(); if (word.matches(CREDIT_CARD_PATTERN){ do your stuff here... } } } } OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item); mGraphicOverlay.add(graphic); } }
source share