2

I tried to run simple code in python(3.6) open cv2 latest version. But when I want to show the image using cv2.imshow(), the image is not opened. And it says 'python is not responding', and shows an empty window.

This is the output. I kept the images in the same folder as the code for simplicity, yet it doesn't work. And there's no error either. I am using 'Spyder' ide to write the code. The code is as follows,

import numpy as np
import cv2
im= cv2.imread('pic.jpg', 1)
cv2.imshow('1', im)
nathancy
  • 42,661
  • 14
  • 115
  • 137
Jd_mahmud
  • 41
  • 6

1 Answers1

1

In cv2 imshow() should be followed by cv2.waitKey()

try this :

import numpy as np
import cv2
im= cv2.imread('pic.jpg', 1)
cv2.imshow('1', im)
cv2.waitKey()
nassim
  • 1,547
  • 1
  • 14
  • 26