When trying to capture frames from two cameras (using a single USB hub) simultaneously, only one camera can return a valid frame, the other one will return None. When using one external camera and the internal camera from the laptop, it works fine.
The exact same code and hardware work fine on a Ubuntu system. So it might be problem with Windows or its driver, or there is something wrong using the hub (maybe bandwidth problem, but not power problem because the hub has external power supply)
import cv2
import numpy as np
from multiprocessing import Process
def show(camera_id):
cap = cv2.VideoCapture(camera_id)
cap.set(3,640)
cap.set(4,480)
cap.set(cv2.CAP_PROP_FPS, 30)
while True:
ret, frame = cap.read()
cv2.imshow('test', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
if __name__ == '__main__':
p1 = Process(target=show, args=(0,))
p2 = Process(target=show, args=(1,))
p1.start()
p2.start()