经过cap.release(),唯一的帧被关闭,网络摄像头灯仍然是在上。
import cv2
cap = cv2.VideoCapture(0)
#cap = cv2.VideoCapture(-1) if i give '-1' instead of '0' then light is getting OFF
#but camera is not working because i don't have second camera to laptop.
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cap.isOpened() #returns False
cv2.destroyAllWindows()按下“Q”键,画面就会关闭,但是摄像头的灯仍然亮着。
如何关闭的网络摄像头?(在python关闭之后,它就开始运行了。)
如果可能,请告诉我cv2.VideoCapture()类源代码的路径。
https://stackoverflow.com/questions/52927170
复制相似问题