smartFactorScenarios.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
23 #include <gtsam/geometry/Cal3_S2.h>
25 
26 using namespace std;
27 using namespace gtsam;
28 
29 // three landmarks ~5 meters infront of camera
30 Point3 landmark1(5, 0.5, 1.2);
31 Point3 landmark2(5, -0.5, 1.2);
32 Point3 landmark3(3, 0, 3.0);
33 Point3 landmark4(10, 0.5, 1.2);
34 Point3 landmark5(10, -0.5, 1.2);
35 
36 // First camera pose, looking along X-axis, 1 meter above ground plane (x-y)
37 Pose3 level_pose = Pose3(Rot3::Ypr(-M_PI / 2, 0., -M_PI / 2), Point3(0, 0, 1));
38 // Second camera 1 meter to the right of first camera
39 Pose3 pose_right = level_pose * Pose3(Rot3(), Point3(1, 0, 0));
40 // Third camera 1 meter above the first camera
41 Pose3 pose_above = level_pose * Pose3(Rot3(), Point3(0, -1, 0));
42 
43 // Create a noise unit2 for the pixel error
44 static SharedNoiseModel unit2(noiseModel::Unit::Create(2));
45 
46 static double fov = 60; // degrees
47 static size_t w = 640, h = 480;
48 
49 /* ************************************************************************* */
50 // default Cal3_S2 cameras
51 namespace vanilla {
54 static Cal3_S2 K(fov, w, h);
55 static Cal3_S2 K2(1500, 1200, 0, w, h);
56 Camera level_camera(level_pose, K2);
57 Camera level_camera_right(pose_right, K2);
60 Camera cam1(level_pose, K2);
61 Camera cam2(pose_right, K2);
62 Camera cam3(pose_above, K2);
65 }
66 
67 /* ************************************************************************* */
68 // default Cal3_S2 poses
69 namespace vanillaPose {
72 static Cal3_S2::shared_ptr sharedK(new Cal3_S2(fov, w, h));
73 Camera level_camera(level_pose, sharedK);
74 Camera level_camera_right(pose_right, sharedK);
75 Camera cam1(level_pose, sharedK);
76 Camera cam2(pose_right, sharedK);
77 Camera cam3(pose_above, sharedK);
78 }
79 
80 /* ************************************************************************* */
81 // default Cal3_S2 poses
82 namespace vanillaPose2 {
85 static Cal3_S2::shared_ptr sharedK2(new Cal3_S2(1500, 1200, 0, 640, 480));
86 Camera level_camera(level_pose, sharedK2);
87 Camera level_camera_right(pose_right, sharedK2);
88 Camera cam1(level_pose, sharedK2);
89 Camera cam2(pose_right, sharedK2);
90 Camera cam3(pose_above, sharedK2);
91 }
92 
93 /* *************************************************************************/
94 // Cal3Bundler cameras
95 namespace bundler {
98 static Cal3Bundler K(500, 1e-3, 1e-3, 0, 0);
99 Camera level_camera(level_pose, K);
100 Camera level_camera_right(pose_right, K);
104 Camera cam1(level_pose, K);
105 Camera cam2(pose_right, K);
106 Camera cam3(pose_above, K);
108 }
109 /* *************************************************************************/
110 // Cal3Bundler poses
111 namespace bundlerPose {
114 static boost::shared_ptr<Cal3Bundler> sharedBundlerK(
115  new Cal3Bundler(500, 1e-3, 1e-3, 1000, 2000));
116 Camera level_camera(level_pose, sharedBundlerK);
117 Camera level_camera_right(pose_right, sharedBundlerK);
118 Camera cam1(level_pose, sharedBundlerK);
119 Camera cam2(pose_right, sharedBundlerK);
120 Camera cam3(pose_above, sharedBundlerK);
121 }
122 /* *************************************************************************/
123 
124 template<class CAMERA>
125 CAMERA perturbCameraPose(const CAMERA& camera) {
126  Pose3 noise_pose = Pose3(Rot3::Ypr(-M_PI / 10, 0., -M_PI / 10),
127  Point3(0.5, 0.1, 0.3));
128  Pose3 cameraPose = camera.pose();
129  Pose3 perturbedCameraPose = cameraPose.compose(noise_pose);
130  return CAMERA(perturbedCameraPose, camera.calibration());
131 }
132 
133 template<class CAMERA>
134 void projectToMultipleCameras(const CAMERA& cam1, const CAMERA& cam2,
135  const CAMERA& cam3, Point3 landmark, typename CAMERA::MeasurementVector& measurements_cam) {
136  Point2 cam1_uv1 = cam1.project(landmark);
137  Point2 cam2_uv1 = cam2.project(landmark);
138  Point2 cam3_uv1 = cam3.project(landmark);
139  measurements_cam.push_back(cam1_uv1);
140  measurements_cam.push_back(cam2_uv1);
141  measurements_cam.push_back(cam3_uv1);
142 }
143 
144 /* ************************************************************************* */
145 
Smart factor on poses, assuming camera calibration is fixed.
static PinholeCamera< Cal3_S2 > cam1(pose3, cal1)
Point2 level_uv_right
static Cal3_S2 K2(1500, 1200, 0, w, h)
static StereoCamera cam2(pose3, cal4ptr)
Vector2 Point2
Definition: Point2.h:27
Point3 landmark5(10,-0.5, 1.2)
#define M_PI
Definition: main.h:78
CAMERA perturbCameraPose(const CAMERA &camera)
Definition: Half.h:150
Camera cam3(pose_above, sharedBundlerK)
Point3 landmark3(3, 0, 3.0)
Pose3 pose_above
Point3 landmark4(10, 0.5, 1.2)
SmartProjectionPoseFactor< Cal3Bundler > SmartFactor
static Point3 landmark(0, 0, 5)
static boost::shared_ptr< Cal3Bundler > sharedBundlerK(new Cal3Bundler(500, 1e-3, 1e-3, 1000, 2000))
static Cal3Bundler K(500, 1e-3, 1e-3, 0, 0)
Smart factor on cameras (pose + calibration)
Class compose(const Class &g) const
Definition: Lie.h:47
PinholePose< Cal3Bundler > Camera
Point3 landmark1(5, 0.5, 1.2)
GeneralSFMFactor< Camera, Point3 > SFMFactor
Camera level_camera(level_pose, sharedBundlerK)
void projectToMultipleCameras(const CAMERA &cam1, const CAMERA &cam2, const CAMERA &cam3, Point3 landmark, typename CAMERA::MeasurementVector &measurements_cam)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static Cal3_S2::shared_ptr sharedK(new Cal3_S2(fov, w, h))
Pose3 level_pose
static SmartStereoProjectionParams params
static SharedNoiseModel unit2(noiseModel::Unit::Create(2))
traits
Definition: chartTesting.h:28
static size_t h
Pose3 pose_right
static size_t w
Point2 project(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose=boost::none, OptionalJacobian< 2, 3 > Dpoint=boost::none, OptionalJacobian< 2, DimK > Dcal=boost::none) const
project a 3D point from world coordinates into the image
Definition: PinholePose.h:118
static double fov
static Cal3_S2::shared_ptr sharedK2(new Cal3_S2(1500, 1200, 0, 640, 480))
Vector3 Point3
Definition: Point3.h:35
static const CalibratedCamera camera(kDefaultPose)
a general SFM factor with an unknown calibration
boost::shared_ptr< Cal3_S2 > shared_ptr
Definition: Cal3_S2.h:39
Calibration used by Bundler.
Camera level_camera_right(pose_right, sharedBundlerK)
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:734
The most common 5DOF 3D->2D calibration.
Point3 landmark2(5,-0.5, 1.2)


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:44:16