From f65b4fa45ad720b063ae63ac2d701cc8b0132449 Mon Sep 17 00:00:00 2001 From: ros Date: Tue, 28 Mar 2023 16:08:20 +0200 Subject: [PATCH] branch dev tout marche pas, test12 and paramgui --- disparityParam_gui.py | 33 ++++++++++++++++++--------------- test12.py | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 test12.py diff --git a/disparityParam_gui.py b/disparityParam_gui.py index 0b450c9..1c7cd94 100644 --- a/disparityParam_gui.py +++ b/disparityParam_gui.py @@ -4,29 +4,30 @@ 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 = 6# Camera ID for left camera +CamR_id = 8# Camera ID for right camera -CamL= cv2.VideoCapture(CamL_id) -CamR= cv2.VideoCapture(CamR_id) - - - - -retL, imgL= CamL.read() -retR, imgR= CamR.read() - -imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY) -imgL_gray = cv2.cvtColor(imgL,cv2.COLOR_BGR2GRAY) -print("la c bon") +CamR= cv2.VideoCapture(CamR_id, cv2.CAP_V4L2) +CamL= cv2.VideoCapture(CamL_id, cv2.CAP_V4L2) +''' +while True: + ret, frame = CamR.read() + if ret: + codec=CamR.get(cv2.CAP_PROP_FOURCC) + print("codec: ",codec) + sdfgh +''' # Reading the mapping values for stereo image rectification cv_file = cv2.FileStorage("data/params_py.xml", cv2.FILE_STORAGE_READ) + Left_Stereo_Map_x = cv_file.getNode("Left_Stereo_Map_x").mat() + Left_Stereo_Map_y = cv_file.getNode("Left_Stereo_Map_y").mat() Right_Stereo_Map_x = cv_file.getNode("Right_Stereo_Map_x").mat() Right_Stereo_Map_y = cv_file.getNode("Right_Stereo_Map_y").mat() cv_file.release() + def nothing(x): pass @@ -47,12 +48,14 @@ cv2.createTrackbar('minDisparity','disp',5,25,nothing) # Creating an object of StereoBM algorithm stereo = cv2.StereoBM_create() + while True: # Capturing and storing left and right camera images retL, imgL= CamL.read() retR, imgR= CamR.read() + waitkey(0) # Proceed only if the frames have been captured if retL and retR: imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY) @@ -122,7 +125,7 @@ while True: else: CamL= cv2.VideoCapture(CamL_id) CamR= cv2.VideoCapture(CamR_id) - + waitKey(0) print("Saving depth estimation paraeters ......") cv_file = cv2.FileStorage("../data/depth_estmation_params_py.xml", cv2.FILE_STORAGE_WRITE) diff --git a/test12.py b/test12.py new file mode 100644 index 0000000..7c3911d --- /dev/null +++ b/test12.py @@ -0,0 +1,21 @@ +import cv2 + +ID1 = 6 +ID2 = 8 +cam1 = cv2.VideoCapture(ID1, cv2.CAP_V4L2) +cam1.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG')) +cam2 = cv2.VideoCapture(ID2, cv2.CAP_V4L2) +cam2.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc(*'MJPG')) + +while True: + ret1, frame1 = cam1.read() + ret2, frame2 = cam2.read() + + cv2.imshow('Camera 1', frame1) + cv2.imshow('Camera 2', frame2) + + if cv2.waitKey(1) == ord('q'): + break +cam1.release() +cam2.release() +cv2.destroyAllWindows()