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

前端 未结 16 2329
既然无缘
既然无缘 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:43

    This Error can also occur if you slice a negative point and pass it to the array. So check if you did

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

    I use ssh to connect to remote server and have python code execute cv2.VideoCapture(0) to capture remote webcam, then encounter this error message:

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

    Finally, I have to grant access to /dev/video0 (which is my webcam device) with my user account and the error message was gone. Use usermod to add user into group video

    usermod -a -G video user
    
    0 讨论(0)
  • 2020-11-29 09:48

    I have the same problem, fix the ret in capture video

    import numpy as np
    import cv2
    
    # Capture video from file
    cap = cv2.VideoCapture('video1.avi')
    
    while True:
    
        ret, frame = cap.read()
    
        if ret == True:
    
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    
            cv2.imshow('frame',gray)
    
    
            if cv2.waitKey(30) & 0xFF == ord('q'):
                break
    
        else:
            break
    
    cap.release()
    cv2.destroyAllWindows()
    
    0 讨论(0)
  • 2020-11-29 09:49

    I also met the error message in raspberry pi 3, but my solution is reload kernel of camera after search on google, hope it can help you.

    sudo modprobe bcm2835-v4l2

    BTW, for this error please check your camera and file path is workable or not

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