“how to count how many cameras you have with python” Kode Jawaban

how to count how many cameras you have with python

import cv2

def camera_amount():
    '''Returns int value of available camera devices connected to the host device'''
    camera = 0
    while True:
        if (cv2.VideoCapture(camera).grab()) is True:
            camera = camera + 1
        else:
            cv2.destroyAllWindows()
            return(int(camera))
Condemned Camel

how to check how many cameras are connected to device in python\

import cv2

def clearCapture(capture):
    capture.release()
    cv2.destroyAllWindows()

def countCameras():
    n = 0
    for i in range(10):
        try:
            cap = cv2.VideoCapture(i)
            ret, frame = cap.read()
            cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            clearCapture(cap)
            n += 1
        except:
            clearCapture(cap)
            break
    return n

print countCameras()
Healthy Hornet

Jawaban yang mirip dengan “how to count how many cameras you have with python”

Pertanyaan yang mirip dengan “how to count how many cameras you have with python”

Lebih banyak jawaban terkait untuk “how to count how many cameras you have with python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya