camera_utils.py 文件源码

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

项目:pybot 作者: spillai 项目源码 文件源码
def project(self, X, check_bounds=False, check_depth=False, return_depth=False, min_depth=0.1):
        """
        Project [Nx3] points onto 2-D image plane [Nx2]
        """
        R, t = self.to_Rt()
    rvec,_ = cv2.Rodrigues(R)
    proj,_ = cv2.projectPoints(X, rvec, t, self.K, self.D)
        x = proj.reshape(-1,2)

        if check_depth: 
            # Only return positive depths
            depths = self.depth_from_projection(X)
            valid = depths >= min_depth
        else:
            valid = np.ones(len(x), dtype=np.bool)

        if check_bounds: 
            if self.shape is None: 
                raise ValueError('check_bounds cannot proceed. Camera.shape is not set')

            # Only return points within-image bounds
            valid = np.bitwise_and(
                valid, np.bitwise_and(
                    np.bitwise_and(x[:,0] >= 0, x[:,0] < self.shape[1]), \
                    np.bitwise_and(x[:,1] >= 0, x[:,1] < self.shape[0]))
            )

        if return_depth: 
            return x[valid], depths[valid]

        return x[valid]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号