1

To update the camera capture session with a new state (focus, exposuretime) it seems i have to call abortCaptures on my current session. Calling this takes about 0.3 seconds though. The viewport also freezes during this time. It seems this other apps change focus without stuttering though, how do these apps do it?

If I don't call abortCaptures on my session it does eventually update to a new focus distance without stuttering, but only after about 10 seconds..

Source file: https://github.com/RuurdBijlsma/Camera/blob/master/app/src/main/java/com/ruurdbijlsma/camera/Camera.java#L166

RuteNL
  • 197
  • 14

1 Answers1

2

You don't need to call abortCaptures to change camera capture parameters - you generally only need it if you want to change to a new capture session quickly, and that's only when you have new target Surfaces. Such as switching from photo mode to video mode.

Just change your focus or exposure settings in your capture request builder, build the request, and submit it to the camera device (probably via setRepeatingRequest()).

Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47
  • Thanks! I didn't actually know setRepeatingRequest existed.. I called capture in a timer, which worked fine except that the focus etc. didn't update. setRepeatingRequest works properly – RuteNL Mar 16 '17 at 10:02
  • Please take a look at https://github.com/googlesamples/android-Camera2Basic for a Google sample on how to wire up a basic camera app - it'll hopefully be helpful. – Eddy Talvala Mar 16 '17 at 22:50
  • @EddyTalvala What if we have a repeatingRequest to capture a video then we'll have to call abortCapture to stop that repeating request. In this case it takes about 3-5 seconds of delay. What is the alternative here? I also tried stopCapturing but it too takes a lot of time. – Shivam Pokhriyal Sep 21 '19 at 09:30
  • 3-5 seconds seems quite long, but if abortCaptures() and stopRepeating() both take that long, you might as well just use stopRepeating() since it's safer. But if you're just stopping recording but continuing preview, you can just replace the repeating request with your preview-only one without stopping/aborting the previous request. Details would depend on your actual use case though. – Eddy Talvala Sep 23 '19 at 21:52