gabhor
gabhor

Reputation: 789

How to check if camera supports auto-focus on Android with CameraX?

Currently I'm using the CameraX library in my Android project. I'd like to decide programmatically if the given camera instance supports auto-focus. How can I get this info?

Upvotes: 3

Views: 899

Answers (1)

gabhor
gabhor

Reputation: 789

I could solve it by extending the CameraCharacteristics class in the following way:

import android.hardware.camera2.CameraCharacteristics

val CameraCharacteristics.hasAutoFocus: Boolean
  get() = get(CameraCharacteristics.CONTROL_MAX_REGIONS_AF) != 0

Upvotes: 2

Related Questions