VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴

这篇具有很好参考价值的文章主要介绍了VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

本文 以 Python 语言开发

我们在做三维软件开发时,经常会用到相机坐标轴,来指示当前空间位置;

坐标轴效果:

VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴,VTK,Python,VTK,坐标轴,三维坐标轴

相机方向坐标轴

VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴,VTK,Python,VTK,坐标轴,三维坐标轴

 Cube 正方体坐标轴

VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴,VTK,Python,VTK,坐标轴,三维坐标轴

 自定义坐标轴:

VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴,VTK,Python,VTK,坐标轴,三维坐标轴文章来源地址https://www.toymoban.com/news/detail-737943.html

Code:

Axes
def main():
    colors = vtkNamedColors()

    # create a Sphere
    sphereSource = vtkSphereSource()
    sphereSource.SetCenter(0.0, 0.0, 0.0)
    sphereSource.SetRadius(0.5)

    # create a mapper
    sphereMapper = vtkPolyDataMapper()
    sphereMapper.SetInputConnection(sphereSource.GetOutputPort())

    # create an actor
    sphereActor = vtkActor()
    sphereActor.SetMapper(sphereMapper)

    # a renderer and render window
    renderer = vtkRenderer()
    renderWindow = vtkRenderWindow()
    renderWindow.SetWindowName('Axes')
    renderWindow.AddRenderer(renderer)

    # an interactor
    renderWindowInteractor = vtkRenderWindowInteractor()
    renderWindowInteractor.SetRenderWindow(renderWindow)

    # add the actors to the scene
    renderer.AddActor(sphereActor)
    renderer.SetBackground(colors.GetColor3d('SlateGray'))

    transform = vtkTransform()
    transform.Translate(1.0, 0.0, 0.0)

    axes = vtkAxesActor()
    #  The axes are positioned with a user transform
    axes.SetUserTransform(transform)

    # properties of the axes labels can be set as follows
    # this sets the x axis label to red
    axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(colors.GetColor3d('Red'));

    # the actual text of the axis label can be changed:
    axes.SetXAxisLabelText('test')
    renderer.AddActor(axes)
    renderer.GetActiveCamera().Azimuth(50)
    renderer.GetActiveCamera().Elevation(-30)

    renderer.ResetCamera()
    renderWindow.SetWindowName('Axes')
    renderWindow.Render()

    # begin mouse interaction
    renderWindowInteractor.Start()


if __name__ == '__main__':
    main()
CameraOrientationWidget
def main():
    colors = vtkNamedColors()

    renderer = vtkRenderer()
    ren_win = vtkRenderWindow()
    interactor = vtkRenderWindowInteractor()

    sphere_source = vtkSphereSource()
    sphere_source.SetRadius(10.0)

    mapper = vtkPolyDataMapper()
    mapper.SetInputConnection(sphere_source.GetOutputPort())

    actor = vtkActor()
    actor.GetProperty().SetColor(colors.GetColor3d('Beige'))
    actor.SetMapper(mapper)

    renderer.AddActor(actor)
    renderer.SetBackground(colors.GetColor3d('DimGray'))

    ren_win.AddRenderer(renderer)
    ren_win.SetSize(600, 600)
    ren_win.SetWindowName('CameraOrientationWidget')

    # Important: The interactor must be set prior to enabling the widget.
    interactor.SetRenderWindow(ren_win)

    cam_orient_manipulator = vtkCameraOrientationWidget()
    cam_orient_manipulator.SetParentRenderer(renderer)
    # Enable the widget.
    cam_orient_manipulator.On()

    ren_win.Render()
    interactor.Initialize()
    interactor.Start()


if __name__ == "__main__":
    main()
