我正在做一个Android应用程序来实时处理图像,我不知道哪种方法是处理这些帧最有效的方法。
我在这样一个线程中启动了获取过程:
/**
* Thread to open camera acquisition process
*/
private static class CameraHandlerThread extends HandlerThread {
Handler mHandler = null;
CameraHandlerThread() {
super("CameraHandlerThread");
start();
mHandler = new Handler(getLooper());
}
synchronized void notifyCameraOpened() {
notify();
}
void openCamera() {
mHandler.post(new Runnable() {
@Override
public void run() {
try {
mCamera = Camera.open(cameraUsed.ordinal());
} catch (RuntimeException e) {
Log.e(TAG, "failed to open front camera");
}
notifyCameraOpened();
}
});
try {
wait();
} catch (InterruptedException e) {
Log.w(TAG, "wait was interrupted");
}
}
}我达到高帧速率(25 fps或多或少)和我的进程任务约300毫秒。启动这些任务的最佳和最快方式是哪一种?另一条线?在主线上?
谢谢
发布于 2016-04-05 11:04:34
有几件事你应该记住
最有效的方法是
number of threads == number of processors但是线程越多,RAM所需的内存就越多。
因此,您应该根据可用的RAM和CPU来决定。
顺便说一句,Camera.open是一个阻塞调用,所以把它放在一个线程中,这样效率更高,但是我希望您不会在Camera.open下处理图像,因为在这种情况下,线程或线程并不重要。
https://stackoverflow.com/questions/36423550
复制相似问题