コード例 #1
0
 def test_block_match_best5(self):
     error_types = pb.DisparityError.values
     for input_type in [np.uint8, np.float32]:
         factory = pb.FactoryStereoDisparity(input_type)
         for error_type in error_types:
             config = pb.ConfigDisparityBMBest5()
             config.errorType = error_type
             # See that it doesn't crash and returns a non None value
             self.assertTrue(factory.block_match_best5(config))
コード例 #2
0
 def test_sgm(self):
     error_hmi = pb.gateway.jvm.boofcv.factory.disparity.DisparitySgmError.MUTUAL_INFORMATION
     error_types = gateway.jvm.boofcv.factory.disparity.DisparitySgmError.values(
     )
     # SGM only supports U8 images
     for input_type in [np.uint8]:
         factory = pb.FactoryStereoDisparity(input_type)
         for error_type in error_types:
             config = pb.ConfigDisparitySGM()
             config.errorType = error_type
             # See that it doesn't crash and returns a non None value
             self.assertTrue(factory.sgm(config))
コード例 #3
0
    pb.ImageType(image0.getImageType()), True)
distort_right = model_rectifier.create_distortion(
    pb.ImageType(image0.getImageType()), False)

rect0 = image0.createSameShape()
rect1 = image1.createSameShape()

distort_left.apply(image0, rect0)
distort_right.apply(image1, rect1)

# Configure and compute disparity
config = pb.ConfigStereoDisparity()
config.minDisparity = 10
config.maxDisparity = 60

factory = pb.FactoryStereoDisparity(np.uint8)

disparityAlg = factory.region_wta(config)

disparityAlg.process(rect0, rect1)

disparity_image = pb.boof_to_ndarray(disparityAlg.get_disparity_image())
# disparity images is in a weird format.  disparity - min disparity and a value more than max-min if invalid
# legacy from 8bit disparity images
disparity_image[:] += 10
disparity_image[disparity_image > 70] = float('nan')

plt.imshow(disparity_image)
plt.show()

print("Done!")