1

System Architecture:

  • Fedora 27
  • OpenCV 3.4
  • Python 3.6

The issue produced from the following code:

def capture_input():
    cap = cv2.VideoCapture(0)

    while 1:

        # Take each frame
        ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 45)
        ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 45)
        ret, frame = cap.read()
        frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
        cv2.imshow("Detecting Digits Frame", frame)
        if cv2.waitKey(1) & 0xFF == ord('q'):
            frame = cv2.resize(frame, (45, 45))
            break

    cap.release()
    cv2.destroyAllWindows()
    return frame

The code works as expected sometimes, the other times it refuses to run producing:

select timeout cv2.error:/io/opencv/modules/core/include/opencv2/core/mat.inl.hpp:500: error: (-215) total() == 0 || data != __null in function Mat

Not only that. Moreover, the webcam does not even work after that, I tried opening it with Cheese, it show a black screen and buttons are grayed out.

I tried to follow these SO links:

but with no success, and same for the other GitHub links.

Thanks in advance.

  • 1
    Did you consider reporting this in the OpenCV issue tracker? (And BTW, this whole thing reads like a bug report, rather than a question -- in fact it seems like you forgot to ask one.) – Dan Mašek Apr 25 '18 at 19:07
  • Did you try the code without the two lines setting height and width `ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 45)` ? – fireant Apr 26 '18 at 08:50

0 Answers0