CameraX Focus Infinity

174 views
Skip to first unread message

jose luis larraz

unread,
Sep 3, 2020, 12:57:55 PM9/3/20
to Android CameraX Discussion Group
How can I set the focus to infinity mode?

Kirill Konovalov

unread,
Sep 6, 2020, 5:13:23 AM9/6/20
to Android CameraX Discussion Group, jll...@gmail.com
Greetings. 
Maybe I can help. In CameraX beta04 was added Camera2Interop. It allow set some settings to use cases and in your case set focus.
Example below in Kotlin.

private fun initPreviewUseCase(): Preview {
  val preview = Preview.Builder()
  attachSettingsTo(preview, false)
  return preview.build()
}

private fun attachSettingsTo(useCaseBuilder: Any, isAF:Boolean){
  Camera2Interop.Extender(useCaseBuilder as ExtendableBuilder<*>).run {
   if (isAF) setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_VIDEO)
   else {
    setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_OFF)
    setCaptureRequestOption(CaptureRequest.LENS_FOCUS_DISTANCE, 0F) // 0F - means infinity focus
}}}

Usefull links.
четверг, 3 сентября 2020 г. в 19:57:55 UTC+3, jll...@gmail.com:

Scott Nien

unread,
Sep 7, 2020, 12:09:13 AM9/7/20
to Kirill Konovalov, Android CameraX Discussion Group, jll...@gmail.com
As Kirill said,  Camera2Interop can do the trick.  

But if you need to change the focus on the fly (without unbinding and rebinding the use cases) ,   we are designing a new Camera2Interop API that can support this scenario.  Hopefully it can be released soon. 


--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/d11101ea-192e-4213-bf7f-799680ad4aecn%40android.com.
Reply all
Reply to author
Forward
0 new messages