使用arcore时,是否可以使用属性或方法访问相机的视场(“ FoV”,“视角”)?

从一些实验来看,FoV通常约为60度,但据推测这将取决于设备硬件而有所不同。

如果无法直接访问它,则有一种方法可以从任何Camera对象属性(例如,视图矩阵?

最佳答案

ARCore库v1.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/

10-12 03:13