【问题标题】:PyVista: AttributeError: 'Plotter' object has no attribute 'ren_win'PyVista:AttributeError:“绘图仪”对象没有属性“ren_win”
【发布时间】:2021-05-03 11:43:56
【问题描述】:

我正在使用 PyVista 文档的示例代码:

import pyvista as pv
import matplotlib.pyplot as plt
from pyvista import examples

mesh = examples.load_random_hills()

p = pv.Plotter()
p.add_mesh(mesh, color=True)
p.show()

zval = p.get_image_depth()

plt.figure()
plt.imshow(zval)
plt.colorbar(label='Distance to Camera')
plt.title('Depth image')
plt.xlabel('X Pixel')
plt.ylabel('Y Pixel')
plt.show()

很遗憾,我收到以下错误:

File "C:\Users\user\Anaconda3\lib\site-packages\pyvista\plotting\plotting.py", line 3110, in get_image_depth
    ifilter.SetInput(self.ren_win)

AttributeError: 'Plotter' object has no attribute 'ren_win'

我不知道为什么会发生错误,也找不到关于这个问题的任何信息。

pv.Report 的输出是:

  Date: Mon May 03 14:02:50 2021 Mitteleuropäische Sommerzeit



  Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)]

           pyvista : 0.29.1
               vtk : 9.0.1
             numpy : 1.16.5
           imageio : 2.6.0
           appdirs : 1.4.4
            scooby : 0.5.7
            meshio : 4.4.1
        matplotlib : 3.3.4
             PyQt5 : 5.9.2
           IPython : 7.8.0
             scipy : 1.3.1
              tqdm : 4.36.1

  Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for
  Intel(R) 64 architecture applications

【问题讨论】:

  • 您使用的是什么版本的 pyvista?检查相关包的最简单方法是运行pv.Report()
  • 这些是软件包的版本:Python 3.7.4(默认,2019 年 8 月 9 日,18:34:13)[MSC v.1915 64 bit (AMD64)] pyvista : 0.29.1 vtk :9.0.1 numpy:1.16.5 imageio:2.6.0 appdirs:1.4.4 scooby:0.5.7 meshio:4.4.1 matplotlib:3.3.4 PyQt5:5.9.2 IPython:7.8.0 scipy:1.3.1 tqdm : 4.36.1 Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 架构应用
  • 能否请edit您的问题添加报告的输出?查看版本会更容易。我无法在 0.29.1 上重现该问题,所以我想看看是否还有其他问题。你确定pv.Report对应的是同一个出现错误的环境吗?
  • 好的,我将编辑问题,是的,pv.Report 对应于出现错误的相同环境。到目前为止谢谢你
  • 我没有看到任何可以解释发生了什么的东西。我在 Linux 上,但该库肯定可以在 Windows 上运行。我认为你应该打开一个问题on github,让更多专家的眼睛可以看到它。

标签: python image 3d depth-buffer pyvista


【解决方案1】:

答案是必须存储图像。 所以我必须在p.show()之前插入p.store_image = True

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 2018-06-29
    • 1970-01-01
    • 2021-04-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多