[英]OpenCV exit code -1073741819 (0xC0000005)
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.我在 Windows 7 中运行我的程序。我的 Python 版本是 Pycharm 中的 3.6。
I got this code to run on my computer by changing the 1 to a 0 in the line cap = cv2.VideoCapture(1)
.我通过将cap = cv2.VideoCapture(1)
行中的 1 更改为 0 来让此代码在我的计算机上运行。 This integer value determines which camera is used to capture an image.这个 integer 值决定了使用哪个相机来捕捉图像。 Passing 0 tells OpenCV to use the first camera on your device.传递 0 告诉 OpenCV 使用设备上的第一个摄像头。 If your device, like mine, only has one camera, then telling it to use the second camera by passing 1 will result in errors.如果你的设备和我的一样只有一个摄像头,那么通过传递 1 来告诉它使用第二个摄像头会导致错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.