Jan-12-2021, 11:19 PM
This is what I'm trying (it's the beginning of a cv2 powered OMR multiple choice marking program) :
Along the way, I want to check on the image, see what it looks like.
According to what I read, cv2.waitkey(0) should wait for a key to be pressed, then, I thought, dismiss the image window.
But what I am getting is this:
I enter this in Idle:
I enter this in Idle:
cv2.waitKey(3000)
My image pops up in a window. After 3 seconds, Idle shows:
The window with my image is still there. This kills it.
cv2.destroyAllWindows()
Shouldn't the image window disappear after 3 seconds?? If not, what is the point??
If I set:
I can not get out of waitkey(0)
Doesn't matter what key I press, I remain waiting. Ctrl-c cannot break the loop in Idle, only shell restart gives me the shell back.
Obviously, I am doing something wrong. Any tips please??
Along the way, I want to check on the image, see what it looks like.
# load the image, convert it to grayscale, blur it # slightly, then find edges mypath = '/home/pedro/PDF_IN/test1.png' # image = cv2.imread(args["image"]) image = cv2.imread(mypath) # check that the image loads ok cv2.imshow("Original image", image) cv2.waitKey(0) cv2.destroyAllWindows() gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) blurred = cv2.GaussianBlur(gray, (5, 5), 0) edged = cv2.Canny(blurred, 75, 200)Without cv2.waitkey() the Python kernel will crash. (Tried a few times!)
According to what I read, cv2.waitkey(0) should wait for a key to be pressed, then, I thought, dismiss the image window.
But what I am getting is this:
I enter this in Idle:
Quote:cv2.imshow("Original image", image)I get a little window with no content, a bit greyish.
I enter this in Idle:
cv2.waitKey(3000)
My image pops up in a window. After 3 seconds, Idle shows:
Quote:>>> cv2.waitKey(3000)
-1
The window with my image is still there. This kills it.
cv2.destroyAllWindows()
Shouldn't the image window disappear after 3 seconds?? If not, what is the point??
If I set:
Quote:cv2.waitKey(0)
I can not get out of waitkey(0)
Doesn't matter what key I press, I remain waiting. Ctrl-c cannot break the loop in Idle, only shell restart gives me the shell back.
Quote:>>> cv2.waitKey(0)
w
vvv
mm
Obviously, I am doing something wrong. Any tips please??