Exemple #1
0
def convert_region(region: Region) -> TraxRegion:
    if isinstance(region, Rectangle):
        return TraxRectangle.create(region.x, region.y, region.width, region.height)
    elif isinstance(region, Polygon):
        return TraxPolygon.create(region.points)
    elif isinstance(region, Mask):
        return TraxMask.create(region.mask, x=region.offset[0], y=region.offset[1])

    return None
Exemple #2
0
 def test_convert_traxregion(self):
     convert_traxregion(TraxRectangle.create(0, 0, 10, 10))
     convert_traxregion(
         TraxPolygon.create([(0, 0), (10, 0), (10, 10), (0, 10)]))
     convert_traxregion(TraxMask.create(np.ones((100, 100),
                                                dtype=np.uint8)))