I'm trying to capture image data from the camera using the camera2 API. I've mostly used code taken from the android Capture2RAW example. Only a few images come through (i.e. calls to onImageAvailable) before stopping completely. I've tried capturing using the RAW_SENSOR and JPEG formats at different sizes with the same results. What am I doing wrong?
this.mImageReader = ImageReader.newInstance(width, height, ImageFormat.RAW_SENSOR, /*maxImages*/ 1); Surface surface = this.mImageReader.getSurface(); final List<Surface> surfaces = Arrays.asList(surface); this.mCamera.createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() { // Callback methods here }, null); CaptureRequest.Builder captureRequestBuilder; captureRequestBuilder = this.mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); captureRequestBuilder.addTarget(surface); this.mCaptureRequest = captureRequestBuilder.build(); this.mCaptureSession.setRepeatingRequest(mCaptureRequest, null, null);