Beispiel #1
0
    def __test_shape(self, n):

        mat = numpy.random.rand(n,n)

        msg = serialize_matrix(mat)

        mat2 = deserialize_matrix(msg)

        eps = numpy.absolute(mat2 - mat).max()
        self.assertLess(eps, 0.00001)
Beispiel #2
0
    def deserialize(project: 'Project', msg: 'ser.Image.Reader') -> 'ImageLayer':
        transform = deserialize_matrix(msg.transform.matrix)
        obj = ImageLayer(project, msg.name, msg.data, transform)

        project.scontext.set_sid(msg.sid, obj)
        obj._project = project

        meta_which = msg.transform.meta.which()
        if meta_which == "noMeta":
            obj.set_alignment(None)
        elif meta_which == "keypointTransformMeta":
            obj.set_alignment(KeyPointAlignment.deserialize(project, msg.transform.meta.keypointTransformMeta))
        elif meta_which == "rectTransformMeta":
            obj.set_alignment(RectAlignment.deserialize(msg.transform.meta.rectTransformMeta))
        else:
            raise NotImplementedError()

        return obj
Beispiel #3
0
    def deserialize(project, msg):
        transform = deserialize_matrix(msg.transform.matrix)
        obj = ImageLayer(msg.name, msg.data, transform)

        project.scontext.set_sid(msg.sid, obj)
        obj._project = project

        meta_which = msg.transform.meta.which()
        if meta_which == "noMeta":
            obj.set_alignment(None)
        elif meta_which == "keypointTransformMeta":
            obj.set_alignment(KeyPointAlignment.deserialize(project, msg.transform.meta.keypointTransformMeta))
        elif meta_which == "rectTransformMeta":
            obj.set_alignment(RectAlignment.deserialize(msg.transform.meta.rectTransformMeta))
        else:
            raise NotImplementedError()


        return obj