Open fmolivato opened 10 months ago
Hi, Did you find a method to get the bbox or segmentation maps now? I also need that thank you so much.
Im also looking into this.
@fmolivato @George121380 did you find out how?
Hi @SergioArnaud, yes, I was finally able to get the bounding boxes.
The process was as follows:
Hope this helps.
Hi @fmolivato, this is awesome! Do you happen to have the code of how you created the pointcloud?
Im trying something like the following but seems to be failing in associating the correct color to a given point
def scene_to_sampled_pointcloud(scene, points_per_mesh=1000):
all_points = []
all_colors = []
for name, geometry in scene.geometry.items():
if isinstance(geometry, trimesh.Trimesh):
# Sample points on the surface of the mesh
points, face_indices = geometry.sample(points_per_mesh, return_index=True)
texture = geometry.visual.material.baseColorTexture.copy().convert('RGB')
# Get UV coordinates of the face vertices
face_uvs = geometry.visual.uv[geometry.faces[face_indices]]
# Compute barycentric coordinates for the sampled points
barycentric = trimesh.triangles.points_to_barycentric(geometry.triangles[face_indices], points)
# Interpolate UV coordinates for the sampled points
uvs = np.sum(face_uvs * barycentric[:, :, np.newaxis], axis=1)
# Sample colors from the texture
colors = np.array([
texture.getpixel((u * (texture.width - 1), v * (texture.height - 1)))
for u, v in uvs
])
all_points.extend(points)
all_colors.extend(colors)
I really really appreciate the help!
Glad to hear it! :smile:
Unfortunately, I'm not allowed to release the open source code until after graduation.
Still, you might want to use the texture vertices themselves as a point cloud. Something like that should do the trick.
Is there a smart way to extract the bounding box of the annotated objects in the scene?