py_sfm_depth_v1-0.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:py_sfm_depth 作者: geojames 项目源码 文件源码
def visibility(cam, footprints, targets):
    """    
    This function tests is the target points (x,y only) are "visable" (i.e.
    within the photo footprints) and calculates the "r" angle for the refraction 
    correction\n
    Vars:\n
    \t cam = Pandas dataframe (n x ~6, fields: x,y,z,yaw,pitch,roll)\n
    \t footprints = Pandas dataframe (n x 1) of Matplotlib Path objects\n
    \t targets = Pandas dataframe (n x ~3, fields: x,y,sfm_z...)\n

    RETURNS: r_filt = numpy array (n_points x n_cams) of filtered "r" angles.\n
    Points that are not visable to a camera will have a NaN "r" angle. 
    """

    # Setup boolean array for visability
    vis = np.zeros((targets.shape[0],cam.shape[0])) 

    # for each path objec in footprints, check is the points in targets are
    #   within the path polygon. path.contains_points returns boolean.
    #   the results are accumulated in the vis array.
    for idx in range(footprints.shape[0]):
        path = footprints.fov[idx]
        vis[:,idx] = path.contains_points(np.array([targets.x.values, targets.y.values]).T)

    # calculate the coord. deltas between the cameras and the target
    dx = np.atleast_2d(cam.x.values) - np.atleast_2d(targets.x.values).T
    dy = np.atleast_2d(cam.y.values) - np.atleast_2d(targets.y.values).T
    dz = np.atleast_2d(cam.z.values) - np.atleast_2d(targets.sfm_z).T

    # calc xy distance (d)
    d = np.sqrt((dx)**2+(dy)**2)

    # calc inclination angle (r) from targets to cams
    r = np.rad2deg(np.arctan(d/dz))

    r_filt = r * vis
    r_filt[r_filt == 0] = np.nan

    return r_filt
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号