Java android tess两个OCR加速和出错
我的应用程序中的OCR非常慢 如何加快我的申请 当代码执行时,我有一些错误 这是我的OCR代码Java android tess两个OCR加速和出错,java,android,ocr,tess-two,Java,Android,Ocr,Tess Two,我的应用程序中的OCR非常慢 如何加快我的申请 当代码执行时,我有一些错误 这是我的OCR代码 public class ProcessImage extends AsyncTask<String,String, String> { String OCRresult = null; @Override protected String doInBackground(String... args) { try {
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() {}
}
公共类ProcessImage扩展异步任务{
字符串ocresult=null;
@凌驾
受保护的字符串doInBackground(字符串…args){
试一试{
mTess.setImage(OCR.image);
ocresult=mTess.getUTF8Text();
mTess.end();
mTess.clear();
}捕获(运行时异常e){
Log.e(“ocrecognizeasynctask”,
“在对Tesseract的请求中捕获了RuntimeException。正在将状态设置为CONTINUOUS_STOPPED。”,
e) );
试一试{
}捕获(NullPointerException e1){
//继续
}
返回null;
}
返回“已执行”;
}
@凌驾
受保护的void onPostExecute(字符串结果){
TextView txt=(TextView)findViewById(OCRTextView);
txt.setText(“請按返回"); // txt.setText(结果);
if(ocresult!=null){
txt.setText(ocresult);
}
//可能需要更改传递的返回字符串的“已执行”
//进入onPostExecute(),但这取决于您
}
@凌驾
受保护的void onPreExecute(){}
}
这是代码执行时的错误
您不能在end()之后调用clear()。如果要加快检测速度,请检查图像大小并使用检测器参数和检测模式
祝你好运。Thka要得到你的答案,我会试试看