简体   繁体   English

无法让Menpo在Pycharm中显示图像

[英]Can't get menpo to display images in Pycharm

My code so far: 到目前为止,我的代码:

import menpo.io as mio

bb = mio.import_builtin_asset.breakingbad_jpg()
bb.view()

I was just trying to play around with menpo. 我只是想和menpo一起玩。 But it seems that I can't even figure out how to display the builtin asset (breakingbad.jpg). 但似乎我什至无法弄清楚如何显示内置资产(breakingbad.jpg)。 I installed menpo from http://www.lfd.uci.edu/~gohlke/pythonlibs/ using the 'menpo-0.6.2-cp27-none-win32.whl' file. 我使用“ menpo-0.6.2-cp27-none-win32.whl”文件从http://www.lfd.uci.edu/~gohlke/pythonlibs/安装了menpo。 I'm running the code in pycharm. 我在pycharm中运行代码。 When I run the code above, it just finishes (Process finished with exit code 0 ). 当我运行上面的代码时,它就完成了(进程以退出代码0结束)。 How can i get it to show the image when I run the code on pycharm as I'm assuming it would in a jupyter notebook? 我在pycharm上运行代码时,如何像假定在jupyter笔记本中那样显示图像?

Essentially, I was wondering if it would be possible to get it to show the first image in a new windows (kind of like imshow() in opencv) when I run the code in pycharm. 本质上,我想知道是否有可能在pycharm中运行代码时在新窗口中显示第一张图像(类似于opencv中的imshow())。 Any help is appreciated. 任何帮助表示赞赏。 Thanks! 谢谢!

(see http://nbviewer.jupyter.org/github/menpo/menpo-notebooks/blob/v0.3.0/notebooks/Deformable%20Models/AAMs%20Basics.ipynb for the first image that i'm referring to) (有关我要引用的第一张图片,请参见http://nbviewer.jupyter.org/github/menpo/menpo-notebooks/blob/v0.3.0/notebooks/Deformable%20Models/AAMs%20Basics.ipynb

The problem is that the rendering loop is fairly complicated. 问题在于渲染循环相当复杂。 This is one of the primary reasons people choose to use things like Jupyter/IPython because it makes the non-blocking aspect of rendering easier (since it's just outputs directly into the web page). 这是人们选择使用Jupyter / IPython之类的原因的主要原因之一,因为它使呈现的非阻塞方面更加容易(因为它只是直接输出到网页中)。 In this case, if you want the figures to show 'of their own accord' you have to tell Matplotlib to go into interactive mode. 在这种情况下,如果您希望数字“自己显示”,则必须告诉Matplotlib进入交互模式。 So, before running your code above, try running: 因此,在运行上面的代码之前,请尝试运行:

import matplotlib.pyplot as plt
plt.ion()

import menpo.io as mio

bb = mio.import_builtin_asset.breakingbad_jpg()
bb.view()

Alternatively, after calling view on the image, you can force Matplotlib to show it: 或者,在图像上调用view之后,可以强制Matplotlib显示它:

bb.view()
plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM