一旦代码在ubuntu-opencv-python中运行,网络摄像头就会一次又一次地停止



我想从网络摄像头中捕捉图像,然后在Ubuntu 14.04中使用opencv 2.4.10在python 2.7中进一步进行ANPR(自动车牌识别)的图像处理。当我运行这个简单的代码时,它会检测到我的相机一次,然后相机停止工作。代码为:

import cv2
cam = cv2.VideoCapture(0)
s, img = cam.read()
winName = "Movement Indicator"
cv2.namedWindow(winName, cv2.CV_WINDOW_AUTOSIZE)
while s:
  cv2.imshow( winName,img )
  s, img = cam.read()
  key = cv2.waitKey(10) & 0xFF
  if key == 27:
    cv2.destroyWindow(winName)
    break
print "Goodbye"

有人能帮我做这个吗?

得到了答案。我没有松开摄像头。它现在工作正常

相关内容

最新更新