After cap.release()
the only Frame is getting closed, webcam light is still ON .
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()
By pressing ' q ', the Frame is getting closed but webcam light is still ON.
How to OFF the webcam? (It is getting OFF after python shell is closed.)
If possible, tell me the path of cv2.VideoCapture()
class source code.
Set OPENCV_VIDEOIO_PRIORITY_MSMF=0
in your environment variables. Seems like there is an instance leak in opencv
library. If you're on windows maybe use setx
in your cmd
to set the value setx OPENCV_VIDEOIO_PRIORITY_MSMF 0
.
Reference to the issue : here
And it looks like the issue has been fixed too. So try updating your opencv library or reinstalling altogether. That should solve your problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.