issues with cv2.imshow

One of the problems with cv2.imshow is that when you use it, the system will freeze.

This function shows a window but it does not continue and you need to restart the kernel in Ipython.

It happens sometimes in spyder ipython console and opencv.

Solution :

The best solution for this problem is using matplotlib for displaying the image.

For example :

plt.figure()
plt.imshow(cv2.cvtColor(host, cv2.COLOR_BGR2RGB))
plt.title('Cover Image')
plt.show()

In the top code, the host is our input image that we want to display.

If you have many imshow command and you want to give the output image in separated figures, add the following code to the first of your code

from IPython import get_ipython
get_ipython().run_line_magic('matplotlib', 'qt')

Leave a Reply

Your email address will not be published. Required fields are marked *