You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从PyRender PerspectiveCamera获取相机内参以生成点云?

PyRender PerspectiveCamera内参获取方法
  • 你之前的代码存在两个关键问题:

    1. 计算焦距时未将yfov除以2,三角函数的参数应为半视场角,而非完整视场角
    2. 忽略了图像宽高比对水平方向焦距的影响,当图像非正方形时,水平焦距fx和垂直焦距fy并不相等
  • 正确的内参计算方式(简便且准确):

    import math
    import numpy as np
    
    # 已知条件:camera为PerspectiveCamera实例,image_width、image_height为渲染图像尺寸
    aspect_ratio = image_width / image_height
    # 垂直方向焦距:基于半视场角计算
    fy = (image_height / 2) / math.tan(camera.yfov / 2)
    # 水平方向焦距:由垂直焦距和宽高比推导
    fx = fy * aspect_ratio
    # 主点坐标(图像中心)
    cx = image_width / 2
    cy = image_height / 2
    
    # 构造内参矩阵
    intrinsics = np.array([
        [fx, 0, cx],
        [0, fy, cy],
        [0, 0, 1]
    ])
    
  • 额外说明:
    你也可以通过访问camera.projection_matrix获取相机的投影矩阵,再从中反推内参,但手动按上述方式计算更直接高效。

内容的提问来源于stack exchange,提问作者nona

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 07:25:01