9

I was trying to implement a burst mode camera in my app, which can take multiple pictures at the rate of 5-10(or more) snaps per second.

FYI I already saw the previous questions here, here and here - tried and failed with speed. Also the questions are old and there are no comprehensive answers addressing all the concerns like how to manage heap etc.

I would really appreciate if someone can help with useful pointers, best practice or maybe an SSCCE.

Update :

Tried successfully with pulling preview frames @ 15+snaps/sec, but the problem is preview size is limited. On nexus 5 I can get only 1920x1080 which is ~2mp, whereas the full resolution pic possible on n5 is 8mp :-(

Community
  • 1
  • 1
COD3BOY
  • 11,964
  • 1
  • 38
  • 56

2 Answers2

7

I think a big part of the problem is the question: How does burst mode work in current phones? A couple of blogs point out that Google has confirmed that they will be adding a burst mode API.

I suspect current implementations work by setting exposure time to minimum and calling takePicture in a loop or using Camera.PreviewCallback

I played around with the latter for some computer vision projects and happened to look into writing a burst mode camera using this API. You could store the buffers you receive from Camera.PreviewCallback in memory and process them on a background thread.

If I remember correctly, the resolution was lower than the actual camera resolution, so this may not ideal.

Leon
  • 12,013
  • 5
  • 36
  • 59
  • Tried successfully with pulling preview frames @ 15+snaps/sec, but the problem is preview size is limited. On nexus 5 I can get only 1920x1080 which is ~2mp, whereas the full resolution pic possible on n5 is 8mp :-( – COD3BOY Apr 27 '14 at 11:04
  • Yes, I mentioned that in my answer. The only other option is to set the camera settings and see how that influences the speed of processing images and maybe make it fast enough to take burst pictures by using takePicutre in a loop, however; that will also influence the quality of the images. – Leon Apr 27 '14 at 11:44
  • Some sensors do support burst mode, separate from onPreviewFrame. But this API is proprietary, and only in [camera HAL v.3](https://source.android.com/devices/camera/camera3.html) there is some attempt to make it possible for the device manufacturer to expose this functionality to 3rd party camera apps. – Alex Cohn Oct 21 '15 at 08:55
  • 1
    @Leon can you provide some examples? I met same problem and I can't find the answer – Anton Shkurenko Dec 01 '15 at 12:39
7

Short of device-specific APIs offered by their manufacturers, the only way you can get a "burst mode" that has a shot of working across devices will be to use the preview frames as the images. takePicture() has no guarantees of when you will be able to call takePicture() again.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • +1 - tried successfully with preview frames @ 15+ fps, but the problem is preview size is limited. On nexus 5 I can get only 1920x1080 which is ~2mp, whereas the full resolution pic possible on n5 is 8mp :( Is there any way to get the full res pic done? – COD3BOY Apr 22 '14 at 14:24
  • @COD3BOY: The only way to get full-resolution pictures is to use `takePicture()`, and then you're back to the issue where you don't know how quickly it will be safe for you to call that again. – CommonsWare Apr 22 '14 at 14:27
  • Thanks. So what is the best approach while using `takePicture()` ? Currently I am saving the image to internal storage (no threads here) and calling `takePicture()` again inside `pictureCallback`. which currently gives me a 2 snaps per sec on nexus 5. Is this the best possible way? – COD3BOY Apr 22 '14 at 14:35
  • @COD3BOY: It's the only way that I know of that will be reliable. In principle, some of the time between `takePicture()` and `onPictureTaken()` should be taken up in processing that might not interfere with another `takePicture()` call. You're welcome to try to call `takePicture()` more frequently, before `onPictureTaken()` is called, but, as the saying goes, your mileage may vary. :-) – CommonsWare Apr 22 '14 at 14:39
  • Thanks, let me try it out, will update in case something comes up :-) – COD3BOY Apr 22 '14 at 14:46
  • CommonsWare, you are right about the way to do it. Most major device manufacturers do have some sort of API available on newer devices and you could use different classes to handle each of those APIs. "Burst Mode" is something that somewhat has to be handled in part by the sensor and by the camera drivers. You need a readily available buffer and distribution of the computing tasks to have it go on well. – childofthehorn Apr 24 '14 at 14:29