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

AttributeError: 'Curve' object has no attribute 'get_bound_box' when calling compute_poi #1113

Open
schirrmacher opened this issue Jun 16, 2024 · 1 comment
Labels
first answer provided question Question, not yet a bug ;)

Comments

@schirrmacher
Copy link

Describe the issue

I copied some code and was facing an issue with:

objs = bproc.loader.load_blend(
    args.scene,
    obj_types=[
        "mesh",
        "curve",
        "curves",
        "hair",
        "armature",
        "empty",
        "light",
        "camera",
    ],
    data_blocks=[
        "armatures",
        "cameras",
        "curves",
        "hair_curves",
        "images",
        "lights",
        "materials",
        "meshes",
        "objects",
        "textures",
    ],
)

poi = bproc.object.compute_poi(objs)
Error: Python: Traceback (most recent call last):
  File "/Users/mav/dev/BlenderProc/examples/basics/semantic_segmentation/main.py", line 66, in <module>
    poi = bproc.object.compute_poi(objs)
  File "/Users/mav/dev/BlenderProc/blenderproc/python/types/MeshObjectUtility.py", line 701, in compute_poi
    bb_points = obj.get_bound_box()
AttributeError: 'Curve' object has no attribute 'get_bound_box'

I can create a PR if you like, the question is why do some object types not have this function. I simply fixed it with:

    for obj in objects:
        if hasattr(obj, "get_bound_box") and callable(getattr(obj, "get_bound_box")):
            # Get bounding box corners
            bb_points = obj.get_bound_box()
            # Compute mean coords of bounding box
            mean_bb_points.append(np.mean(bb_points, axis=0))

in def compute_poi(objects: List[MeshObject]) -> np.ndarray.

Minimal code example

No response

Files required to run the code

No response

Expected behavior

I would have expected no AttributeError

BlenderProc version

2.7.1

@schirrmacher schirrmacher added the question Question, not yet a bug ;) label Jun 16, 2024
@cornerfarmer
Copy link
Member

Hey @schirrmacher,

thanks for the report. I think the problem is that load_blend returns a List[Entity] while compute_poi requires a List[MeshObject] (Entity is a parent class of MeshObject). So you would need to filter out all objects that are no MeshObject first.

If you want the curves to be considered in the poi computation, you probably would need to write your own compute_poi function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first answer provided question Question, not yet a bug ;)
Projects
None yet
Development

No branches or pull requests

2 participants