本文整理匯總了Python中cv2.StereoBM_create方法的典型用法代碼示例。如果您正苦於以下問題:Python cv2.StereoBM_create方法的具體用法?Python cv2.StereoBM_create怎麽用?Python cv2.StereoBM_create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cv2
的用法示例。
在下文中一共展示了cv2.StereoBM_create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: compute_disparity_pyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import StereoBM_create [as 別名]
def compute_disparity_pyramid(self):
self.disparity = []
stereo = cv2.StereoBM_create()
# stereo = cv2.StereoSGBM_create(minDisparity=0,
# numDisparities=64,
# blockSize=11)
# Compute disparity at full resolution and downsample
disp = stereo.compute(self.im_left, self.im_right).astype(float) / 16.
for pyrlevel in range(self.pyrlevels):
if pyrlevel == 0:
self.disparity = [disp]
else:
pyr_factor = 2**-pyrlevel
# disp = cv2.pyrDown(disp) # Applies a large Gaussian blur
# kernel!
disp = disp[0::2, 0::2]
self.disparity.append(disp * pyr_factor)
示例2: compute_depth_pyramid
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import StereoBM_create [as 別名]
def compute_depth_pyramid(self):
self.depth = []
stereo = cv2.StereoBM_create()
# stereo = cv2.StereoSGBM_create(minDisparity=0,
# numDisparities=64,
# blockSize=11)
# Compute disparity at full resolution and downsample
depth = self.data[1]
for pyrlevel in range(self.pyrlevels):
if pyrlevel == 0:
self.depth = [depth]
else:
pyr_factor = 2**-pyrlevel
depth = depth[0::2, 0::2]
self.depth.append(depth)
示例3: stereo_depth_map
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import StereoBM_create [as 別名]
def stereo_depth_map(rectified_pair):
print ('SWS='+str(SWS)+' PFS='+str(PFS)+' PFC='+str(PFC)+' MDS='+\
str(MDS)+' NOD='+str(NOD)+' TTH='+str(TTH))
print (' UR='+str(UR)+' SR='+str(SR)+' SPWS='+str(SPWS))
c, r = rectified_pair[0].shape
disparity = np.zeros((c, r), np.uint8)
sbm = cv2.StereoBM_create(numDisparities=16, blockSize=15)
#sbm.SADWindowSize = SWS
sbm.setPreFilterType(1)
sbm.setPreFilterSize(PFS)
sbm.setPreFilterCap(PFC)
sbm.setMinDisparity(MDS)
sbm.setNumDisparities(NOD)
sbm.setTextureThreshold(TTH)
sbm.setUniquenessRatio(UR)
sbm.setSpeckleRange(SR)
sbm.setSpeckleWindowSize(SPWS)
dmLeft = rectified_pair[0]
dmRight = rectified_pair[1]
#cv2.FindStereoCorrespondenceBM(dmLeft, dmRight, disparity, sbm)
disparity = sbm.compute(dmLeft, dmRight)
#disparity_visual = cv.CreateMat(c, r, cv.CV_8U)
local_max = disparity.max()
local_min = disparity.min()
print ("MAX " + str(local_max))
print ("MIN " + str(local_min))
disparity_visual = (disparity-local_min)*(1.0/(local_max-local_min))
local_max = disparity_visual.max()
local_min = disparity_visual.min()
print ("MAX " + str(local_max))
print ("MIN " + str(local_min))
#cv.Normalize(disparity, disparity_visual, 0, 255, cv.CV_MINMAX)
#disparity_visual = np.array(disparity_visual)
return disparity_visual
示例4: disparity
# 需要導入模塊: import cv2 [as 別名]
# 或者: from cv2 import StereoBM_create [as 別名]
def disparity(self):
matcher = cv2.StereoBM_create(1024, 7)
disparity = matcher.compute(cv2.cvtColor(self.images[0], cv2.COLOR_BGR2GRAY),
cv2.cvtColor(self.images[1], cv2.COLOR_BGR2GRAY))
self.process_output(disparity)