hello
after a lot of research i discovered a partial fix however it is quite janky. basically i use run from subprocess to call ffmpeg with this command
ffmpeg -f avfoundation -list_devices true -i “”
in the command line which then returns the name and opencv camera index for all cameras, then you simply find the index corresponding to your cameras name and use that with opencv. i dont know how this will function with multiple of the same camera tho as i only have one webcam to test with, there might be a similar function that can return a unique id for each camera using ffmpeg but im unaware if one exists
heres my code
import cv2
import os
from subprocess import PIPE, run
camera_name = "Arducam OV9281 USB Camera"
command = ['ffmpeg','-f', 'avfoundation','-list_devices','true','-i','""']
result = run(command, stdout=PIPE, stderr=PIPE, universal_newlines=True)
cam_id = 0
for item in result.stderr.splitlines():
if camera_name in item:
cam_id = int(item.split("[")[2].split(']')[0])
print("cam id", cam_id)
cap = cv2.VideoCapture(cam_id)
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
ret_val , cap_for_exposure = cap.read()
in future i hope to find a way that can just use which usb port the camera is connected too