You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm having problems using OpenCV (cv2) & matplotlib.pyplot. I'm not sure if it's a bug in cv2 or matplotlib, but I'll post here anyways.
Matplotlib figures don't block when their show() method is called after cv2 is also used to display something. For example:
#!/usr/bin/python2importcv2importnumpyasnpimportmatplotlib.pyplotaspltimg=cv2.imread("test.png")
cv2.namedWindow("test", cv2.WINDOW_NORMAL)
cv2.imshow("test", img)
cv2.waitKey(1)
fig=plt.figure()
fig_ax=fig.add_subplot(111)
fig_ax.set_title("test")
fig_ax.grid(True)
fig.show() #<--- Figure should show up & should block. Instead the figure flashes & the script continues.
This is not a bug, and it is not related to cv2, it is just the way Figure.show() works; it is not the same as plt.show(). Figure.show() does not have any blocking logic in it. It doesn't call the gui mainloop, which is what plt.show() uses to block.
@jashandeep-sohi This is all quite confusing, even to me--and I wrote parts of the relevant code and documentation. It appears that the only example use of Figure.show that we have in the mpl examples directory is https://github.com/matplotlib/matplotlib/blob/master/examples/event_handling/pick_event_demo2.py. In this usage, plt.show() is used to run the mainloop, blocking at the end of the script. The user can then interact with a figure; clicking calls up additional figures, which are displayed via Figure.show().
Hi, I'm having problems using OpenCV (cv2) & matplotlib.pyplot. I'm not sure if it's a bug in cv2 or matplotlib, but I'll post here anyways.
Matplotlib figures don't block when their show() method is called after cv2 is also used to display something. For example:
But if plt.show() is used:
Any ideas as to what's going on here?
The text was updated successfully, but these errors were encountered: