from robosuite.utils.camera_utils import get_real_depth_map
agentview_depth_real = get_real_depth_map(env.sim, agentview_depth)
h,w = env_args['camera_heights'], env_args['camera_widths']
i = np.zeros([h*w,2])#(点数,像素点二维坐标)
colors = np.zeros([h*w,3])#(点数,像素点对应的RGB值)
for x in range(h):
for y in range(w):
i[x*h+y] = [x,y]
colors[x*h+y] = agentview_image[x,y]
from robosuite.utils.camera_utils import get_camera_extrinsic_matrix,get_camera_intrinsic_matrix
camera_intrinsic_matrix_ = np.linalg.inv(get_camera_intrinsic_matrix(env.sim,'agentview', env_args['camera_heights'], env_args['camera_widths']))
camera_extrinsic_matrix_ = np.linalg.inv(get_camera_extrinsic_matrix(env.sim,'agentview'))
points = np.zeros([i.shape[0],3])
for num,p in enumerate(i):
p_ = (camera_intrinsic_matrix_@np.array([[p[0],p[1],1]]).T).T
p_[0,2] = agentview_depth_real[int(p[0]),int(p[1])]
p_ = (camera_extrinsic_matrix_@np.array([p_[0,0],p_[0,1],p_[0,2],1]).T).T
points[num] = p_[:-1]
print(points)
env.close()
X Error of failed request: BadAccess (attempt to access private resource denied)
Major opcode of failed request: 152 (GLX)
Minor opcode of failed request: 5 (X_GLXMakeCurrent)
Serial number of failed request: 183
Current serial number in output stream: 183
import open3d as o3d
pcd_show = o3d.geometry.PointCloud()
pcd_show.points = o3d.utility.Vector3dVector(points[:, :3])
pcd_show.colors = o3d.utility.Vector3dVector(colors[:]/255)
o3d.visualization.draw_geometries([pcd_show])