Ubuntu18.04 under opencv importCV2 imshow () execution does not respond to the solution

Ubuntu18.04 under opencv importCV2 imshow () execution does not respond to the solution

When you were studying "OpenCV 2 Easy Getting Started" for Python-by Li Lizong-did you encounter the same problem as me at the beginning of [Example 1.2].

[Example 1.2]

Display the read image in a window
According to the requirements of the title, write the code as follows:
import cv2
lena = cv2.imread (“lena.bmp”)
cv2.namedWindow (“lesson”)
cv2.imshow (“lesson”, lena)

~~ ~~ As above, when the line cv2.imshow ("lesson", lena) is executed, an error occurs in the window that originally appeared when cv2.namedWindow ("lesson") was executed. Clicking the window crashes—no response.

Solution:

Insert picture description hereAs shown in the figure, enter cv2.waitKey () to appear the normal lesson window. This function is used to wait for the key. Here () does not add parameters, you can gradually recognize it in the learning of the waitKey function.

Published 2 original articles · liked 0 · visits 4

Guess you like

Origin blog.csdn.net/weixin_42597902/article/details/105473492