Trouble With " Cv2.imshow ()" Function
I installed openCV and numpy libraries in python 2.7. I've tested them using commands import cv2 and import numpy and it compiled. But when I use the cv2.imshow('frame', ----) func
Solution 1:
imshow should be followed by waitKey function which displays the image for specified milliseconds. Otherwise, it won’t display the image. For example, waitKey(0) will display the window infinitely until any keypress (it is suitable for image display). waitKey(25) will display a frame for 25 ms, after which display will be automatically closed. (If you put it in a loop to read videos, it will display the video frame-by-frame). Here's a working example:
importcv2img= cv2.imread('a.jpg')
cv2.imshow('FRAME', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Solution 2:
Try using imread like this
img = cv2.imread('a.jpg',0)#grayscaleimg = cv2.imread('a.jpg',1)#rgb
Post a Comment for "Trouble With " Cv2.imshow ()" Function"