cv2.imshow() function is opening a window that always says not responding - python opencv

后端 未结 9 1051
长情又很酷
长情又很酷 2020-12-13 17:54

I am trying to run a very simple program. To open and jpg file and display it using the opencv library for python. Initially it all worked fine but now it just opens a windo

9条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 18:21

    The cv2.imshow() function always takes two more functions to load and close the image. These two functions are cv2.waitKey() and cv2.destroyAllWindows(). Inside the cv2.waitKey() function, you can provide any value to close the image and continue with further lines of code.

        # First line will provide resizing ability to the window
        cv.namedWindow('Amanda', cv.WINDOW_AUTOSIZE)
    
        # Show the image, note that the name of the output window must be same
        cv.imshow('Amanda', img)
    
        # T0 load and hold the image
        cv.waitKey(0)
    
        # To close the window after the required kill value was provided
        cv.destroyAllWindows()
    

    Hoping that you will get the image in a separate window now.

提交回复
热议问题