Open3D 中 get_view_control.rotate() 的参数类型是什么?
What is the Argument Type for get_view_control.rotate() in Open3D?
如Open3D的documentation所示,您可以使用get_view_control.rotate()
函数在查看器中旋转对象。但它没有指定类型(度数、弧度等)。如果我使用大约 2100 的值,它看起来像是一个完整的转弯,但在将它们放在一个循环中之后,事实证明这不是转弯 360 度 的确切值。我也没有在 Open3D 文档中的任何地方看到它。
我想捕捉 360 度 (x,y,z) 不同角度的深度图像。这是我的一段代码:
class Viewer:
def __init__(self, on, of, fd): #objectname, objectFile and folderdirectory
self.index = 0
self.objectName = on
self.objectFile = of
self.folderDirectory = fd
self.vis = o3d.visualization.Visualizer()
self.view = o3d.visualization.ViewControl()
self.pcd = o3d.io.read_triangle_mesh(self.folderDirectory + self.objectFile)
def depthFullCapture(self, times):
self.numberOfTimes = times
def captureDepth(vis):
print('Capturing')
self.depth = vis.capture_depth_float_buffer(False)
plt.imsave((self.folderDirectory + 'images/' + self.objectName + '_{:05d}.png'.format(self.index)),np.asarray(self.depth), dpi = 1)
np.savetxt((self.folderDirectory + 'text/' + self.objectName + '_{:05d}.txt'.format(self.index)),self.depth,fmt='%.2f',delimiter=',')
vis.register_animation_callback(rotate)
def rotate(vis):
print('Rotating')
ctr = vis.get_view_control()
if(self.index % 25 == 0):
self.vis.reset_view_point(True)
ctr.rotate(0,((2100/25)*(self.index/25)))
else:
ctr.rotate(84, 0)
ctr.set_zoom(0.75)
self.index += 1
if not (self.index == 625):
vis.register_animation_callback(captureDepth)
else:
vis.register_animation_callback(None)
vis.destroy_window()
self.vis.create_window(width = 200, height = 200)
self.vis.add_geometry(self.pcd)
self.vis.register_animation_callback(captureDepth)
self.vis.run()
所以谁能解释一下 value/type 转动一定角度的正确方法?或者有 another/better 的方法吗?提前致谢!有什么不明白的请追问:)
正如我从 Open3D Docs (see also this link) 中的示例所知,get_view_control.rotate() 有 4 个参数:x、y、xo 和 yo,它们都是以度为单位的浮点值。
当然这个答案来得太晚了,可以扩展,也许你可以告诉我们你学到了什么!
实际答案可以在C documentation:
中找到
const double open3d::visualization::ViewControl::ROTATION_RADIAN_PER_PIXEL = 0.003
旋转单位为像素:
x and y are the distances the mouse cursor has moved. xo and yo are the original point coordinate the mouse cursor started to move from. Coordinates are measured in screen coordinates relative to the top-left corner of the window client area.
你们非常亲密。
0.003 [radian/pixel] * (180/pi) [degrees/radian] = 0.1719 [degrees/pixel]
或
5.8178 [pixels/degree]
参加
360 [degrees/rotation] * 5.8178 [pixels/degree] = 2094.3951 [pixels/rotation]
如Open3D的documentation所示,您可以使用get_view_control.rotate()
函数在查看器中旋转对象。但它没有指定类型(度数、弧度等)。如果我使用大约 2100 的值,它看起来像是一个完整的转弯,但在将它们放在一个循环中之后,事实证明这不是转弯 360 度 的确切值。我也没有在 Open3D 文档中的任何地方看到它。
我想捕捉 360 度 (x,y,z) 不同角度的深度图像。这是我的一段代码:
class Viewer:
def __init__(self, on, of, fd): #objectname, objectFile and folderdirectory
self.index = 0
self.objectName = on
self.objectFile = of
self.folderDirectory = fd
self.vis = o3d.visualization.Visualizer()
self.view = o3d.visualization.ViewControl()
self.pcd = o3d.io.read_triangle_mesh(self.folderDirectory + self.objectFile)
def depthFullCapture(self, times):
self.numberOfTimes = times
def captureDepth(vis):
print('Capturing')
self.depth = vis.capture_depth_float_buffer(False)
plt.imsave((self.folderDirectory + 'images/' + self.objectName + '_{:05d}.png'.format(self.index)),np.asarray(self.depth), dpi = 1)
np.savetxt((self.folderDirectory + 'text/' + self.objectName + '_{:05d}.txt'.format(self.index)),self.depth,fmt='%.2f',delimiter=',')
vis.register_animation_callback(rotate)
def rotate(vis):
print('Rotating')
ctr = vis.get_view_control()
if(self.index % 25 == 0):
self.vis.reset_view_point(True)
ctr.rotate(0,((2100/25)*(self.index/25)))
else:
ctr.rotate(84, 0)
ctr.set_zoom(0.75)
self.index += 1
if not (self.index == 625):
vis.register_animation_callback(captureDepth)
else:
vis.register_animation_callback(None)
vis.destroy_window()
self.vis.create_window(width = 200, height = 200)
self.vis.add_geometry(self.pcd)
self.vis.register_animation_callback(captureDepth)
self.vis.run()
所以谁能解释一下 value/type 转动一定角度的正确方法?或者有 another/better 的方法吗?提前致谢!有什么不明白的请追问:)
正如我从 Open3D Docs (see also this link) 中的示例所知,get_view_control.rotate() 有 4 个参数:x、y、xo 和 yo,它们都是以度为单位的浮点值。
当然这个答案来得太晚了,可以扩展,也许你可以告诉我们你学到了什么!
实际答案可以在C documentation:
中找到const double open3d::visualization::ViewControl::ROTATION_RADIAN_PER_PIXEL = 0.003
旋转单位为像素:
x and y are the distances the mouse cursor has moved. xo and yo are the original point coordinate the mouse cursor started to move from. Coordinates are measured in screen coordinates relative to the top-left corner of the window client area.
你们非常亲密。
0.003 [radian/pixel] * (180/pi) [degrees/radian] = 0.1719 [degrees/pixel]
或
5.8178 [pixels/degree]
参加
360 [degrees/rotation] * 5.8178 [pixels/degree] = 2094.3951 [pixels/rotation]