OrientationMarkerWidget
   colors = vtkNamedColors()
    # create a rendering window and renderer
    ren = vtkRenderer()
    ren_win = vtkRenderWindow()
    ren_win.AddRenderer(ren)
    ren_win.SetWindowName('OrientationMarkerWidget')

    # create a renderwindowinteractor
    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow(ren_win)

    cube = vtkCubeSource()
    cube.SetXLength(200)
    cube.SetYLength(200)
    cube.SetZLength(200)
    cube.Update()
    cm = vtkPolyDataMapper()
    cm.SetInputConnection(cube.GetOutputPort())
    ca = vtkActor()
    ca.SetMapper(cm)
    ca.GetProperty().SetColor(colors.GetColor3d("BurlyWood"))
    ca.GetProperty().EdgeVisibilityOn()
    ca.GetProperty().SetEdgeColor(colors.GetColor3d("Red"))

    # assign actor to the renderer
    ren.AddActor(ca)
    ren.SetBackground(colors.GetColor3d('CornflowerBlue'))

    axes_actor = vtkAnnotatedCubeActor()
    axes_actor.SetXPlusFaceText('L')
    axes_actor.SetXMinusFaceText('R')
    axes_actor.SetYMinusFaceText('I')
    axes_actor.SetYPlusFaceText('S')
    axes_actor.SetZMinusFaceText('P')
    axes_actor.SetZPlusFaceText('A')
    axes_actor.GetTextEdgesProperty().SetColor(colors.GetColor3d("Yellow"))
    axes_actor.GetTextEdgesProperty().SetLineWidth(2)
    axes_actor.GetCubeProperty().SetColor(colors.GetColor3d("Blue"))
    axes = vtkOrientationMarkerWidget()
    axes.SetOrientationMarker(axes_actor)
    axes.SetInteractor(iren)
    axes.EnabledOn()
    axes.InteractiveOn()
    ren.ResetCamera()

    # enable user interface interactor
    iren.Initialize()
    ren_win.Render()
    ren.GetActiveCamera().Azimuth(45)
    ren.GetActiveCamera().Elevation(30)
    ren_win.Render()
    iren.Start()
custom OrientationMarker
    colors = vtkNamedColors()

    reader = vtkXMLPolyDataReader()
    reader.SetFileName("./Human.vtp")

    icon_mapper = vtkDataSetMapper()
    icon_mapper.SetInputConnection(reader.GetOutputPort())

    icon_actor = vtkActor()
    icon_actor.SetMapper(icon_mapper)
    icon_actor.GetProperty().SetColor(colors.GetColor3d('Silver'))

    # Set up the renderer, window, and interactor
    renderer = vtkRenderer()
    renderer.SetBackground(colors.GetColor3d('SlateGray'))

    ren_win = vtkRenderWindow()
    ren_win.AddRenderer(renderer)
    ren_win.SetSize(400, 400)
    ren_win.SetWindowName('OrientationMarkerWidget1')

    iren = vtkRenderWindowInteractor()
    iren.SetRenderWindow(ren_win)

    rgb = [0.0, 0.0, 0.0]
    colors.GetColorRGB('Wheat', rgb)
    # Set up the widget
    widget = vtkOrientationMarkerWidget()
    widget.SetOrientationMarker(icon_actor)
    widget.SetInteractor(iren)
    widget.SetViewport(0.0, 0.0, 0.3, 0.3)
    widget.SetOutlineColor(*rgb)
    widget.SetEnabled(1)
    widget.InteractiveOn()

    # Create a superquadric
    superquadric_source = vtkSuperquadricSource()
    superquadric_source.SetPhiRoundness(.001)
    superquadric_source.SetThetaRoundness(.04)

    # Create a mapper and actor
    superquadric_mapper = vtkPolyDataMapper()
    superquadric_mapper.SetInputConnection(superquadric_source.GetOutputPort())

    superquadric_actor = vtkActor()
    superquadric_actor.SetMapper(superquadric_mapper)
    superquadric_actor.GetProperty().SetInterpolationToFlat()
    superquadric_actor.GetProperty().SetDiffuseColor(colors.GetColor3d('Carrot'))
    superquadric_actor.GetProperty().SetSpecularColor(colors.GetColor3d('White'))
    superquadric_actor.GetProperty().SetDiffuse(0.6)
    superquadric_actor.GetProperty().SetSpecular(0.5)
    superquadric_actor.GetProperty().SetSpecularPower(5.0)

    renderer.AddActor(superquadric_actor)
    renderer.ResetCamera()

    ren_win.Render()

    iren.Initialize()

    iren.Start()

