cv2.imshow command doesn't work properly in opencv-python

前端 未结 16 1646
轻奢々
轻奢々 2020-12-04 17:31

I\'m using opencv 2.4.2, python 2.7 The following simple code created a window of the correct name, but its content is just blank and doesn\'t show the image:



        
16条回答
  •  独厮守ぢ
    2020-12-04 17:50

    I found the answer that worked for me here: http://txt.arboreus.com/2012/07/11/highgui-opencv-window-from-ipython.html

    If you run an interactive ipython session, and want to use highgui windows, do cv2.startWindowThread() first.

    In detail: HighGUI is a simplified interface to display images and video from OpenCV code. It should be as easy as:

    import cv2
    img = cv2.imread("image.jpg")
    cv2.startWindowThread()
    cv2.namedWindow("preview")
    cv2.imshow("preview", img)
    

提交回复
热议问题