Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
ANDROID OS BUILD NUMBER: AP1A.240505.005
DEVICES TESTED: Pixel 7a and Samsung S23FE
I'm using Camera2Interop to manually set all image capture settings, i.e. exposure/iso/wb/focus in the ImageAnalysis use case. In the code included below I've set the LENS_FOCUS_DISTANCE to 0.1 and then look at the reported focus value in the capture result. In the Pixel 7a the values are different. The included code produces this logcat output on the Pixel 7a:
2024-05-26 13:36:04.065 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.122 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): false 0.089209 733210577061211
2024-05-26 13:36:04.154 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 0 timestamp 733210577061211
2024-05-26 13:36:04.266 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.340 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): false 0.089209 733210777951266
2024-05-26 13:36:04.351 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 1 timestamp 733210777951266
2024-05-26 13:36:04.367 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.438 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): false 0.089209 733210878397157
2024-05-26 13:36:04.447 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 2 timestamp 733210878397157
2024-05-26 13:36:04.467 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.535 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733210978842472
2024-05-26 13:36:04.544 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 3 timestamp 733210978842472
2024-05-26 13:36:04.568 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.636 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211079287787
2024-05-26 13:36:04.649 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 4 timestamp 733211079287787
2024-05-26 13:36:04.668 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.737 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211179733102
2024-05-26 13:36:04.744 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 5 timestamp 733211179733102
2024-05-26 13:36:04.768 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.845 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211280178417
2024-05-26 13:36:04.863 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 6 timestamp 733211280178417
2024-05-26 13:36:04.871 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.960 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211380623732
2024-05-26 13:36:04.972 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:04.990 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 7 timestamp 733211380623732
2024-05-26 13:36:05.061 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211481069047
2024-05-26 13:36:05.071 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:05.079 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 8 timestamp 733211481069047
2024-05-26 13:36:05.159 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211581514362
2024-05-26 13:36:05.173 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:05.196 8889-8889 debug_imageanalysis com.example.testimageanalysis D image 9 timestamp 733211581514362
2024-05-26 13:36:05.264 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211681959676
2024-05-26 13:36:05.273 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:05.362 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211782404991
2024-05-26 13:36:05.375 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:05.467 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211882850306
2024-05-26 13:36:05.476 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:05.568 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733211983295621
2024-05-26 13:36:05.574 8889-8953 debug_imageanalysis com.example.testimageanalysis D onCaptureStarted():
2024-05-26 13:36:05.685 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureCompleted(): true 0.089209 733212083740936
2024-05-26 13:36:05.685 8889-8942 debug_imageanalysis com.example.testimageanalysis D onCaptureSequenceCompleted():
The focus distance is set to 0.1 via Camera2Interop but once the lens has finished moving the value is still reported as 0.089209. Other focus distance settings have the same behavior.
On the Samsung S23FE I don't see this behavior *except* when setting the focus distance to 0.0. In this case the S23FE returns a non-zero value for the focus distance in the capture result and it appears the focus remains at the setting last used in any other camera app.
I created a simple app and added the following code in the main activity to test this issue:
cameraProviderFuture.addListener( {
val cameraProvider = cameraProviderFuture.get()
val resolutionSelector = ResolutionSelector.Builder()
.setResolutionStrategy(ResolutionStrategy.HIGHEST_AVAILABLE_STRATEGY)
.build()
val imageAnalysisBuilder = ImageAnalysis.Builder()
.setOutputImageFormat(ImageAnalysis.OUTPUT_IMAGE_FORMAT_RGBA_8888)
.setResolutionSelector(resolutionSelector)
val camera2InterOp = Camera2Interop.Extender(imageAnalysisBuilder)
camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AWB_MODE,
CameraMetadata.CONTROL_AWB_MODE_DAYLIGHT)
camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AE_MODE,
CameraMetadata.CONTROL_AE_MODE_OFF)
camera2InterOp.setCaptureRequestOption(CaptureRequest.CONTROL_AF_MODE,
CameraMetadata.CONTROL_AF_MODE_OFF)
camera2InterOp.setCaptureRequestOption(CaptureRequest.FLASH_MODE,
CameraMetadata.FLASH_MODE_OFF)
camera2InterOp.setCaptureRequestOption(CaptureRequest.SENSOR_SENSITIVITY, 200)
camera2InterOp.setCaptureRequestOption(CaptureRequest.SENSOR_EXPOSURE_TIME, 100_000_000L)
camera2InterOp.setCaptureRequestOption(CaptureRequest.LENS_FOCUS_DISTANCE, 0.1f)
camera2InterOp.setSessionCaptureCallback(object: CameraCaptureSession.CaptureCallback() {
override fun onCaptureFailed(session: CameraCaptureSession, request: CaptureRequest,
failure: CaptureFailure) {
Log.d("debug_imageanalysis","onCaptureFailed(): ")
super.onCaptureFailed(session, request, failure)
}
override fun onCaptureSequenceCompleted(session: CameraCaptureSession, sequenceId: Int,
frameNumber: Long) {
Log.d("debug_imageanalysis","onCaptureSequenceCompleted(): ")
super.onCaptureSequenceCompleted(session, sequenceId, frameNumber)
}
override fun onCaptureStarted(session: CameraCaptureSession, request: CaptureRequest,
timestamp: Long, frameNumber: Long) {
Log.d("debug_imageanalysis","onCaptureStarted(): ")
super.onCaptureStarted(session, request, timestamp, frameNumber)
}
override fun onCaptureCompleted(session: CameraCaptureSession, request: CaptureRequest,
result: TotalCaptureResult) {
val lens_state = result.get(CaptureResult.LENS_STATE)
val focus_dist = result.get(CaptureResult.LENS_FOCUS_DISTANCE)
val timestamp = result.get(CaptureResult.SENSOR_TIMESTAMP)
Log.d("debug_imageanalysis","onCaptureCompleted(): " +
"${lens_state==CaptureResult.LENS_STATE_STATIONARY} $focus_dist $timestamp")
super.onCaptureCompleted(session, request, result)
}
})
var kimage = 0
val imageAnalysis = imageAnalysisBuilder.build().apply {
setAnalyzer( ContextCompat.getMainExecutor(baseContext), ImageAnalysis.Analyzer { image ->
val timestamp = image.imageInfo.timestamp
Log.d("debug_imageanalysis","image $kimage timestamp $timestamp")
image.close()
if( ++kimage == 10 ) clearAnalyzer() // stop streaming images to the image analyzer
})
}
val cameraSelector = CameraSelector.DEFAULT_BACK_CAMERA
cameraProvider.unbindAll()
cameraProvider.bindToLifecycle(this as LifecycleOwner, cameraSelector, imageAnalysis)
}, ContextCompat.getMainExecutor(this))