From de8ad0b82cde89271db4248465862c10b42c8fb7 Mon Sep 17 00:00:00 2001 From: ros Date: Tue, 28 Mar 2023 17:15:45 +0200 Subject: [PATCH] =?UTF-8?q?=C3=A7a=20maaarche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- disparityParam_gui.py | 17 +++++++++-------- file1.txt | 1 + file2.txt | 1 + test12.py | 27 +++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 file1.txt create mode 100644 file2.txt create mode 100644 test12.py diff --git a/disparityParam_gui.py b/disparityParam_gui.py index 0b450c9..9dcffa1 100644 --- a/disparityParam_gui.py +++ b/disparityParam_gui.py @@ -4,20 +4,21 @@ import cv2 # Check for left and right camera IDs # These values can change depending on the system -CamL_id = 1# Camera ID for left camera -CamR_id = 5# Camera ID for right camera +CamL_id = 2# Camera ID for left camera +CamR_id = 0# Camera ID for right camera -CamL= cv2.VideoCapture(CamL_id) -CamR= cv2.VideoCapture(CamR_id) +#CamL= cv2.VideoCapture(CamL_id) +#CamR= cv2.VideoCapture(CamR_id) -retL, imgL= CamL.read() -retR, imgR= CamR.read() +retL, imgL= cv2.VideoCapture(CamL_id, cv2.CAP_V4L2).read() +retR, imgR= cv2.VideoCapture(CamR_id, cv2.CAP_V4L2).read() imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY) imgL_gray = cv2.cvtColor(imgL,cv2.COLOR_BGR2GRAY) + print("la c bon") # Reading the mapping values for stereo image rectification cv_file = cv2.FileStorage("data/params_py.xml", cv2.FILE_STORAGE_READ) @@ -50,8 +51,8 @@ stereo = cv2.StereoBM_create() while True: # Capturing and storing left and right camera images - retL, imgL= CamL.read() - retR, imgR= CamR.read() + retL, imgL= cv2.VideoCapture(CamL_id, cv2.CAP_V4L2).read() + retR, imgR= cv2.VideoCapture(CamR_id, cv2.CAP_V4L2).read() # Proceed only if the frames have been captured if retL and retR: diff --git a/file1.txt b/file1.txt new file mode 100644 index 0000000..e212970 --- /dev/null +++ b/file1.txt @@ -0,0 +1 @@ +file1 diff --git a/file2.txt b/file2.txt new file mode 100644 index 0000000..6c493ff --- /dev/null +++ b/file2.txt @@ -0,0 +1 @@ +file2 diff --git a/test12.py b/test12.py new file mode 100644 index 0000000..44fb09a --- /dev/null +++ b/test12.py @@ -0,0 +1,27 @@ +import cv2 + +ID1 = 2 +ID2 = 0 +#cam1 = cv2.VideoCapture(ID2, cv2.CAP_V4L2) +#cam1.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG')) +#cam2 = cv2.VideoCapture(ID1, cv2.CAP_V4L2) +#cam2.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG')) + +while True: + + ret2, frame2 = cv2.VideoCapture(ID1, cv2.CAP_V4L2).read() + ret1, frame1 = cv2.VideoCapture(ID2, cv2.CAP_V4L2).read() + + print("ret 1 = ", ret1) + print("ret 2 = ", ret2) + + cv2.imshow('Camera 1', frame1) + cv2.imshow('Camera 2', frame2) + + + if cv2.waitKey(1) == ord('q'): + break + +cam1.release() +cam2.release() +cv2.destroyAllWindows()