4

I'm trying to develop an android application which should take continuous images just like native camera in continuous shooting mode for 10 to 20 seconds.

I followed the sample program from the site

http://marakana.com/forums/android/examples/39.html

Now , i want to enhance this code to take continuous images (for 10 to 20 seconds) , first i tried to take 10 pics by using a for loop , i just put the takePicture() function in the loop , but that'S not working .

do i need to use threadS . IF YES , THEN which part should i put in thread , the image capturing or image saving to sd card

If any body having some sample code for taking continuous images , pls share.

Sushanta Patel
  • 614
  • 4
  • 5
user921463
  • 41
  • 2
  • 4
  • possible duplicate of [Capturing Multiple Photos](http://stackoverflow.com/questions/5336890/capturing-multiple-photos) – Alex Cohn Jun 14 '14 at 09:11

2 Answers2

2

I know it is very late to reply, but I just came across this question and thought it would be helpful for future visitors.

PictureCallback jpegCallback = new PictureCallback() {
    public void onPictureTaken(byte[] data, Camera camera) {
     //Save Picture here

       preview.camera.stopPreview();

       // if condition 
             preview.camera.startPreview();
       // end if condition
  }
};
Johny Smith
  • 154
  • 1
  • 1
  • 7
2

Just put a counter in the jpegCallBack function, that decrements and calls your takePicture() again until the wished number of pictures is reached.

int pictureCounter = 10;

PictureCallback jpegCallback = new PictureCallback() {

    @Override
    public void onPictureTaken(byte[] data, Camera camera) {
            // save your picture
        if(--pictureCounter>=0) {
            takePicture();
        } else {
            pictureCounter = 10; // reset the counter
        }
    }
Mark
  • 7,507
  • 12
  • 52
  • 88