我正在为android
编写基于Tess-two的OCR系统,偶然发现了一个奇怪的障碍。我实际上使用TextureView
与已弃用的Camera
相关联,当我尝试在华为P8 上执行此代码时:
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surface) {
Log.d("frame", "update frame");
if(btmQueue.size()<10)
btmQueue.add(mTextureView.getBitmap());
System.out.println(mOCRWorker.isAlive());
if(mOCRWorker.isAlive()==false)
{
mOCRWorker.start();
}
}
Thread mOCRWorker = new Thread(new Runnable() {
@Override
public void run() {
Log.d("Ocr:", "Running thread!");
if(apiInit==true) {
if (btmQueue.size() > 0) {
Bitmap bmp = btmQueue.pollFirst();
baseAPI.setImage(bmp);
String recognizedText = baseAPI.getUTF8Text();
Log.d("Recognized: ", recognizedText);
}
}
Log.d("Ocr:", "Thread finished!");
}
});
我收到此错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.myApp, PID: 18386
java.lang.IllegalThreadStateException: Thread already started
at java.lang.Thread.checkNotStarted(Thread.java:864)
at java.lang.Thread.start(Thread.java:1074) [...]
我认为如果isAlive()
给我假,那么我的线程实际上已经死了。你有什么线索吗?
答案 0 :(得分:0)