How to specify exact camera by id to prevent two usb cameras from being switched around macos

what i need is the ability for two usb cameras to not get switched around so i would have camera A pointing in one direction then camera B pointing in a different direction and within opencv even after a reboot or unpluging the cameras each of those cameras remains associated to the proper frame

but when trying to do this using indexes
cap = cv2.VideoCapture(1)
sometimes it will access my built in webcam or the usb camera attached to it or a 3rd camera if thats attached, ive heard that on linux you can specify which webcam you want with
cap = cv2.VideoCapture("/dev/video0")
but there does not seam to be an analogue to this on mac

im on an m1 air ventura 13.2.1

and here is my example code

import cv2
import os
cwd = os.getcwd()
cap = cv2.VideoCapture(1)

cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
ret, img =
path = cwd + "/calibrationimages/"
count = 0
while True:
    name = path + str(count)+".jpg"
    ret, img =
    cv2.imshow("img", img)

    if cv2.waitKey(20) & 0xFF == ord('c'):
        cv2.imwrite(name, img)
        cv2.imshow("img", img)
        count += 1
        if cv2.waitKey(0) & 0xFF == ord('q'):


I don’t know on MacOS, but on Linux you have alternative path for the camera in /dev/v4l/by-id/, where the file name contains the unique camera ID.

Maybe you have a similar thing in MacOS.

hi i have tried that but for one i cant seam to figure out what the correct name for the camera would be and the tools to list out whats there don’t say much about a /dev/ folder