I'm working on an android app using the camera, and the only means of focusing the image I've found requires the use of the built-in auto-focus. Its functionality is great when you're looking to take a picture, but when you're working with video it's a whole other story.
Is there a way to repeatedly adjust the focus without having to completely re-set the current focus?
See this.
edit
Not that I believe the site will go away anytime soon, but just in case:
public static final String FOCUS_MODE_CONTINUOUS_VIDEO
Continuous auto focus mode intended for video recording. The camera continuously tries to focus. This is ideal for shooting video. Applications still can call takePicture(Camera.ShutterCallback, Camera.PictureCallback, Camera.PictureCallback) in this mode but the subject may not be in focus. Auto focus starts when the parameter is set. Applications should not call autoFocus(AutoFocusCallback) in this mode. To stop continuous focus, applications should change the focus mode to other modes. Constant Value: "continuous-video"
Related
I'm making a small camera app, and I'm having a little problem with capturing several pictures.
First I found that after every mCamera.takePicture() we need to call mCamera.startPreview() on onPictureTaken() callback to keep seeing the preview after the first shot.
So, after this discovery, I've added a code to set the camera focus mode to FOCUS_MODE_CONTINUOUS_PICTURE in initialization, because it was not getting focus automatically.
What happens is that Auto Exposure and Auto Focus stop to work after the first shot.
I found that the Auto Exposure and Auto Focus works for a brief time after the shots and blocks.
Is there any function I need to call to restart this features after a shot?
Thank you.
This answer will probably work for you:
I fixed the issue by calling camera.cancelAutoFocus(). This caused continuous autofocus to kick in again.
After you take the shot, call camera.cancelAutoFocus()
Following camera2basic guide on Android L preview page, I am able to capture normal images, i.e. without flash or using auto-focus mechanism (I rely on passive focus)
However, I would like to take a flash image. The documentation states before taking flash image, I should call android.control.aePrecaptureTrigger to determine correct exposure.
My question:
How can I call AE Precapture trigger, wait for it to complete and then take the image using capture(CaptureRequest, CameraCaptureSession.CaptureListener, Handler)?
Method I've already tried:
After user clicks capture image button, I start a preview
Set CONTROL_AE_PRECAPTURE_TRIGGER to CONTROL_AE_PRECAPTURE_TRIGGER_START
Monitor AE_STATE result in CaptureListener's onCaptureCompleted method
When AE_STATE converges, I set AE lock and take image using capture() method
However, the flash image is still over-exposed and sometimes, I get complete garbage image.
Has anyone able to get this working?
Once this is working, auto-focus mechanism can be used in similar fashion.
Thanks
Thanks for trying out the new camera2 API!
You shouldn't need to lock AE; once you see AE_STATE as CONVERGED (or FLASH_REQUIRED), submit the still capture request.
Things to verify:
Is your AE_MODE either ON_AUTO_FLASH or ON_ALWAYS_FLASH for both the preview and the still capture requests? If not, the metering routines won't be controlling flash power or firing correctly. The still capture and preview templates may just have AE mode set to ON, which means the flash won't be fired under AE control.
Are you using CAPTURE_INTENT_STILL_PICTURE for the still capture? If not, the flash won't be fired by the automatics. This is automatically set for TEMPLATE_STILL_CAPTURE.
If you're seeing garbage images, please feel free to file a bug on our Android AOSP tracker:
http://b.android.com
Detailing the set of outputs you have for your session would be especially helpful, since we know there are some current bugs for certain output Surface sets.
I am not sure you got answer or not. I just figure it out as follows:
First I did for capturebuilder
captureBuilder.set(CaptureRequest.CONTROL_MODE,
CameraMetadata.CONTROL_MODE_AUTO);
captureBuilder.set(CaptureRequest.FLASH_MODE,
CameraMetadata.FLASH_MODE_TORCH);
I set both because I think that flash can be able to take while auto mode.
But the result is can't get flash image when capture.
Now I get flash image after I set boolean value for flash on/off.
if (isFlashOn)
captureBuilder.set(CaptureRequest.FLASH_MODE,
CameraMetadata.FLASH_MODE_SINGLE);
else
captureBuilder.set(CaptureRequest.CONTROL_MODE,
CameraMetadata.CONTROL_MODE_AUTO);
i am using samsung galaxy s2,i ve noticed that in video recording mode when i press record button the camera continuously focus on the object.but in preview mode it does n't.i want to use continuous auto focus in my application.it doesn't support this type of parameter.
question on auto focus
the auto focus call back hold focus for some amount of time and after that it looses.
and again most of the proposed solutions are not reliable.proposed solutions.
can u suggest me a perfect solution which will act as inbuilt camera application.(in video recording.)
thank you!have a nice day!!
Did you try the continuous autofocus mode FOCUS_MODE_CONTINUOUS_VIDEO (starting from API level 9)? In this mode, focus is automatically adjusted permanently (it worked well for me)
See the documentation at http://developer.android.com:
Camera.Parameters#FOCUS_MODE_CONTINUOUS_VIDEO
Camera.Parameters.html#setFocusMode(java.lang.String)
I am building an Android app that uses the phone's camera feature. I know there is a way to build a custom camera view. Instead, I am choosing to use the camera app via an intent and not build my own camera view. I want to disable/make disappear the pause button while taking a video and have just the stop button. I looked up the Camera API Guide at www.developer.android.com but it doesn't talk about how I could do this. Does anyone know a way to do this?
I doesn't think that this is possible. Using Intents is just a way to tell Android "hey, I'd like to take a video (photo, see MapView, etc). Can you do it for me?". It may trigger one or MORE Apps listening to that Intent, depending on what apps the user has Installed. Usually you can only choose very basic options via Intents, i.e. take video/picture or tell the MapView at which Position it should show up. These options usually also appear inside the App during normal use. I never see a "CustomCamera-App" that hasn't a pause Button, or where one is able to deactivate it inside the menu. Therefore the chances that it is possible to set that special option tends to zero.
I developed a small video camera application. It all works fine except focus.
I understand I need to call camera.autofocus, but I don't really know where is the right place to put the call it.
Anyone ever succeeded in autofocusing a video camera on android?
Thank
Eli
It's probably a matter of preference based on how you think users will use your app.
I think a common convention is to do an auto-focus when the user touches the scene in the preview. Most OEM camera apps seem to do this.
Doing auto-focus after zooming is also a common thing.
Finally, you might want to have a look at the zxing project (bar code scanner app) which has a nifty continuous auto focus approach that might be of use, though since youre capturing video, it might not be ideal as the focus transitions might be too noticeable.
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/camera/AutoFocusCallback.java?r=1698