38 using namespace gtsam;
54 emplace_shared<Projection>(
z,
model,
X(
i),
L(
j));
73 double U1 = rand() / (double) (RAND_MAX);
74 double U2 = rand() / (double) (RAND_MAX);
77 S = V1 * V1 + V2 * V2;
88 const Symbol cameraFrameNumber(
'x', 1), landmarkNumber(
'l', 1);
90 std::shared_ptr<Projection>
factor1(
93 std::shared_ptr<Projection>
factor2(
120 vector<Point3> landmarks;
121 landmarks.push_back(
Point3(-1., -1.,
z));
122 landmarks.push_back(
Point3(-1., 1.,
z));
123 landmarks.push_back(
Point3(1., 1.,
z));
124 landmarks.push_back(
Point3(1., -1.,
z));
125 landmarks.push_back(
Point3(-1.5, -1.5, 1.5 *
z));
126 landmarks.push_back(
Point3(-1.5, 1.5, 1.5 *
z));
127 landmarks.push_back(
Point3(1.5, 1.5, 1.5 *
z));
128 landmarks.push_back(
Point3(1.5, -1.5, 1.5 *
z));
129 landmarks.push_back(
Point3(-2., -2., 2 *
z));
130 landmarks.push_back(
Point3(-2., 2., 2 *
z));
131 landmarks.push_back(
Point3(2., 2., 2 *
z));
132 landmarks.push_back(
Point3(2., -2., 2 *
z));
156 const std::vector<GeneralCamera>&
cameras,
157 const std::vector<Point3>& landmarks) {
159 for (
size_t i = 0;
i < landmarks.size(); ++
i)
167 TEST( GeneralSFMFactor_Cal3Bundler, optimize_defaultK ) {
175 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
181 const size_t nMeasurements =
cameras.size() * landmarks.size();
184 const double noise =
baseline * 0.1;
189 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
206 TEST( GeneralSFMFactor_Cal3Bundler, optimize_varK_SingleMeasurementError ) {
212 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
218 const size_t nMeasurements =
cameras.size() * landmarks.size();
221 const double noise =
baseline * 0.1;
227 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
239 const double reproj_error = 1
e-5;
244 EXPECT(optimizer.
error() < 0.5 * reproj_error * nMeasurements);
248 TEST( GeneralSFMFactor_Cal3Bundler, optimize_varK_FixCameras ) {
254 const double noise =
baseline * 0.1;
257 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
263 const size_t nMeasurements = landmarks.
size() *
cameras.size();
269 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
280 const double reproj_error = 1
e-5;
285 EXPECT(optimizer.
error() < 0.5 * reproj_error * nMeasurements);
289 TEST( GeneralSFMFactor_Cal3Bundler, optimize_varK_FixLandmarks ) {
297 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
303 const size_t nMeasurements = landmarks.
size() *
cameras.size();
307 const double rot_noise = 1
e-5, trans_noise = 1
e-3, focal_noise = 1,
308 distort_noise = 1
e-3;
314 trans_noise, trans_noise, trans_noise,
315 focal_noise, distort_noise, distort_noise
321 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
327 for (
size_t i = 0;
i < landmarks.size(); ++
i)
328 graph.addPoint3Constraint(
i, landmarks[
i]);
330 const double reproj_error = 1
e-5;
335 EXPECT(optimizer.
error() < 0.5 * reproj_error * nMeasurements);
339 TEST( GeneralSFMFactor_Cal3Bundler, optimize_varK_BA ) {
346 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
352 const size_t nMeasurements =
cameras.size() * landmarks.size();
355 const double noise =
baseline * 0.1;
361 for (
size_t i = 0;
i < landmarks.size(); ++
i) {
374 noiseModel::Isotropic::Sigma(1, 10.));
376 const double reproj_error = 1
e-5;
381 EXPECT(optimizer.
error() < 0.5 * reproj_error * nMeasurements);