Hrushi
Hrushi

Reputation: 499

cv2.imshow not working when using with plt.show

I am working on opencv4 and python 3 with matplotlib version 3.2.0 .

cv2.imshow("Original",image)
#after few lines
plt.plot(hist)
plt.xlim([0, 256])
plt.show()
cv2.waitKey(0)

The image is not displayed but only the plt.show is displayed. The image is displayed after closing the graph. I want them to be showed together, is it possible? This is the first time I am using matplotlib and only installed python3-tk. Is there anything else I should do? Would be grateful for any help.

Upvotes: 2

Views: 772

Answers (1)

Andrey  Smorodov
Andrey Smorodov

Reputation: 10852

plt.show() waits when you close plot window. imshow waits for waitKey call to show window. Put waitKey(205) just after imshow, it should work.

Upvotes: 2

Related Questions