camera_simile.py 文件源码

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

项目:SIMILE 作者: hoangminhle 项目源码 文件源码
def residual_smooth(trajectory, reg_alpha, back_horizon):
    # Alternative method to calculate the smooth coefficients: try to fit y-values directly to explain smoothness
    clf = linear_model.Ridge(alpha = reg_alpha)
    residual_ar_seg = np.empty(shape = [trajectory.shape[0],back_horizon]) #initialize an empty array to hold the autoregressed position values
    residual = trajectory.copy() #initialize position vector to simply be the output vector
    for item in inPlay:
        for i in range(back_horizon):
            temp = np.roll(residual[item[0]:(item[1]+1)],i+1)
            for j in range(i+1):
                temp[j] = 0
            residual_ar_seg[item[0]:(item[1]+1),i] = temp.copy()
    rows_to_delete = []
    for item in inPlay:
        for i in range(2*back_horizon):
            rows_to_delete.append(item[0]+i)
    residual = np.delete(residual, rows_to_delete,0)
    residual_ar_seg = np.delete(residual_ar_seg, rows_to_delete,0)
    # Use least square regression to find the best fit set of coefficients for the velocity vectors
    #position_smooth_interpolate = np.linalg.lstsq(position_ar_seg,position)[0]
    #Note that in practice, the outcome of position_smooth_coeff and position_smooth_interpolate seem to be quite similar
    clf.fit(residual_ar_seg,residual) # addition to switch from velocity to position
    residual_smooth_interpolate = clf.coef_ # addition to switch from velocity to position
    return residual_smooth_interpolate
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号