Reputation: 1
i became always the same error after applying region growing to my 3d pointcloud i tried all the versions of open3d but it's also not working. with which version should i dowmload? for python and open3d?
here is the code:
import open3d as o3d
import numpy as np
import matplotlib.pyplot as plt
file_path = (file_path)
pcd.estimate_normals(search_param=o3d.geometry.KDTreeSearchParamHybrid(radius=0.05, max_nn=30))
distance_threshold = 0.05 # Distance threshold (5 cm)
angle_threshold = np.deg2rad(30) # Angle threshold (30 degrees)
min_cluster_size = 100 # Minimum cluster size to consider a region valid
labels = np.zeros(len(pcd.points), dtype=np.int32)
next_label = 1
queue = []
def grow_region(seed_index):
queue.append(seed_index)
labels[seed_index] = next_label
while queue:
current_index = queue.pop(0)
current_point = pcd.points[current_index]
current_normal = pcd.normals[current_index]
[k, idx, dist] = pcd.search_radius_vector_3d(current_point, distance_threshold)
for neighbor_index in idx:
if labels[neighbor_index] == 0: # Point not labeled yet
neighbor_normal = pcd.normals[neighbor_index]
# Calculate the angle between the normals
dot_product = np.dot(current_normal, neighbor_normal)
angle = np.arccos(dot_product)
# Check if the angle is within the angle threshold
if angle <= angle_threshold:
# Label the point and add it to the queue
labels[neighbor_index] = next_label
queue.append(neighbor_index)
for i in range(len(pcd.points)):
if labels[i] == 0: # Unlabeled point
grow_region(i)
next_label += 1 # Increment the label index
colors = plt.get_cmap("tab20")(np.linspace(0, 1, next_label))
colors = colors[labels]
pcd.colors = o3d.utility.Vector3dVector(colors)
o3d.visualization.draw_geometries([pcd])
and here is the Error
AttributeError: 'open3d.cpu.pybind.geometry.PointCloud' object has no attribute 'search_radius_vector_3d'
Upvotes: 0
Views: 55