gpt4 book ai didi

android - 如何计算arcore中的视野?

转载 作者:行者123 更新时间:2023-11-29 18:42:26 25 4
gpt4 key购买 nike

在使用 arcore 时,是否有可用于访问相机视野(“FoV”、“视角”)的属性或方法?

根据一些实验,FoV 似乎通常约为 60 度,但据推测这会因设备硬件而异。

如果不能直接访问,有没有办法从任何相机对象属性计算 FoV 角度,例如 View 矩阵?

最佳答案

ARCorev1.8.0 不返回 FoV 值。相反,您可以使用 Camera 参数计算它:

val frame = session.update()
val camera = frame.camera
val imageIntrinsics = camera.imageIntrinsics

val focalLength = imageIntrinsics.focalLength[0]
val size = imageIntrinsics.imageDimensions
val w = size[0]
val h = size[1]

val fovW = Math.toDegrees(2 * Math.atan(w / (focalLength * 2.0)))
val fovH = Math.toDegrees(2 * Math.atan(h / (focalLength * 2.0)))

另一种使用 Camera2 API 的解决方案:

val cameraId = session.cameraConfig.cameraId

val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
val characteristics = cameraManager.getCameraCharacteristics(cameraId)

val maxFocus = characteristics.get(CameraCharacteristics.LENS_INFO_AVAILABLE_FOCAL_LENGTHS)
val size = characteristics.get(CameraCharacteristics.SENSOR_INFO_PHYSICAL_SIZE)
val w = size.width
val h = size.height

val fovW = Math.toDegrees(2 * Math.atan(w / (maxFocus[0] * 2.0)))
val fovH = Math.toDegrees(2 * Math.atan(h / (maxFocus[0] * 2.0)))

关于android - 如何计算arcore中的视野?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52828668/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com