0

I'm trying to run a real-time Capture of 2 Usb-Cameras (same Reference) USB-Camera_0 --> USB-port 0 USB-Camera_1 --> USB-port 1

I use This Code to make a real time capture for only one camera. To run the second camera (connected to the second usb-Port) at the same time I create another file with the same Code (changing the index 0-->1). I'm asking if it is possible to run this two real time capture in the same Code-file.

thanks

import numpy as np
import cv2

cap = cv2.VideoCapture(0)

while(True):
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Display the resulting frame
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
  • Hi, I think your problem has been solved already here https://stackoverflow.com/questions/48923084/unable-to-run-tune-blockmatcher-and-image-to-pointcloud-programs – VideoProcessingResearcher May 24 '18 at 12:19
  • 1
    Given that you only have one keyboard, which one are you hoping will stop when you press `q`? What are you actually trying to do? – Mark Setchell May 24 '18 at 13:38
  • not sure about @VideoProcessingReacher link. Seems to be unrelated. However, this link [addresses reading two cameras at once](https://stackoverflow.com/questions/29664399/reading-from-two-cameras-in-opencv-at-once). It looks like it can be done, but you either have to do multithreading or add some code to make sure that the read for the first camera is complete before reading the second camera. – bfris May 24 '18 at 17:37

0 Answers0