Esempio n. 1
0
class RemoteCamera:
    def __init__(self, address, port=10000, xform=None):
        self.raw = RemoteRawCamera(address, port)
        self.xform = xform or se3.identity()
        
    def read(self, clean=True):
        (color, cloud, depth_uv, inverse_uv) = self.raw.read()
        
        # flip everything up/down based on camera mounting
        color = color[::-1,:,:]
        cloud = cloud[::-1,:,:]
        if depth_uv is not None:
            depth_uv = depth_uv[::-1,:,:]
        if inverse_uv is not None:
            inverse_uv = inverse_uv[::-1,:,:]

        # the point cloud and the depth UV map actually need to have their values changed
        # because the Y spatial direction is reversed
        cloud[:,:,1] *= -1
        if depth_uv is not None:
            depth_uv[:,:,1] = 1 - depth_uv[:,:,1]
        if inverse_uv is not None:
            inverse_uv[:,:,1] = 1 - inverse_uv[:,:,1]

        # convert point cloud to meters
        cloud /= 1000

        # compute the invalid mask early because world coordinates make
        # the z = 0 invalid points non-zero
        self.mask = invalid_mask(cloud) & (cloud[:,:,2] < 0.70)

        # apply the camera xform
        cloud = cloud.dot(numpy.array(self.xform[0]).reshape((3, 3))) + self.xform[1]

        self.color = color
        self.cloud = cloud
        self.depth_uv = depth_uv
        self.inverse_uv = inverse_uv

        return (color, cloud, depth_uv, inverse_uv)
        
    def clean(self):
        return (self.mask, self.cloud[self.mask])

    def colorize(self):
        if self.depth_uv is not None:
            colorized = uvtexture(self.color, self.depth_uv)
            return colorized
        else:
            return None

    def close(self):
        self.raw.close()
Esempio n. 2
0
class RemoteCamera:
    def __init__(self, address, port=10000, xform=None):
        self.raw = RemoteRawCamera(address, port)
        self.xform = xform or se3.identity()

    def read(self, clean=True):
        (color, cloud, depth_uv, inverse_uv) = self.raw.read()

        # flip everything up/down based on camera mounting
        color = color[::-1, :, :]
        cloud = cloud[::-1, :, :]
        if depth_uv is not None:
            depth_uv = depth_uv[::-1, :, :]
        if inverse_uv is not None:
            inverse_uv = inverse_uv[::-1, :, :]

        # the point cloud and the depth UV map actually need to have their values changed
        # because the Y spatial direction is reversed
        cloud[:, :, 1] *= -1
        if depth_uv is not None:
            depth_uv[:, :, 1] = 1 - depth_uv[:, :, 1]
        if inverse_uv is not None:
            inverse_uv[:, :, 1] = 1 - inverse_uv[:, :, 1]

        # convert point cloud to meters
        cloud /= 1000

        # compute the invalid mask early because world coordinates make
        # the z = 0 invalid points non-zero
        self.mask = invalid_mask(cloud) & (cloud[:, :, 2] < 0.70)

        # apply the camera xform
        cloud = cloud.dot(numpy.array(self.xform[0]).reshape((3, 3))) + self.xform[1]

        self.color = color
        self.cloud = cloud
        self.depth_uv = depth_uv
        self.inverse_uv = inverse_uv

        return (color, cloud, depth_uv, inverse_uv)

    def clean(self):
        return (self.mask, self.cloud[self.mask])

    def colorize(self):
        if self.depth_uv is not None:
            colorized = uvtexture(self.color, self.depth_uv)
            return colorized
        else:
            return None

    def close(self):
        self.raw.close()
Esempio n. 3
0
 def __init__(self, address, port=10000, xform=None):
     self.raw = RemoteRawCamera(address, port)
     self.xform = xform or se3.identity()
Esempio n. 4
0
 def __init__(self, address, port=10000, xform=None):
     self.raw = RemoteRawCamera(address, port)
     self.xform = xform or se3.identity()