android camera2 how to achieve continuous capture with 30 pictures 1second

288 views Asked by At

When saving a bitmap, an error appear. How to achieve continuous capture? Do I do it right?

This is my imageReader

//wight 480, height 640, format JPEG,maxnum 30
//when I set format is YUV_420_888, I do not know how to translate it 
//to bitmap,so I set it is JPEG
imageReader = ImageReader.newInstance(480, 640, ImageFormat.JPEG, 30);

try {
        //set Builder
        takePictureRequestBuilder = 
              mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        
        takePictureRequestBuilder.addTarget(imageReader.getSurface());            
        takePictureRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                                          CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        
        takePictureRequestBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                                               CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
        
        int rotation = getWindowManager().getDefaultDisplay().getRotation();  
      
        takePictureRequestBuilder.set(CaptureRequest.JPEG_ORIENTATION, 
                                                       ORIENTATIONS.get(rotation));
        
        CaptureRequest mCaptureRequest = takePictureRequestBuilder.build();

        List<CaptureRequest> list = new LinkedList<>();
        for (int i = 0; i < 10; i++) {
            list.add(mCaptureRequest);
        }

        //set captureBurst
        mCameraCaptureSession.captureBurst(list,null,handler1);
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
0

There are 0 answers