Ejemplo n.º 1
0
    def zreader(self, fname):
        """reads a depth file to make a depth buffer"""

        if "OpenEXR" in self.backends:
            return exr.load_depth(fname)

        if "PIL" in self.backends:
            #for backwards compatibility with Bacall, remove as soon as possible
            try:
                im = PIL.Image.open(fname)
                return numpy.array(im, numpy.float32).reshape(
                    im.size[1], im.size[0])
            except:
                pass

        # Adjust the filename, replace .im with .npz
        baseName, ext = os.path.splitext(fname)
        adjustedName = baseName + ".npz"

        file = open(adjustedName, mode='r')
        tz = numpy.load(file)  #like a tar
        imageslice = tz[tz.files[0]]
        tz.close()
        file.close()
        return imageslice
Ejemplo n.º 2
0
    def zreader(self, fname):
        if "OpenEXR" in self.backends:
            return exr.load_depth(fname)

        elif "PIL" in self.backends:
            im = PIL.Image.open(fname)
            return numpy.array(im, numpy.float32).reshape(im.size[1],im.size[0])

        else:
            print "Warning: need OpenEXR or PIL to read from " + fname
Ejemplo n.º 3
0
    def zreader(self, fname):
        """reads a depth file to make a depth buffer"""
        if "OpenEXR" in self.backends:
            return exr.load_depth(fname)

        elif "PIL" in self.backends:
            try:
                im = PIL.Image.open(fname)
                #print "read", fname
                return numpy.array(im, numpy.float32).reshape(
                    im.size[1], im.size[0])
            except:
                #print "no such file", fname
                return None
        else:
            print "Warning: need OpenEXR or PIL to read from " + fname
Ejemplo n.º 4
0
    def zreader(self, fname):
        """reads a depth file to make a depth buffer"""

        if "OpenEXR" in self.backends:
            return exr.load_depth(fname)

        if "PIL" in self.backends:
            #for backwards compatibility with Bacall, remove as soon as possible
            try:
                im = PIL.Image.open(fname)
                return numpy.array(im, numpy.float32).reshape(im.size[1],im.size[0])
            except:
                pass

        # Adjust the filename, replace .im with .npz
        baseName, ext = os.path.splitext(fname)
        adjustedName = baseName + ".npz"

        file = open(adjustedName, mode='r')
        tz = numpy.load(file) #like a tar
        imageslice = tz[tz.files[0]]
        tz.close()
        file.close()
        return imageslice