mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-29 02:21:41 +00:00
FIilter usb devices
This commit is contained in:
19
backend/app/classes/CamerasHandler.py
Normal file
19
backend/app/classes/CamerasHandler.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import cscore
|
||||
import cv2
|
||||
|
||||
|
||||
class CamerasHandler:
|
||||
|
||||
@staticmethod
|
||||
def get_cameras():
|
||||
arr = []
|
||||
|
||||
usb_devices = cscore.UsbCamera.enumerateUsbCameras()
|
||||
|
||||
for index in range(len(usb_devices)):
|
||||
cap = cv2.VideoCapture(index)
|
||||
if cap.isOpened():
|
||||
arr.append(index)
|
||||
cap.release()
|
||||
index += 1
|
||||
return [usb_devices[i] for i in arr]
|
||||
Reference in New Issue
Block a user