The problem with the function "cv2.imshow ()"

I installed the openCV and numpy libraries in python 2.7.

I tested them using the commands import cv2and import numpyand compiled.

But when I use the function cv2.imshow('frame', ----), it displays a window, but does not display an image. And he shows that "the frame is not responding."

So, I tried using matplotlib functions to display the image, and it worked.

I inserted a function cv2.imshowin the second case, and it worked.

Versions [Python-2.7.10, OpenCV-2.4.11]

Below is the code,

Case 1: Does not work, showing the window, but not the image (showing HOW DOES NOT FAIL)

import cv2
import numpy 

img = cv2.imread('a.jpg')
cv2.imshow('FRAME',img)

Case 2: Work

import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2

img = mpimg.imread('a.jpg')
img2 = cv2.imread('b.jpg')
cv2.imshow('FRAME',img2)
plt.imshow(img)
plt.show()
+4
2

imshow waitKey, . . , waitKey (0) , ( ). waitKey (25) 25 , . ( , ). :

import cv2

img = cv2.imread('a.jpg')
cv2.imshow('FRAME', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
+12

imread,

img = cv2.imread('a.jpg',0)#grayscale
img = cv2.imread('a.jpg',1)#rgb
-1

Source: https://habr.com/ru/post/1663359/


All Articles