(self, polygons, ignore_tags, h, w)
return polygons, ignore_tags
polygons (numpy.array, required): of shape (num_instances, num_points, 2)
polygons (numpy.array, required): of shape (num_instances, num_points, 2)
polygons ( numpy . array required ) : of shape ( num_instances num_points 2 )
def validate_polygons(self, polygons, ignore_tags, h, w):
        '''
        polygons (numpy.array, required): of shape (num_instances, num_points, 2)
        '''
        if len(polygons) == 0:
            return polygons, ignore_tags
        assert len(polygons) == len(ignore_tags)
        for polygon in polygons:
            polygon[:, 0] = np.clip(polygon[:, 0], 0, w - 1)
            polygon[:, 1] = np.clip(polygon[:, 1], 0, h - 1)

        for i in range(len(polygons)):
            area = self.polygon_area(polygons[i])
            if abs(area) < 1:
                ignore_tags[i] = True
            if area > 0:
                polygons[i] = polygons[i][::-1, :]
        return polygons, ignore_tags
def validate_polygons ( self , polygons , ignore_tags , h , w ) : if len ( polygons ) == 0 : return polygons , ignore_tags assert len ( polygons ) == len ( ignore_tags ) for polygon in polygons : polygon [ : , 0 ] = np . clip ( polygon [ : , 0 ] , 0 , w - 1 ) polygon [ : , 1 ] = np . clip ( polygon [ : , 1 ] , 0 , h - 1 ) for i in range ( len ( polygons ) ) : area = self . polygon_area ( polygons [ i ] ) if abs ( area ) < 1 : ignore_tags [ i ] = True if area > 0 : polygons [ i ] = polygons [ i ] [ : : - 1 , : ] return polygons , ignore_tags