Android: continuous autofocus video recording

I am working on a video recording; everything works, except for the continuous focus request. This is what I am doing (tried both in the surfaceCreated method and in the surfaceChanged method without success):

camera = Camera.open(); camera.setPreviewDisplay(holder); Parameters parameters = camera.getParameters(); 

then i do either

 parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO); 

or

 parameters.set("focus-mode", "continuous-video"); 

both must do the same; then I set the parameters with

 camera.setParameters(parameters); 

This last line always fails! So am I missing something?

By the way, I am testing fairly new devices, such as Desire HD, Galaxy S, Galaxy Tab 7 and 10.1, which should have continuous autofocus support; at least their built-in camera apps support it.

+6
source share
2 answers

Well, I have a solution to this problem: I managed to manually focus the camera by calling the camera # autoFocus (...).

This still has serious problems. Firstly, the autofocus call when shooting video does not work on some Samsung devices. It is also not recommended to force your users to manually focus the camera during video recording.

So, if you were able to properly focus your videos while recording, your tips would be very helpful.

+4
source

You should check to see if Continuous Auto Focus is supported by the device. This is what works for me, please try.

 boolean startContinuousAutoFocus() { Camera.Parameters params = mCamera.getParameters(); List<String> focusModes = params.getSupportedFocusModes(); String CAF_PICTURE = Parameters.FOCUS_MODE_CONTINUOUS_PICTURE, CAF_VIDEO = Parameters.FOCUS_MODE_CONTINUOUS_VIDEO, supportedMode = focusModes .contains(CAF_PICTURE) ? CAF_PICTURE : focusModes .contains(CAF_VIDEO) ? CAF_VIDEO : ""; if (!supportedMode.equals("")) { params.setFocusMode(supportedMode); mCamera.setParameters(params); return true; } return false; } 
+5
source

Source: https://habr.com/ru/post/899221/


All Articles