0

i was wondering if it is possible to save images from the camera preview, maybe 1 image every 2-3 seconds. any examples you can give me?

i have found this as a possible solution, and i know how to save the image from byte array, but how do i proceed with saving every Nth frame? i was thinking of storing the system uptime and checking it in every frame but it seems kinda lame. Is there a better way? Is there a way i can get info such as preview frame rate?

Android: How to save a preview frame as jpeg image?

tnx.

1

2 Answers 2

2

I have been able to convert images from the preview stream to a usable format using the YUV420-to-RGB algorithm presented here. In my application, I also do this every 2-3 seconds for the purposes of analysing the colour.

You can write an appropriate Runnable and use Handler.postDelayed() (see docs) to chain call for the appropriate interval. You could also use Message and Handler.sendMessageDelayed() in conjunction with overriding Handler.handleMessage() for the same effect.

The key idea is to include code to send (delayed) another identical message in the code to handle that message. This enables continuous capture. Be careful to clear the message pipeline when you eventually decide to stop your application!

Sign up to request clarification or add additional context in comments.

1 Comment

I am also implementing this feature in my application. But I can only able to capture 1 frame while in camera preview mode. I would like to capture frame for every 5 seconds while in preview mode. Any sample of how to achieve this ? Thanks. U rock !
1

You can use a CountDownTimer. You have to override the onPreviewFrame. In there you call the YUV420. In your CountDownTimer, you can call your own screenshot method every 5 seconds. or you use a ArrayList<Bitmap> and add your Bitmaps from the onPreviewFrame. And after capture the screenshots, you can save all the Bitmaps....

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.