<filename>show_cameras.py<gh_stars>1-10
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 15 08:37:26 2020

@author: Bill
"""
import cv2

def list_cameras(max2check=None):
    if max2check is None:
        max2check = 1000
    index = 0
    arr = []
    for index in range(max2check):
        cap = cv2.VideoCapture(index)
        if not cap.read()[0]:
            pass
        else:
            arr.append(index)
        cap.release()
        
    
    return arr

if __name__=="__main__":
    cmax = 10
    print('Looking for connected cameras, as many as',cmax)
    some_cams = list_cameras(max2check=cmax)
    
    if some_cams:
        for c in some_cams:
            cap = cv2.VideoCapture(c)
            cv2.imshow(str(c), cap.read()[1])
            cap.release()
        
<filename>show_cameras.py<gh_stars>1-10
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 15 08:37:26 2020

@author: Bill
"""
import cv2

def list_cameras(max2check=None):
    if max2check is None:
        max2check = 1000
    index = 0
    arr = []
    for index in range(max2check):
        cap = cv2.VideoCapture(index)
        if not cap.read()[0]:
            pass
        else:
            arr.append(index)
        cap.release()
        
    
    return arr

if __name__=="__main__":
    cmax = 10
    print('Looking for connected cameras, as many as',cmax)
    some_cams = list_cameras(max2check=cmax)
    
    if some_cams:
        for c in some_cams:
            cap = cv2.VideoCapture(c)
            cv2.imshow(str(c), cap.read()[1])
            cap.release()
        
# -*- coding: utf-8 -*- Created on Wed Jan 15 08:37:26 2020  @author: Bill