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

前端 未结 16 1554
轻奢々
轻奢々 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:37

    I had the same 215 error, which I was able to overcome by giving the full path to the image, as in, C:\Folder1\Folder2\filename.ext

    0 讨论(0)
  • 2020-12-04 17:38

    For me waitKey() with number greater than 0 worked

        cv2.waitKey(1)
    
    0 讨论(0)
  • 2020-12-04 17:39

    I also had a -215 error. I thought imshow was the issue, but when I changed imread to read in a non-existent file I got no error there. So I put the image file in the working folder and added cv2.waitKey(0) and it worked.

    0 讨论(0)
  • 2020-12-04 17:40

    If you are running inside a Python console, do this:

    img = cv2.imread("yourimage.jpg")
    
    cv2.imshow("img", img); cv2.waitKey(0); cv2.destroyAllWindows()
    

    Then if you press Enter on the image, it will successfully close the image and you can proceed running other commands.

    0 讨论(0)
  • 2020-12-04 17:43

    You've got all the necessary pieces somewhere in this thread:

    if cv2.waitKey(): cv2.destroyAllWindows()
    

    works fine for me in IDLE.

    0 讨论(0)
  • 2020-12-04 17:43

    error: (-215) size.width>0 && size.height>0 in function imshow

    This error is produced because the image is not found. So it's not an error of imshow function.

    0 讨论(0)
提交回复
热议问题