The problem is as follows:
This kind of problem occurs because there is no delay when using the cv2.imshow() function, which leads to the problem that the display is too fast to be displayed.
Solution:
Add a line after cv2.imshow():
cv2.imshow()
cv2.waitKey(3)
Then it will display normally: