Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
116022017144 opened this issue Feb 27, 2023 · 0 comments

Comments

@116022017144
Copy link

/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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant