def __init__(self, java_object=None): self.left = pyboof.CameraPinhole() self.right = pyboof.CameraPinhole() self.right_to_left = pyboof.Se3_F64() if java_object is not None: self.set_from_boof(java_object)
def test_save_load(self): calib = pb.CameraPinhole() calib.set_image_shape(200, 300) calib.set_matrix(100, 101, 102, 103, 104) calib.set_distortion([0.1, 0.2], 103, 104) calib.save("junk") calib = pb.CameraPinhole() calib.load("junk") os.remove("junk") self.check_expected_values(calib)
def test_setters(self): calib = pb.CameraPinhole() calib.set_image_shape(200, 300) calib.set_matrix(100, 101, 102, 103, 104) calib.set_distortion([0.1, 0.2], 103, 104) self.check_expected_values(calib)
#!/usr/bin/env python3 import pyboof as pb import numpy as np import os data_path = "../data/example/fiducial/image/examples/" # Load the camera parameters intrinsic = pb.CameraPinhole() intrinsic.load(os.path.join(data_path, "intrinsic.yaml")) configFiducial = pb.ConfigFiducialImage() configThreshold = pb.ConfigThreshold.create_local(pb.ThresholdType.LOCAL_MEAN, 10) print("Configuring detector") detector = pb.FactoryFiducial(np.uint8).square_image(configFiducial, configThreshold) detector.set_intrinsic(intrinsic) detector.add_pattern(pb.load_single_band( data_path + "../patterns/pentarose.png", np.uint8), side_length=4.0) detector.add_pattern(pb.load_single_band(data_path + "../patterns/yu.png", np.uint8), side_length=4.0) print("Detecting image") detector.detect( pb.load_single_band(os.path.join(data_path, "image00.jpg"), np.uint8))
#!/usr/bin/env python3 import pyboof as pb import numpy as np import os import cv2 import transforms3d.euler # pip install transforms3d pb.init_memmap(5) data_path = "../data/example/fisheye/theta/" model_pinhole = pb.CameraPinhole() model_pinhole.set_image_shape(450, 450) model_pinhole.set_matrix(250, 250, 0, 300, 300) model_fisheye = pb.CameraUniversalOmni() model_fisheye.load(os.path.join(data_path, "front.yaml")) transform = pb.NarrowToWideFovPtoP(narrow_model=model_pinhole, wide_model=model_fisheye) image_fisheye = pb.load_planar(os.path.join(data_path, "front_hike.jpg"), np.uint8) image_pinhole = image_fisheye.createNew(model_pinhole.width, model_pinhole.height) image_distorter = transform.create_image_distort( pb.ImageType(image_fisheye.getImageType())) image_distorter.apply(image_fisheye, image_pinhole)
#!/usr/bin/env python3 import numpy as np import pyboof as pb from pyboof.swing import visualize_matches # Enable use of memory mapped files for MUCH faster conversion between some python and boofcv data types pb.init_memmap(5) # Load two images and camera calibration image0 = pb.load_single_band("../data/example/stereo/mono_wall_01.jpg", np.uint8) image1 = pb.load_single_band("../data/example/stereo/mono_wall_02.jpg", np.uint8) intrinsic = pb.CameraPinhole().load( "../data/example/calibration/mono/Sony_DSC-HX5V_Chess/intrinsic.yaml") # Set up the SURF fast hessian feature detector. Reduce the number of features it will detect by putting a limit # on how close two features can be and the maximum number at each scale config_fh = pb.ConfigFastHessian() config_fh.extractRadius = 4 config_fh.maxFeaturesPerScale = 300 # Create the detector and use default for everything else feature_detector = pb.FactoryDetectDescribe( np.uint8).createSurf(config_detect=config_fh) # Detect features in the first image locs0, desc0 = feature_detector.detect(image0) locs1, desc1 = feature_detector.detect(image1)