Cameraview: Any way to disable auto focus?

Created on 19 Nov 2017  路  9Comments  路  Source: natario1/CameraView

Hi!

Is it possible to disable camera auto focus feature with your library?

Thank you in advance!

discussion enhancement discussion on hold

Most helpful comment

+1 May I ask, do you plan to add this functionality(disable auto focus)?

All 9 comments

No. May I ask why you want to disable it?

I want to calibrate android camera using OpenCV methods for later use. That process, as far as i know, requires the camera focus to be locked. Your great library seems to be the best choice since i want to focus on other stuff instead of dealing with the camera, however i am missing this feature.

Calibrate what? (Just curious).

This feature was present but I have removed it months ago. I had (have) the feeling that 99.99% of users would just need the best focus option.

Also focus modes are complicated to wrap in a useful API. Maybe Focus.BEST and Focus.OFF. if anyone wants to work on it we can discuss.

+1 to bring back possibility of turning off continous auto focus

No. May I ask why you want to disable it?

Would be nice to disable it so it can be locked to Infinite focus mode

+1 May I ask, do you plan to add this functionality(disable auto focus)?

Would really be great to have more focus modes. But the best we can do for now is to set autofocus reset delay to 0 (forever) then focus on a given point. Like this:

camera.setAutoFocusResetDelay(0); camera.startAutoFocus(camera.getWidth()/2,camera.getHeight()/2);

This way, the focus point is gonna be fixed. Hope it helps!

Not planning to do this. But you can change focus in Camera2 by simply subclassing the engine:

  • Subclass CameraView, e.g. MyCameraView
  • Subclass Camera2Engine, e.g. MyCamera2Engine
  • Override MyCameraView.instantiateCameraEngine(), and return an instance of My2CameraEngine
  • In My2CameraEngine, override protected methods like applyDefaultFocus() to do whatever you want

Something similar could be done in Camera1Engine, I'm just not sure that methods there are protected. If you need to make some method protected instead of private, just submit a PR.

Thank you for instructions :) Should be fine with it.

Was this page helpful?
0 / 5 - 0 ratings