When playing local video or reading the camera content, the picture may be large, so that the window spreads almost all over the screen, and there is no way to shrink it. Moreover, the program is looping in the while, and there is no way to close it, which is very disturbing. You need to fix the size of the window in your program.

The pits we walked through are recorded here.

import cv2 cap = cv2.VideoCapture('./1.mp4') fps = cap.get(cv2.CAP_PROP_FPS) while cap.isOpened(): Ret, frame = cap.read() # Note: The string in NamedWindow, ResizeWindow and ImShow must be the same. Cv2.namedWindow ("test", 0) cv2.resizeWindow("test", 500, 300) # Set window length and width cv2.imShow ('test', 0) frame) cv2.waitKey(int(fps)) cap.release() cv2.destroyAllWindows()