ça maaarche
This commit is contained in:
parent
2c3aee2937
commit
de8ad0b82c
|
|
@ -4,20 +4,21 @@ 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 = 2# Camera ID for left camera
|
||||||
CamR_id = 5# Camera ID for right camera
|
CamR_id = 0# Camera ID for right camera
|
||||||
|
|
||||||
CamL= cv2.VideoCapture(CamL_id)
|
#CamL= cv2.VideoCapture(CamL_id)
|
||||||
CamR= cv2.VideoCapture(CamR_id)
|
#CamR= cv2.VideoCapture(CamR_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
retL, imgL= CamL.read()
|
retL, imgL= cv2.VideoCapture(CamL_id, cv2.CAP_V4L2).read()
|
||||||
retR, imgR= CamR.read()
|
retR, imgR= cv2.VideoCapture(CamR_id, cv2.CAP_V4L2).read()
|
||||||
|
|
||||||
imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY)
|
imgR_gray = cv2.cvtColor(imgR,cv2.COLOR_BGR2GRAY)
|
||||||
imgL_gray = cv2.cvtColor(imgL,cv2.COLOR_BGR2GRAY)
|
imgL_gray = cv2.cvtColor(imgL,cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
print("la c bon")
|
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)
|
||||||
|
|
@ -50,8 +51,8 @@ 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= cv2.VideoCapture(CamL_id, cv2.CAP_V4L2).read()
|
||||||
retR, imgR= CamR.read()
|
retR, imgR= cv2.VideoCapture(CamR_id, cv2.CAP_V4L2).read()
|
||||||
|
|
||||||
# Proceed only if the frames have been captured
|
# Proceed only if the frames have been captured
|
||||||
if retL and retR:
|
if retL and retR:
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
Loading…
Reference in New Issue