예제 #1
0
    def test_point2f(self):
        pt = Point2(54.3, 72.9)
        msg = serialize_point2f(pt)

        pt2 = deserialize_point2f(msg)

        self.assertAlmostEqual(pt2.x, pt.x)
        self.assertAlmostEqual(pt2.y, pt.y)
예제 #2
0
    def deserialize(msg):
        handles = [ RectAlignment.__deserialize_handle(i) for i in msg.handles]
        dimHandles = [ RectAlignment.__deserialize_handle(i) for i in msg.dimHandles]
        dims = [i for i in msg.dims]

        assert len(handles) == 12
        assert len(dimHandles) == 4
        assert len(dims) == 2
        originCorner = {"lowerLeft": 0, "lowerRight": 1, "upperLeft" : 2, "upperRight": 3}[str(msg.originCorner)]
        originCenter = deserialize_point2f(msg.originCenter)

        return RectAlignment(handles, dimHandles, dims, msg.lockedToDim,
                             originCenter, originCorner, msg.flipX, msg.flipY)
예제 #3
0
    def deserialize(msg: ser.ImageTransform.RectTransformMeta.Reader) -> 'RectAlignment':
        handles = [RectAlignment.__deserialize_handle(i) for i in msg.handles]
        dimHandles = [RectAlignment.__deserialize_handle(i) for i in msg.dimHandles]
        dims = [i for i in msg.dims]

        assert len(handles) == 12
        assert len(dimHandles) == 4
        assert len(dims) == 2
        originCorner = {
            "lowerLeft": 0,
            "lowerRight": 1,
            "upperLeft": 2,
            "upperRight": 3}[str(msg.originCorner)]

        originCenter = deserialize_point2f(msg.originCenter)

        return RectAlignment(handles, dimHandles, dims, msg.lockedToDim,
                             originCenter, originCorner, msg.flipX, msg.flipY)
예제 #4
0
 def __deserialize_handle(msg):
     if msg.which() == "none":
         return None
     else:
         return deserialize_point2f(msg.point)
예제 #5
0
 def deserialize(project, msg):
     obj = KeyPointAlignment()
     for i in msg.keypoints:
         obj.set_keypoint_position(project.scontext.get(i.kpSid),
                                   deserialize_point2f(i.position))
     return obj
예제 #6
0
 def __deserialize_handle(msg: ser.Handle.Reader) -> Optional[Vec2]:
     if msg.which() == "none":
         return None
     else:
         return deserialize_point2f(msg.point)
예제 #7
0
 def deserialize(project: 'Project',
         msg: ser.ImageTransform.KeypointTransformMeta) -> 'KeyPointAlignment':
     obj = KeyPointAlignment()
     for i in msg.keypoints:
         obj.set_keypoint_position(project.scontext.get(i.kpSid), deserialize_point2f(i.position))
     return obj
예제 #8
0
 def __deserialize_handle(msg):
     if msg.which() == "none":
         return None
     else:
         return deserialize_point2f(msg.point)
예제 #9
0
 def deserialize(project, msg):
     obj = KeyPointAlignment()
     for i in msg.keypoints:
         obj.set_keypoint_position(project.scontext.get(i.kpSid), deserialize_point2f(i.position))
     return obj