Skip to content
mplackowski edited this page Mar 6, 2014 · 5 revisions

Introduction

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:

Starting preview and OCR

	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

Receiving OCR results

Yous should implement CameraInterface.OCRListener interface:

@Override
public void onTextRecognized(String text, float accuracy) {
	mOcrTV.setText("Accuracy:["+accuracy+"] Text: "+text);
}

Receiving bitmap that was used in OCR

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);
		}
	});
}