到了这里,关于VTK OrientationMarker 方向 三维坐标系 相机坐标轴 自定义坐标轴的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 世界坐标系、相机坐标系和图像坐标系的转换

    之前只是停留在会用的阶段,一直没去读懂计算的原理,今天通读了大佬的文章,写的言简意赅,感谢感谢~~特此记录一下,仅用作个人笔记 贴链接,十分感谢~ https://blog.csdn.net/weixin_44278406/article/details/112986651 https://blog.csdn.net/guyuealian/article/details/104184551 将三维物体转换成照

    2023年04月15日
    浏览(48)
  • 关于世界坐标系,相机坐标系,图像坐标系,像素坐标系的一些理解

    在项目中,研究标定时,像素坐标与轴位置的关系时,需要用到关于坐标系的转换。在此也就是找到世界坐标系与像素坐标系的转换关系。想理清楚故做如下记录。 四坐标关系图如下: 图中: 世界坐标系(O W —X W Y W Z W ): 一个三维直角坐标系,以其为基准可以描述相机

    2024年02月09日
    浏览(56)
  • 图像坐标系如何转换到相机坐标系。

    问题描述:图像坐标系如何转换到相机坐标系。 问题解答: 图像坐标系的定义: 图像坐标系是用于描述数字图像中像素位置的坐标系。图像坐标系的原点是相机光轴与成像平面的交点。X轴沿着成像平面的水平方向正向,Y轴沿着成像平面的垂直方向正向。 相机坐标系的定义

    2024年02月04日
    浏览(37)
  • 三维坐标系转换

    一、首先需要判断坐标系是左手坐标系还是右手坐标系 首先将拇指作为X轴,食指作为Y轴,中指作为Z轴。观察(待判断的)坐标系对应哪只手对应的坐标系。然后根据对应的坐标系使用适配定则判断。右(左)手定则:用右(左)手的大拇指指向旋转轴的正方向,弯曲手指,

    2024年02月15日
    浏览(23)
  • 三维坐标系旋转矩阵推导

    注意 坐标系 旋转不同于 坐标点 旋转 坐标系旋转角度θ则 等同于 将目标点围绕坐标原点反方向旋转同样的角度θ 假设三维坐标系是一个右手坐标系。如下图 可以通过右手定则确定是右手坐标系。 确定轴的旋转的正方向,用右手的大拇指指向轴的正方向,弯曲手指手指。手

    2023年04月18日
    浏览(28)
  • 激光雷达坐标系和相机坐标系相互变换(易懂不详细)

    码字不易,路过的朋友动动小手点点赞吧 传感器融合少不了的就是联合标定,最近大火的激光雷达和相机传感器融合算法,让很多工程师学者投入精力学习,本文简单介绍一下激光雷达和相机传感器坐标系转换的原理。         传感器安装位置不同,而且每个传感器都有

    2024年02月11日
    浏览(33)
  • Three.js教程:三维坐标系

    推荐:将 NSDT场景编辑器 加入你的3D工具链 其他系列工具: NSDT简石数字孪生 本节课的目的就是为了加强大家对threejs三维空间的认识。 辅助观察坐标系 THREE.AxesHelper() 的参数表示坐标系坐标轴线段尺寸大小,你可以根据需要改变尺寸。 材质半透明设置 设置材质半透明,这样可

    2024年02月09日
    浏览(33)
  • 双相机坐标系标定

    在工业应用中,常常会遇到双相机定位的项目,下面就介绍双相机如何标定才能做到精准定位。 1,产品  如上图所示,玻璃上对角有两个mark点,由于mark点的间距太远只能用两个相机去拍。 2,相机布局  两个相机分别拍产品的对角。 3,标定流程   1,根据n点标的规则获取

    2024年02月12日
    浏览(35)
  • 相机坐标系

    相机坐标系——像素坐标系 本文所述的相机坐标系的意思是以该相机为参考,也就是世界坐标系的原点为该相机,来观测P的坐标。 在通俗理解下的相机坐标系与像素坐标系之间只差一个cx和cy。一定要注意 一个相机A的坐标系为L1,此时一个空间的点P距离相机50m,x方向偏10

    2024年02月09日
    浏览(33)
  • 相机基础(二)——坐标系转换

    物体之间的坐标系变换都可以表示坐标系的旋转变换加上平移变换,则世界坐标系到相机坐标系的转换关系也是如此。绕着不同的轴旋转不同的角度得到不同的旋转矩阵。如下: 那么世界坐标系到相机坐标系的变换如下: 从相机坐标系到图像坐标系,属于透视投影关系,从

    2024年02月11日
    浏览(41)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包