|
|
|
@ -4,29 +4,30 @@ import cv2
|
|
|
|
|
|
|
|
|
|
|
|
# Check for left and right camera IDs
|
|
|
|
# Check for left and right camera IDs
|
|
|
|
# These values can change depending on the system
|
|
|
|
# These values can change depending on the system
|
|
|
|
CamL_id = 1# Camera ID for left camera
|
|
|
|
CamL_id = 6# Camera ID for left camera
|
|
|
|
CamR_id = 5# Camera ID for right camera
|
|
|
|
CamR_id = 8# Camera ID for right camera
|
|
|
|
|
|
|
|
|
|
|
|
CamL= cv2.VideoCapture(CamL_id)
|
|
|
|
CamR= cv2.VideoCapture(CamR_id, cv2.CAP_V4L2)
|
|
|
|
CamR= cv2.VideoCapture(CamR_id)
|
|
|
|
CamL= cv2.VideoCapture(CamL_id, cv2.CAP_V4L2)
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
while True:
|
|
|
|
|
|
|
|
ret, frame = CamR.read()
|
|
|
|
|
|
|
|
if ret:
|
|
|
|
retL, imgL= CamL.read()
|
|
|
|
codec=CamR.get(cv2.CAP_PROP_FOURCC)
|
|
|
|
retR, imgR= CamR.read()
|
|
|
|
print("codec: ",codec)
|
|
|
|
|
|
|
|
sdfgh
|
|
|
|
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
|
|
|
|
# Reading the mapping values for stereo image rectification
|
|
|
|
cv_file = cv2.FileStorage("data/params_py.xml", cv2.FILE_STORAGE_READ)
|
|
|
|
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_x = cv_file.getNode("Left_Stereo_Map_x").mat()
|
|
|
|
|
|
|
|
|
|
|
|
Left_Stereo_Map_y = cv_file.getNode("Left_Stereo_Map_y").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_x = cv_file.getNode("Right_Stereo_Map_x").mat()
|
|
|
|
Right_Stereo_Map_y = cv_file.getNode("Right_Stereo_Map_y").mat()
|
|
|
|
Right_Stereo_Map_y = cv_file.getNode("Right_Stereo_Map_y").mat()
|
|
|
|
cv_file.release()
|
|
|
|
cv_file.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def nothing(x):
|
|
|
|
def nothing(x):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
@ -47,12 +48,14 @@ cv2.createTrackbar('minDisparity','disp',5,25,nothing)
|
|
|
|
|
|
|
|
|
|
|
|
# Creating an object of StereoBM algorithm
|
|
|
|
# Creating an object of StereoBM algorithm
|
|
|
|
stereo = cv2.StereoBM_create()
|
|
|
|
stereo = cv2.StereoBM_create()
|
|
|
|
|
|
|
|
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
|
|
|
|
|
|
|
|
# Capturing and storing left and right camera images
|
|
|
|
# Capturing and storing left and right camera images
|
|
|
|
retL, imgL= CamL.read()
|
|
|
|
retL, imgL= CamL.read()
|
|
|
|
retR, imgR= CamR.read()
|
|
|
|
retR, imgR= CamR.read()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
waitkey(0)
|
|
|
|
# Proceed only if the frames have been captured
|
|
|
|
# Proceed only if the frames have been captured
|
|
|
|
if retL and retR:
|
|
|
|
if retL and retR:
|
|
|
|
imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY)
|
|
|
|
imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY)
|
|
|
|
@ -122,7 +125,7 @@ while True:
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
CamL= cv2.VideoCapture(CamL_id)
|
|
|
|
CamL= cv2.VideoCapture(CamL_id)
|
|
|
|
CamR= cv2.VideoCapture(CamR_id)
|
|
|
|
CamR= cv2.VideoCapture(CamR_id)
|
|
|
|
|
|
|
|
waitKey(0)
|
|
|
|
print("Saving depth estimation paraeters ......")
|
|
|
|
print("Saving depth estimation paraeters ......")
|
|
|
|
|
|
|
|
|
|
|
|
cv_file = cv2.FileStorage("../data/depth_estmation_params_py.xml", cv2.FILE_STORAGE_WRITE)
|
|
|
|
cv_file = cv2.FileStorage("../data/depth_estmation_params_py.xml", cv2.FILE_STORAGE_WRITE)
|
|
|
|
|