The OCR in my application is very slow
How can I speed up my application
and I have some error when the code executes
This is my code of OCR
public class ProcessImage extends AsyncTask<String,String, String> {
String OCRresult = null;
@Override
protected String doInBackground(String... args) {
try {
mTess.setImage(OCR.image);
OCRresult = mTess.getUTF8Text();
mTess.end();
mTess.clear();
} catch (RuntimeException e) {
Log.e("OcrRecognizeAsyncTask",
"Caught RuntimeException in request to Tesseract. Setting state to CONTINUOUS_STOPPED.",
e);
try {
} catch (NullPointerException e1) {
// Continue
}
return null;
}
return "Executed";
}
@Override
protected void onPostExecute(String result) {
TextView txt = (TextView) findViewById(OCRTextView);
txt.setText("請按返回"); // txt.setText(result);
if(OCRresult!=null) {
txt.setText(OCRresult);
}
// might want to change "executed" for the returned string passed
// into onPostExecute() but that is upto you
}
@Override
protected void onPreExecute() {}
}
This the error when code executes
You can not call clear() after end(). If you want to speed up the detection check the image size and play with the detector params and detection modes.
Good luck.