2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation, 3 Atlanta, Georgia 30332-0415 6 See LICENSE for the license information 9 Author: Frank Dellaert & Fan Jiang (Python) 16 from gtsam
import (Cal3_S2, Cal3Bundler, CameraSetCal3_S2,
17 CameraSetCal3Bundler, PinholeCameraCal3_S2,
18 PinholeCameraCal3Bundler, Point2Vector, Point3, Pose3,
24 """ Tests for triangulation with shared and individual calibrations """ 27 """ Set up two camera poses """ 29 upright = Rot3.Ypr(-np.pi / 2, 0., -np.pi / 2)
33 pose2 = pose1.compose(
Pose3(Rot3(),
Point3(1, 0, 0)))
36 self.poses.append(pose1)
37 self.poses.append(pose2)
44 Generate vector of measurements for given calibration and camera model. 47 calibration: Camera calibration e.g. Cal3_S2 48 camera_model: Camera model e.g. PinholeCameraCal3_S2 49 cal_params: Iterable of camera parameters for `calibration` e.g. [K1, K2] 50 camera_set: Cameraset object (for individual calibrations) 52 list of measurements and list/CameraSet object for cameras 54 if camera_set
is not None:
55 cameras = camera_set()
60 for k, pose
in zip(cal_params, self.
poses):
62 camera = camera_model(pose, K)
63 cameras.append(camera)
65 measurements.append(z)
67 return measurements, cameras
70 """ Tests triangulation with shared Cal3_S2 calibration""" 72 sharedCal = (1500, 1200, 0, 640, 480)
76 (sharedCal, sharedCal))
87 measurements_noisy.append(measurements[0] - np.array([0.1, 0.5]))
88 measurements_noisy.append(measurements[1] - np.array([-0.2, 0.3]))
99 """ Tests triangulation with individual Cal3_S2 calibrations """ 101 K1 = (1500, 1200, 0, 640, 480)
102 K2 = (1600, 1300, 0, 650, 440)
105 PinholeCameraCal3_S2,
107 camera_set=CameraSetCal3_S2)
116 """ Tests triangulation with individual Cal3Bundler calibrations""" 118 K1 = (1500, 0, 0, 640, 480)
119 K2 = (1600, 0, 0, 650, 440)
122 PinholeCameraCal3Bundler,
124 camera_set=CameraSetCal3Bundler)
133 if __name__ ==
"__main__":
def gtsamAssertEquals(self, actual, expected, tol=1e-9)
std::vector< Pose3 > Pose3Vector
def generate_measurements(self, calibration, camera_model, cal_params, camera_set=None)
std::vector< Point2, Eigen::aligned_allocator< Point2 > > Point2Vector
def test_TriangulationExample(self)
def test_distinct_Ks(self)
def test_distinct_Ks_Bundler(self)
Point3 triangulatePoint3(const CameraSet< PinholeCamera< CALIBRATION > > &cameras, const Point2Vector &measurements, double rank_tol=1e-9, bool optimize=false)
Pinhole-specific version.