stabilizer.py 文件源码

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

项目:360-stabilizer 作者: MateusZitelli 项目源码 文件源码
def fixOffset(self, offset, img):
    size = img.shape
    finalImg = np.ndarray(size)
    indices = np.indices((self.videoSize[0],self.videoSize[1])).swapaxes(0,2).swapaxes(0,1)
    indices = np.around(indices, decimals=1)
    indices.shape = (self.videoSize[1] * self.videoSize[0], 2)
    phi = 2 * np.arctan(np.exp(indices[:, 1] / self.videoSize[1])) - 1/2 * np.pi - offset[0]
    lamb = indices[:, 0] - offset[1]
    x = lamb
    y = np.log(np.tan(np.pi / 4 + 1/2 * phi)) * self.videoSize[1]
    finalIdx = np.ndarray((self.videoSize[1] * self.videoSize[0], 2))
    finalIdx = np.around(finalIdx, decimals=1).astype(int)
    finalIdx[:, 1] = y % self.videoSize[1]
    finalIdx[:, 0] = x % self.videoSize[0]
    finalImg[indices[:,1], indices[:,0]] = img[finalIdx[:,1], finalIdx[:,0]]
    return finalImg
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号