我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用cv2.StereoBM_create()。
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)
def readyStereoBM(roi1, roi2): stereobm = cv2.StereoBM_create(numDisparities=112, blockSize=31) stereobm.setPreFilterSize(31)#41 stereobm.setPreFilterType(cv2.STEREO_BM_PREFILTER_NORMALIZED_RESPONSE) stereobm.setPreFilterCap(31) stereobm.setTextureThreshold(10) stereobm.setMinDisparity(0) stereobm.setSpeckleWindowSize(100) stereobm.setSpeckleRange(64) stereobm.setUniquenessRatio(0) stereobm.setROI1(roi1) stereobm.setROI1(roi2) return stereobm