本文整理汇总了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)