Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java android tess两个OCR加速和出错_Java_Android_Ocr_Tess Two - Fatal编程技术网

Java android tess两个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 {

我的应用程序中的OCR非常慢

如何加快我的申请

当代码执行时,我有一些错误

这是我的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() {}



}
公共类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要得到你的答案,我会试试看