-
Notifications
You must be signed in to change notification settings - Fork 0
Home
mplackowski edited this page Mar 6, 2014
·
5 revisions
To start the preview you should initialize CameraTool object in yours Activity onCreatemethod.
You should also prepare some container layout that will hold the preview.
Sample implemenation can be found in the source code, and below:
mCameraTool = new CameraTool(this);
mCameraTool.container(mCameraRL) // ViewGroup that will contain the Preview and Picker views
.OCRListener(this) // Listener for OCR results
.cropListener(this) // Listener for Picker changes
.save(10) // Stores last 10 previews on SD-Card
.source(CameraSource.BACK) // Defines source camera
.start(); // Starts preview and OCR
Yous should implement CameraInterface.OCRListener interface:
@Override
public void onTextRecognized(String text, float accuracy) {
mOcrTV.setText("Accuracy:["+accuracy+"] Text: "+text);
}
Yous should implement CameraInterface.CropListener interface.
Since the updates comes from background thread, assure that UI is updated from the main thread:
@Override
public void onCropUpdate(final Bitmap image) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mCropIV.setImageBitmap(image);
}
});
}