简体   繁体   中英

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. But it seems that I can't even figure out how to display the builtin asset (breakingbad.jpg). I installed menpo from http://www.lfd.uci.edu/~gohlke/pythonlibs/ using the 'menpo-0.6.2-cp27-none-win32.whl' file. I'm running the code in pycharm. When I run the code above, it just finishes (Process finished with exit code 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?

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. 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)

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). In this case, if you want the figures to show 'of their own accord' you have to tell Matplotlib to go into interactive mode. 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:

bb.view()
plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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