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

前端 未结 16 2327
既然无缘
既然无缘 2020-11-29 09:09

I am trying to make a face tracker that combines Haar Cascade Classification with Lucas Kanade good feature detection. However, I keep getting an error that I cannot figure

相关标签:
16条回答
  • 2020-11-29 09:23

    This error message

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

    simply means that imshow() is not getting video frame from input-device. You can try using

    cap = cv2.VideoCapture(1) 
    

    instead of

    cap = cv2.VideoCapture(0) 
    

    & see if the problem still persists.

    0 讨论(0)
  • 2020-11-29 09:23

    This is a problem with space consumption or choosing the wrong camera. My suggestion in to restart kernel and clear output and run it again. It works then.

    0 讨论(0)
  • 2020-11-29 09:24

    Check if you have "opencv_ffmpeg330.dll" in python27 root directory or of the python version you are using. If not you will find it in "....\OpenCV\opencv\build\bin".

    Choose the appropriate version and copy the dll into the root directory of your python installation and re-run the program

    0 讨论(0)
  • 2020-11-29 09:26

    I had this problem.

    Solution: Update the path of the image.

    If the path contains (for example: \n or \t or \a) it adds to the corruption. Therefore, change every back-slash "\" with front-slash "/" and it will not make create error but fix the issue of reading path.

    Also double check the file path/name. any typo in the name or path also gives the same error.

    0 讨论(0)
  • 2020-11-29 09:26

    Simply use an image extension like .jpeg or .png.

    0 讨论(0)
  • 2020-11-29 09:32

    You have to delay

    Example Code:

    import cv2
    import numpy as np
    import time
    
    cam = cv2.VideoCapture(0)
    time.sleep(2)
    
    while True:
        ret,frame = cam.read()
        cv2.imshow('webcam', frame)
        if cv2.waitKey(1)&0xFF == ord('q'):
            break
    
    cam.release()
    cv2.destroyAllWindows()
    
    0 讨论(0)
提交回复
热议问题