Skip to content

Instantly share code, notes, and snippets.

@nandantal
Created March 1, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nandantal/c720cd03822a415d69cb68f2817e092f to your computer and use it in GitHub Desktop.
Save nandantal/c720cd03822a415d69cb68f2817e092f to your computer and use it in GitHub Desktop.
mTextRecognizer.setProcessor(new Detector.Processor() {
@Override
public void release() {
}
@Override
public void receiveDetections(Detector.Detections detections) {
SparseArray items = detections.getDetectedItems();
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < items.size(); ++i) {
TextBlock item = items.valueAt(i);
if (item != null && item.getValue() != null) {
stringBuilder.append(item.getValue() + " ");
}
}
final String fullText = stringBuilder.toString();
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
public void run() {
mTextView.setText(fullText);
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment