OpenCV exit code -1073741819 (0xC0000005)

0

This is my program:

import numpy as np
import cv2

cap = cv2.VideoCapture(1)

while(True):

    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break


cap.release()
cv2.destroyAllWindows()

And the result:

exit code -1073741819 (0xC0000005)

I am running my program in Windows 7. My Python version is 3.6 in Pycharm.

python
camera
pycharm
cv2
imshow
asked on Stack Overflow Aug 9, 2020 by Tôn Thất Minh Quân • edited Aug 9, 2020 by Keara

1 Answer

0

I got this code to run on my computer by changing the 1 to a 0 in the line cap = cv2.VideoCapture(1). This integer value determines which camera is used to capture an image. Passing 0 tells OpenCV to use the first camera on your device. If your device, like mine, only has one camera, then telling it to use the second camera by passing 1 will result in errors.

answered on Stack Overflow Aug 9, 2020 by Keara

User contributions licensed under CC BY-SA 3.0