eyes.py 文件源码

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

项目:srcsim2017 作者: ZarjRobotics 项目源码 文件源码
def get_cloud_image(self, data):
        """ Get an image from the cloud """
        dta = np.zeros((data.height, data.width), dtype="float32")

        dtype = np.dtype('float32')
        dtype = dtype.newbyteorder('<')
        buf = np.frombuffer(data.data, dtype)
        buf = np.resize(buf, (data.width * data.height, 8))
        buf = np.compress([True, True, True, True, True, False, False, False],
                          buf, axis=1)
        buf = buf[~np.isnan(buf).any(1)]

        for point in buf:
            point[3] = 1.0
            src = np.asmatrix(point[:4])
            src = np.reshape(src, (4, 1))
            dst = np.dot(self.p_left, src)
            pnt_w = dst[2, 0]
            if pnt_w != 0:
                img_x = dst[0, 0] / pnt_w
                img_y = dst[1, 0] / pnt_w
                dta[img_y, img_x] = point[4]

        nstr = dta.tostring()
        img = np.fromstring(nstr, dtype='uint8')
        img.resize(data.height, data.width, 4)
        img = np.compress([True, True, True, False], img, axis=2)
        return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号