Python OpenCV - Update camera index of live webcam view -
i viewing webcam camera live feed. incorporate tkinter gui , have dropdown selection allows 1 change camera index, , therefore webcam being used, on fly. how can achieved? example code: import cv2 def show_webcam(mirror=false): cam = cv2.videocapture(0) while true: ret_val, img = cam.read() if mirror: img = cv2.flip(img, 1) cv2.imshow('my webcam', img) if cv2.waitkey(1) == 27: break # esc quit cv2.destroyallwindows() def main(): show_webcam(mirror=true) if __name__ == '__main__': main() to change camera @ run time need change index pass in cv2.videocapture(index) . find out how many camera using app , 3 cameras, can change through changing index 0 or 1 or 2. add 1 more parameter index show_webcam(mirror=true, index) in function side can use this def show_webcam(mirror=false,index): cam = cv2.videocapture(index) while true: ret_val, img = cam.read()...