forked from wjb711/Python_learn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2cameras.py
More file actions
38 lines (32 loc) · 865 Bytes
/
2cameras.py
File metadata and controls
38 lines (32 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import cv2
import numpy as np
from matplotlib import pyplot as plt
cap0=cv2.VideoCapture(0)
cap1=cv2.VideoCapture(1)
while cv2.waitKey(1)!=27:
t0=cap0.grab()
#print t0
ret0, frame0=cap0.read()
left=cv2.cvtColor(frame0,6)
r1=cap0.retrieve()
t1=cap1.grab()
#cv2.imshow('0',t1)
r2=cap1.retrieve()
ret1, frame1=cap1.read()
right=cv2.cvtColor(frame1,6)
stereo = cv2.StereoBM(cv2.STEREO_BM_BASIC_PRESET,ndisparities=16, SADWindowSize=15)
disparity = stereo.compute(left,right)
#print t1
#print frame0
#ret1, frame1=cap1.read()
#print frame1
cv2.imshow('0',frame0)
#ret1, frame1=cap1.read()
cv2.imshow('1',frame1)
#cv2.imshow('2',disparity)
#plt.imshow(disparity,'gray')
#plt.show()
#cv2.waitKey(50)
cap0.release()
cap1.release()
cv2.destroyAllWindows()