Last active
December 30, 2017 16:10
-
-
Save prakashpun/1c2f91a8bdf1d638f6b595bb9addc740 to your computer and use it in GitHub Desktop.
Set the TextRecognizer's Processor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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