Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Camera: fixed lens focus

I'm developing an Android application with a camera-related functionality feature.

First of all, I read a lot of stuff on SO, XDA and so on, then please don't redirect me to other useless posts.

I am trying to implement something like a "fixed focus mode", so that:

  1. I start my application with FOCUS_MODE_AUTO (or something else);
  2. bring into focus an object at an arbitrary distance;
  3. fix the current focus;
  4. move the camera on another object at a different distance which is out of focus.

I tried different solutions, i.e.:

  • mCamera.cancelAutoFocus() in the AutoFocusCallback to prevent the adjustment of the focus;
  • set a FocusArea: new Camera.Area(new Rect(-50, -50, 50, 50), 1000) to fix the focus on the current area.

I'm targeting API 20 and I'm working on a Samsung Galaxy S5. On this device, the supported focus modes are: - auto - infinity - macro - continuous-video - continuous-picture

The suggestion that I found more frequently is to recompile Android...

like image 976
Zeb Avatar asked Nov 10 '22 20:11

Zeb


1 Answers

"AUTO" mode doesn't mean that the camera continuously focuses - just that when you call the autoFocus command the focus is done automatically with no indication on what result you expect not like "Macro" or "Infinity".

http://developer.android.com/reference/android/hardware/Camera.html#autoFocus(android.hardware.Camera.AutoFocusCallback)

So if you don't have a loop that calls the autoFocus (as many examples do or call it again in the Callback) your focus should stay after it runs once.

like image 131
Raanan Avatar answered Nov 14 '22 23:11

Raanan