Re: [camerax-developers] Digest for camerax-developers@android.com - 1 update in 1 topic

46 views
Skip to first unread message

Chie Tolentino

unread,
Feb 20, 2023, 4:13:53 PM2/20/23
to camerax-d...@android.com

On Tue, Feb 21, 2023, 05:09 <camerax-d...@android.com> wrote:
202ngnr <ngn...@gmail.com>: Feb 20 01:28AM -0800

Hello.
I am developing an application for recognizing moving objects, and the
problem is that when an object appears, the camera adjusts to it, changing
the background at the same time. There is focusing on the object, and the
overall brightness of the image changes if the brightness of the object is
different from the brightness of the background. I need to disable all
automatic settings. I'm trying different methods, for clarity I've combined
them into a function. The variant with FocusMeteringAction disables
autofocus, but the brightness change remains, with the reference point
moving to the upper right corner (according to mp1 coordinates). The option
with Camera2CameraControl (option 2) also disables autofocus, but leaves
automatic brightness change (automatic white balance?). Moreover, option 3
does not turn on the autofocus back. The Camera2Interop option does not
work at all, probably because this ImageAnalysis object is not connected to
the cameraProvider. Attempting to connect Camera2Interop to CameraX sample
code fails, errors occur.
 
```
private fun camAutoCtrls(mode: Int = 1) {
if (mode == 0) {
val mp1 = SurfaceOrientedMeteringPointFactory(1.0F, 1.0F).createPoint(0.0F,
0.0F)
val mp2 = SurfaceOrientedMeteringPointFactory(1.0F, 1.0F).createPoint(0.5F,
0.1F)
val fma = FocusMeteringAction.Builder(mp1) // must be AF | AE | AWB
.addPoint(mp2, FocusMeteringAction.FLAG_AWB) // single flag allowed ??
//.setAutoCancelDuration(10, TimeUnit.MINUTES)
.disableAutoCancel()
.build()
camCtl.startFocusAndMetering(fma) //camCtl: CameraControl
return
}
if (mode == 1) {
camCtl.cancelFocusAndMetering()
return
}
if (mode == 2) {
val c2cc = Camera2CameraControl.from(camCtl) // error: This declaration is
opt-in and its usage should be marked with
c2cc.captureRequestOptions = CaptureRequestOptions.Builder()
.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE,CaptureRequest.
CONTROL_AWB_MODE_OFF)
.setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE,CaptureRequest.
CONTROL_AF_MODE_OFF)
.setCaptureRequestOption(CaptureRequest.CONTROL_AE_MODE,CaptureRequest.
CONTROL_AE_MODE_OFF)
.build()
return
}
if (mode == 3) {
val c2cc = Camera2CameraControl.from(camCtl) // error: This declaration is
opt-in and its usage should be marked with
c2cc.captureRequestOptions = CaptureRequestOptions.Builder()
.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE,CaptureRequest.
CONTROL_AWB_MODE_AUTO)
.setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE,CaptureRequest.
CONTROL_AF_MODE_AUTO)
.setCaptureRequestOption(CaptureRequest.CONTROL_AE_MODE,CaptureRequest.
CONTROL_AE_MODE_ON)
.build()
return
}
if (mode == 4) {
val builder = ImageAnalysis.Builder()
val c2io = Camera2Interop.Extender(builder) //do not work
c2io.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE,CaptureRequest.
CONTROL_AWB_MODE_OFF)
c2io.setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE,CaptureRequest.
CONTROL_AF_MODE_OFF)
//c2io.setCaptureRequestOption(CaptureRequest.CONTROL_AE_LOCK,true)
return
}
}
```
 
Maybe I'm wrong, and the brightness change is not related to the automatic
white balance, but then what? With exposure? But the
exposureCompensationIndex does not change.
 
```
//camInf: CameraInfo
val x1 = camInf.exposureState.exposureCompensationIndex // 0 always
val x2 = camInf.exposureState.exposureCompensationRange.lower // -12 always
val x3 = camInf.exposureState.exposureCompensationRange.upper // 12 always
```
 
So, can you suggest a good way to disable the automatic camera settings,
and in such a way that they can be turned back on? I found a post with a
similar request dated 2019, but there were only promises to implement.
 
Also, options 2 and 3 give an error "This declaration is opt-in and its
usage should be marked with", but the code compiles and works. Is there any
way around this error other than suppress?
 
Tried on two phones with Android 5, the same on both.
 
I apologize if I did not see the solution in the discussion.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to camerax-develop...@android.com.
Reply all
Reply to author
Forward
0 new messages