anonymus_lte
anonymus_lte

Reputation: 51

How check status of Web Camera using Python

I have a setup of web application and Hardware(which has camera integrated), My job is to

1.Check cam in hardware is capturing video(when a video call is initiated from the web application to Hardware). 2.Check cam in my laptop is capturing video(when a video call is initiated from hardware to web application).

I don't want to capture video from Cam, All I need to check the status of Camera(whether it is capturing video or not).Is there any way to check this scenario using python?

Thanks in advance.

Upvotes: 2

Views: 5111

Answers (2)

avereux
avereux

Reputation: 607

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    if cap.isOpened():
        print("Webcam online.")

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()

Upvotes: 2

Kentonium
Kentonium

Reputation: 33

Pretty sure you're looking for:yourCamVar.isOpened(). This checks if it's capturing video.

Lots of information on that here.

Upvotes: 2

Related Questions