我正在尝试让Android camera2在后台服务中运行,然后在回调ImageReader.OnImageAvailableListener中处理帧.我已经使用建议的原始格式YUV_420_888来获得最大fps,但是我只能在分辨率640x480上获得7fps左右.这甚至比我使用旧的Camera接口(我想升级到Camera2以获得更高的fps)或使用OpenCV JavaCameraView(我不能使用它,因为我需要在后台服务中运行处理)更慢.
以下是我的服务类.我错过了什么?
我的手机是运行Android 5.0.2的Redmi Note 3
public class Camera2ServiceYUV extends Service {
protected static final String TAG = "VideoProcessing";
protected static final int CAMERACHOICE = CameraCharacteristics.LENS_FACING_BACK;
protected CameraDevice cameraDevice;
protected CameraCaptureSession captureSession;
protected ImageReader imageReader;
// A semaphore to prevent the app from exiting before closing the camera.
private Semaphore mCameraOpenCloseLock = new Semaphore(1);
public static final String RESULT_RECEIVER = "resultReceiver";
private static final int JPEG_COMPRESSION = 90;
public static final int RESULT_OK = 0;
public static final …Run Code Online (Sandbox Code Playgroud)