hustvl/SparseInst

这个文件/root/anaconda3/envs/sparse/lib/python3.7/site-packages/fvcore/transforms/transform.py对polygon数据的处理是怎么样的

116022017144 opened this issue · 0 comments

/root/anaconda3/envs/sparse/lib/python3.7/site-packages/fvcore/transforms/transform.py
下面这串代码如何改呢?报错: for poly in cropped:处
TypeError: 'int' object is not iterable

for polygon in polygons:
polygon = geometry.Polygon(polygon).buffer(0.0)
# polygon must be valid to perform intersection.
if not polygon.is_valid:
continue
cropped = polygon.intersection(crop_box)
if cropped.is_empty:
continue
if not isinstance(cropped, geometry.collection.BaseMultipartGeometry):
cropped = [cropped]
print(type(cropped))

        # one polygon may be cropped to multiple ones

        for poly in cropped:
                [poly for poly in cropped if isinstance(poly, geometry.Polygon) and poly.is_valid]

                #poly=cropped[poly]
                coords = np.asarray(poly.exterior.coords)
            # NOTE This process will produce an extra identical vertex at
            # the end. So we remove it. This is tested by
            # `tests/test_data_transform.py`
                cropped_polygons.append(coords[:-1])


    return [self.apply_coords(p) for p in cropped_polygons]