Skip to content

Instantly share code, notes, and snippets.

@prakashpun
Last active December 30, 2017 16:10
Show Gist options
  • Save prakashpun/1c2f91a8bdf1d638f6b595bb9addc740 to your computer and use it in GitHub Desktop.
Save prakashpun/1c2f91a8bdf1d638f6b595bb9addc740 to your computer and use it in GitHub Desktop.
Set the TextRecognizer's Processor.
textRecognizer.setProcessor(new Detector.Processor<TextBlock>() {
@Override
public void release() {
}
/**
* Detect all the text from camera using TextBlock and the save values into a stringBuilder
* which will then be set to the textView.
* */
@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
final SparseArray<TextBlock> items = detections.getDetectedItems();
if (items.size() != 0 ){
mTextView.post(new Runnable() {
@Override
public void run() {
StringBuilder stringBuilder = new StringBuilder();
for(int i=0;i<items.size();i++){
TextBlock item = items.valueAt(i);
stringBuilder.append(item.getValue());
stringBuilder.append("\n");
}
// set the stringBuilder value to textView
mTextView.setText(stringBuilder.toString());
}
});
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment