开发者

How to capture continious image in Android

开发者 https://www.devze.com 2023-04-01 05:00 出处:网络
I\'m trying to develop an android application which should take continuous images just like nat开发者_如何学JAVAive camera in continuous shooting mode for 10 to 20 seconds.

I'm trying to develop an android application which should take continuous images just like nat开发者_如何学JAVAive 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.


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
        }
    }


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
  }
};
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号