kevalpatel2106/android-hidden-camera

Burst/multiple images?

androidnoob123 opened this issue · 1 comments

Hi,

Can someone please suggest how to take multiple images with the help of the service -- one after other repeatedly say for like 3 times (or if possible, take all at the same time without doing the saveImage first.)

Thank you!

You can increase a static variable on the callback (onImageCapture) and start takePicture(). Something along the lines of:

image_taken++
if (image_taken<10){
   takePicture();
}else{
   stopSelf();
}

However, its possible that you will run into an issue on HiddenCameraService.java. On takePicture(), because the else case for mCameraPreview.isSafeToTakePictureInternal() is not handled, the camera will stay open forever until the main service is closed forcefully. This only happens when you are trying to take multiple images one-after-another in short interval, of course.

protected void takePicture() {
        if (mCameraPreview != null) {
            if (mCameraPreview.isSafeToTakePictureInternal()) {
                mCameraPreview.takePictureInternal();
            }     // what to do in case its not safe, wait, queue, stop camera? 
        } else {
            throw new RuntimeException("Background camera not initialized. Call startCamera() to initialize the camera.");
        }
    }

Maybe @kevalpatel2106 can look into this.