Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to check if webcam is busy

Hello,

is there a way to check if webcam is busy before taking an image? Python.exe would crash if camera is in use and following code is running

Python code: from cv2 import * while True: #need to check here if camera is busy cam = VideoCapture(0) s, img = cam.read() if s: # frame captured without any errors imwrite("filename.jpg",img) #save image

How to check if webcam is busy

Hello,

is there a way to check if webcam is busy before taking an image? Python.exe would crash if camera is in use and following code is running

Python code: code:

from cv2 import *
while True:
    #need to check here if camera is busy
    cam = VideoCapture(0)
    s, img = cam.read()
    if s:    # frame captured without any errors
        imwrite("filename.jpg",img) #save image 

image