ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
camera_models.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <ceres/ceres.h>
11 
12 #include <Eigen/Core>
13 #include <Eigen/Dense>
14 #include <cfloat>
15 #include <string>
16 #include <vector>
17 
18 namespace colmap {
19 
20 // This file defines several different camera models and arbitrary new camera
21 // models can be added by the following steps:
22 //
23 // 1. Add a new struct in this file which implements all the necessary methods.
24 // 2. Define an unique model_name and model_id for the camera model.
25 // 3. Add camera model to `CAMERA_MODEL_CASES` macro in this file.
26 // 4. Add new template specialization of test case for camera model to
27 // `camera_models_test.cc`.
28 //
29 // A camera model can have three different types of camera parameters: focal
30 // length, principal point, extra parameters (distortion parameters). The
31 // parameter array is split into different groups, so that we can enable or
32 // disable the refinement of the individual groups during bundle adjustment. It
33 // is up to the camera model to access the parameters correctly (it is free to
34 // do so in an arbitrary manner) - the parameters are not accessed from outside.
35 //
36 // A camera model must have the following methods:
37 //
38 // - `WorldToImage`: transform normalized camera coordinates to image
39 // coordinates (the inverse of `ImageToWorld`). Assumes that the world
40 // coordinates are given as (u, v, 1).
41 // - `ImageToWorld`: transform image coordinates to normalized camera
42 // coordinates (the inverse of `WorldToImage`). Produces world coordinates
43 // as (u, v, 1).
44 // - `ImageToWorldThreshold`: transform a threshold given in pixels to
45 // normalized units (e.g. useful for reprojection error thresholds).
46 //
47 // Whenever you specify the camera parameters in a list, they must appear
48 // exactly in the order as they are accessed in the defined model struct.
49 //
50 // The camera models follow the convention that the upper left image corner has
51 // the coordinate (0, 0), the lower right corner (width, height), i.e. that
52 // the upper left pixel center has coordinate (0.5, 0.5) and the lower right
53 // pixel center has the coordinate (width - 0.5, height - 0.5).
54 
55 static const int kInvalidCameraModelId = -1;
56 
57 #ifndef CAMERA_MODEL_DEFINITIONS
58 #define CAMERA_MODEL_DEFINITIONS(model_id_value, model_name_value, \
59  num_params_value) \
60  static const int kModelId = model_id_value; \
61  static const size_t kNumParams = num_params_value; \
62  static const int model_id; \
63  static const std::string model_name; \
64  static const size_t num_params; \
65  static const std::string params_info; \
66  static const std::vector<size_t> focal_length_idxs; \
67  static const std::vector<size_t> principal_point_idxs; \
68  static const std::vector<size_t> extra_params_idxs; \
69  \
70  static inline int InitializeModelId() { return model_id_value; }; \
71  static inline std::string InitializeModelName() { \
72  return model_name_value; \
73  }; \
74  static inline size_t InitializeNumParams() { return num_params_value; }; \
75  static inline std::string InitializeParamsInfo(); \
76  static inline std::vector<size_t> InitializeFocalLengthIdxs(); \
77  static inline std::vector<size_t> InitializePrincipalPointIdxs(); \
78  static inline std::vector<size_t> InitializeExtraParamsIdxs(); \
79  static inline std::vector<double> InitializeParams( \
80  const double focal_length, const size_t width, \
81  const size_t height); \
82  \
83  template <typename T> \
84  static void WorldToImage(const T* params, const T u, const T v, T* x, \
85  T* y); \
86  template <typename T> \
87  static void ImageToWorld(const T* params, const T x, const T y, T* u, \
88  T* v); \
89  template <typename T> \
90  static void Distortion(const T* extra_params, const T u, const T v, T* du, \
91  T* dv);
92 #endif
93 
94 #ifndef CAMERA_MODEL_CASES
95 #define CAMERA_MODEL_CASES \
96  CAMERA_MODEL_CASE(SimplePinholeCameraModel) \
97  CAMERA_MODEL_CASE(PinholeCameraModel) \
98  CAMERA_MODEL_CASE(SimpleRadialCameraModel) \
99  CAMERA_MODEL_CASE(SimpleRadialFisheyeCameraModel) \
100  CAMERA_MODEL_CASE(RadialCameraModel) \
101  CAMERA_MODEL_CASE(RadialFisheyeCameraModel) \
102  CAMERA_MODEL_CASE(OpenCVCameraModel) \
103  CAMERA_MODEL_CASE(OpenCVFisheyeCameraModel) \
104  CAMERA_MODEL_CASE(FullOpenCVCameraModel) \
105  CAMERA_MODEL_CASE(FOVCameraModel) \
106  CAMERA_MODEL_CASE(ThinPrismFisheyeCameraModel)
107 #endif
108 
109 #ifndef CAMERA_MODEL_SWITCH_CASES
110 #define CAMERA_MODEL_SWITCH_CASES \
111  CAMERA_MODEL_CASES \
112  default: \
113  CAMERA_MODEL_DOES_NOT_EXIST_EXCEPTION \
114  break;
115 #endif
116 
117 #define CAMERA_MODEL_DOES_NOT_EXIST_EXCEPTION \
118  throw std::domain_error("Camera model does not exist");
119 
120 // The "Curiously Recurring Template Pattern" (CRTP) is used here, so that we
121 // can reuse some shared functionality between all camera models -
122 // defined in the BaseCameraModel.
123 template <typename CameraModel>
125  template <typename T>
126  static inline bool HasBogusParams(const std::vector<T>& params,
127  const size_t width,
128  const size_t height,
129  const T min_focal_length_ratio,
130  const T max_focal_length_ratio,
131  const T max_extra_param);
132 
133  template <typename T>
134  static inline bool HasBogusFocalLength(const std::vector<T>& params,
135  const size_t width,
136  const size_t height,
137  const T min_focal_length_ratio,
138  const T max_focal_length_ratio);
139 
140  template <typename T>
141  static inline bool HasBogusPrincipalPoint(const std::vector<T>& params,
142  const size_t width,
143  const size_t height);
144 
145  template <typename T>
146  static inline bool HasBogusExtraParams(const std::vector<T>& params,
147  const T max_extra_param);
148 
149  template <typename T>
150  static inline T ImageToWorldThreshold(const T* params, const T threshold);
151 
152  template <typename T>
153  static inline void IterativeUndistortion(const T* params, T* u, T* v);
154 };
155 
156 // Simple Pinhole camera model.
157 //
158 // No Distortion is assumed. Only focal length and principal point is modeled.
159 //
160 // Parameter list is expected in the following order:
161 //
162 // f, cx, cy
163 //
164 // See https://en.wikipedia.org/wiki/Pinhole_camera_model
166  : public BaseCameraModel<SimplePinholeCameraModel> {
167  CAMERA_MODEL_DEFINITIONS(0, "SIMPLE_PINHOLE", 3)
168 };
169 
170 // Pinhole camera model.
171 //
172 // No Distortion is assumed. Only focal length and principal point is modeled.
173 //
174 // Parameter list is expected in the following order:
175 //
176 // fx, fy, cx, cy
177 //
178 // See https://en.wikipedia.org/wiki/Pinhole_camera_model
179 struct PinholeCameraModel : public BaseCameraModel<PinholeCameraModel> {
180  CAMERA_MODEL_DEFINITIONS(1, "PINHOLE", 4)
181 };
182 
183 // Simple camera model with one focal length and one radial distortion
184 // parameter.
185 //
186 // This model is similar to the camera model that VisualSfM uses with the
187 // difference that the distortion here is applied to the projections and
188 // not to the measurements.
189 //
190 // Parameter list is expected in the following order:
191 //
192 // f, cx, cy, k
193 //
195  : public BaseCameraModel<SimpleRadialCameraModel> {
196  CAMERA_MODEL_DEFINITIONS(2, "SIMPLE_RADIAL", 4)
197 };
198 
199 // Simple camera model with one focal length and two radial distortion
200 // parameters.
201 //
202 // This model is equivalent to the camera model that Bundler uses
203 // (except for an inverse z-axis in the camera coordinate system).
204 //
205 // Parameter list is expected in the following order:
206 //
207 // f, cx, cy, k1, k2
208 //
209 struct RadialCameraModel : public BaseCameraModel<RadialCameraModel> {
210  CAMERA_MODEL_DEFINITIONS(3, "RADIAL", 5)
211 };
212 
213 // OpenCV camera model.
214 //
215 // Based on the pinhole camera model. Additionally models radial and
216 // tangential distortion (up to 2nd degree of coefficients). Not suitable for
217 // large radial distortions of fish-eye cameras.
218 //
219 // Parameter list is expected in the following order:
220 //
221 // fx, fy, cx, cy, k1, k2, p1, p2
222 //
223 // See
224 // http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html
225 struct OpenCVCameraModel : public BaseCameraModel<OpenCVCameraModel> {
226  CAMERA_MODEL_DEFINITIONS(4, "OPENCV", 8)
227 };
228 
229 // OpenCV fish-eye camera model.
230 //
231 // Based on the pinhole camera model. Additionally models radial and
232 // tangential Distortion (up to 2nd degree of coefficients). Suitable for
233 // large radial distortions of fish-eye cameras.
234 //
235 // Parameter list is expected in the following order:
236 //
237 // fx, fy, cx, cy, k1, k2, k3, k4
238 //
239 // See
240 // http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html
242  : public BaseCameraModel<OpenCVFisheyeCameraModel> {
243  CAMERA_MODEL_DEFINITIONS(5, "OPENCV_FISHEYE", 8)
244 };
245 
246 // Full OpenCV camera model.
247 //
248 // Based on the pinhole camera model. Additionally models radial and
249 // tangential Distortion.
250 //
251 // Parameter list is expected in the following order:
252 //
253 // fx, fy, cx, cy, k1, k2, p1, p2, k3, k4, k5, k6
254 //
255 // See
256 // http://docs.opencv.org/modules/calib3d/doc/camera_calibration_and_3d_reconstruction.html
257 struct FullOpenCVCameraModel : public BaseCameraModel<FullOpenCVCameraModel> {
258  CAMERA_MODEL_DEFINITIONS(6, "FULL_OPENCV", 12)
259 };
260 
261 // FOV camera model.
262 //
263 // Based on the pinhole camera model. Additionally models radial distortion.
264 // This model is for example used by Project Tango for its equidistant
265 // calibration type.
266 //
267 // Parameter list is expected in the following order:
268 //
269 // fx, fy, cx, cy, omega
270 //
271 // See:
272 // Frederic Devernay, Olivier Faugeras. Straight lines have to be straight:
273 // Automatic calibration and removal of distortion from scenes of structured
274 // environments. Machine vision and applications, 2001.
275 struct FOVCameraModel : public BaseCameraModel<FOVCameraModel> {
277 
278  template <typename T>
279  static void Undistortion(
280  const T* extra_params, const T u, const T v, T* du, T* dv);
281 };
282 
283 // Simple camera model with one focal length and one radial distortion
284 // parameter, suitable for fish-eye cameras.
285 //
286 // This model is equivalent to the OpenCVFisheyeCameraModel but has only one
287 // radial distortion coefficient.
288 //
289 // Parameter list is expected in the following order:
290 //
291 // f, cx, cy, k
292 //
295  CAMERA_MODEL_DEFINITIONS(8, "SIMPLE_RADIAL_FISHEYE", 4)
296 };
297 
298 // Simple camera model with one focal length and two radial distortion
299 // parameters, suitable for fish-eye cameras.
300 //
301 // This model is equivalent to the OpenCVFisheyeCameraModel but has only two
302 // radial distortion coefficients.
303 //
304 // Parameter list is expected in the following order:
305 //
306 // f, cx, cy, k1, k2
307 //
309  : public BaseCameraModel<RadialFisheyeCameraModel> {
310  CAMERA_MODEL_DEFINITIONS(9, "RADIAL_FISHEYE", 5)
311 };
312 
313 // Camera model with radial and tangential distortion coefficients and
314 // additional coefficients accounting for thin-prism distortion.
315 //
316 // This camera model is described in
317 //
318 // "Camera Calibration with Distortion Models and Accuracy Evaluation",
319 // J Weng et al., TPAMI, 1992.
320 //
321 // Parameter list is expected in the following order:
322 //
323 // fx, fy, cx, cy, k1, k2, p1, p2, k3, k4, sx1, sy1
324 //
326  : public BaseCameraModel<ThinPrismFisheyeCameraModel> {
327  CAMERA_MODEL_DEFINITIONS(10, "THIN_PRISM_FISHEYE", 12)
328 };
329 
330 // Check whether camera model with given name or identifier exists.
331 bool ExistsCameraModelWithName(const std::string& model_name);
332 bool ExistsCameraModelWithId(const int model_id);
333 
334 // Convert camera name to unique camera model identifier.
335 //
336 // @param name Unique name of camera model.
337 //
338 // @return Unique identifier of camera model.
339 int CameraModelNameToId(const std::string& model_name);
340 
341 // Convert camera model identifier to unique camera model name.
342 //
343 // @param model_id Unique identifier of camera model.
344 //
345 // @return Unique name of camera model.
346 std::string CameraModelIdToName(const int model_id);
347 
348 // Initialize camera parameters using given image properties.
349 //
350 // Initializes all focal length parameters to the same given focal length and
351 // sets the principal point to the image center.
352 //
353 // @param model_id Unique identifier of camera model.
354 // @param focal_length Focal length, equal for all focal length parameters.
355 // @param width Sensor width of the camera.
356 // @param height Sensor height of the camera.
357 std::vector<double> CameraModelInitializeParams(const int model_id,
358  const double focal_length,
359  const size_t width,
360  const size_t height);
361 
362 // Get human-readable information about the parameter vector order.
363 //
364 // @param model_id Unique identifier of camera model.
365 std::string CameraModelParamsInfo(const int model_id);
366 
367 // Get the indices of the parameter groups in the parameter vector.
368 //
369 // @param model_id Unique identifier of camera model.
370 const std::vector<size_t>& CameraModelFocalLengthIdxs(const int model_id);
371 const std::vector<size_t>& CameraModelPrincipalPointIdxs(const int model_id);
372 const std::vector<size_t>& CameraModelExtraParamsIdxs(const int model_id);
373 
374 // Get the total number of parameters of a camera model.
375 size_t CameraModelNumParams(const int model_id);
376 
377 // Check whether parameters are valid, i.e. the parameter vector has
378 // the correct dimensions that match the specified camera model.
379 //
380 // @param model_id Unique identifier of camera model.
381 // @param params Array of camera parameters.
382 bool CameraModelVerifyParams(const int model_id,
383  const std::vector<double>& params);
384 
385 // Check whether camera has bogus parameters.
386 //
387 // @param model_id Unique identifier of camera model.
388 // @param params Array of camera parameters.
389 // @param width Sensor width of the camera.
390 // @param height Sensor height of the camera.
391 // @param min_focal_length_ratio Minimum ratio of focal length over
392 // minimum sensor dimension.
393 // @param max_focal_length_ratio Maximum ratio of focal length over
394 // maximum sensor dimension.
395 // @param max_extra_param Maximum magnitude of each extra parameter.
396 bool CameraModelHasBogusParams(const int model_id,
397  const std::vector<double>& params,
398  const size_t width,
399  const size_t height,
400  const double min_focal_length_ratio,
401  const double max_focal_length_ratio,
402  const double max_extra_param);
403 
404 // Transform world coordinates in camera coordinate system to image coordinates.
405 //
406 // This is the inverse of `CameraModelImageToWorld`.
407 //
408 // @param model_id Unique model_id of camera model as defined in
409 // `CAMERA_MODEL_NAME_TO_CODE`.
410 // @param params Array of camera parameters.
411 // @param u, v Coordinates in camera system as (u, v, 1).
412 // @param x, y Output image coordinates in pixels.
413 inline void CameraModelWorldToImage(const int model_id,
414  const std::vector<double>& params,
415  const double u,
416  const double v,
417  double* x,
418  double* y);
419 
420 // Transform image coordinates to world coordinates in camera coordinate system.
421 //
422 // This is the inverse of `CameraModelWorldToImage`.
423 //
424 // @param model_id Unique identifier of camera model.
425 // @param params Array of camera parameters.
426 // @param x, y Image coordinates in pixels.
427 // @param v, u Output Coordinates in camera system as (u, v, 1).
428 inline void CameraModelImageToWorld(const int model_id,
429  const std::vector<double>& params,
430  const double x,
431  const double y,
432  double* u,
433  double* v);
434 
435 // Convert pixel threshold in image plane to world space by dividing
436 // the threshold through the mean focal length.
437 //
438 // @param model_id Unique identifier of camera model.
439 // @param params Array of camera parameters.
440 // @param threshold Image space threshold in pixels.
441 //
442 // @ return World space threshold.
444  const int model_id,
445  const std::vector<double>& params,
446  const double threshold);
447 
449 // Implementation
451 
453 // BaseCameraModel
454 
455 template <typename CameraModel>
456 template <typename T>
458  const std::vector<T>& params,
459  const size_t width,
460  const size_t height,
461  const T min_focal_length_ratio,
462  const T max_focal_length_ratio,
463  const T max_extra_param) {
464  if (HasBogusPrincipalPoint(params, width, height)) {
465  return true;
466  }
467 
468  if (HasBogusFocalLength(params, width, height, min_focal_length_ratio,
469  max_focal_length_ratio)) {
470  return true;
471  }
472 
473  if (HasBogusExtraParams(params, max_extra_param)) {
474  return true;
475  }
476 
477  return false;
478 }
479 
480 template <typename CameraModel>
481 template <typename T>
483  const std::vector<T>& params,
484  const size_t width,
485  const size_t height,
486  const T min_focal_length_ratio,
487  const T max_focal_length_ratio) {
488  const size_t max_size = std::max(width, height);
489 
490  for (const auto& idx : CameraModel::focal_length_idxs) {
491  const T focal_length_ratio = params[idx] / max_size;
492  if (focal_length_ratio < min_focal_length_ratio ||
493  focal_length_ratio > max_focal_length_ratio) {
494  return true;
495  }
496  }
497 
498  return false;
499 }
500 
501 template <typename CameraModel>
502 template <typename T>
504  const std::vector<T>& params, const size_t width, const size_t height) {
505  const T cx = params[CameraModel::principal_point_idxs[0]];
506  const T cy = params[CameraModel::principal_point_idxs[1]];
507  return cx < 0 || cx > width || cy < 0 || cy > height;
508 }
509 
510 template <typename CameraModel>
511 template <typename T>
513  const std::vector<T>& params, const T max_extra_param) {
514  for (const auto& idx : CameraModel::extra_params_idxs) {
515  if (std::abs(params[idx]) > max_extra_param) {
516  return true;
517  }
518  }
519 
520  return false;
521 }
522 
523 template <typename CameraModel>
524 template <typename T>
526  const T threshold) {
527  T mean_focal_length = 0;
528  for (const auto& idx : CameraModel::focal_length_idxs) {
529  mean_focal_length += params[idx];
530  }
531  mean_focal_length /= CameraModel::focal_length_idxs.size();
532  return threshold / mean_focal_length;
533 }
534 
535 template <typename CameraModel>
536 template <typename T>
538  T* u,
539  T* v) {
540  // Parameters for Newton iteration using numerical differentiation with
541  // central differences, 100 iterations should be enough even for complex
542  // camera models with higher order terms.
543  const size_t kNumIterations = 100;
544  const double kMaxStepNorm = 1e-10;
545  const double kRelStepSize = 1e-6;
546 
547  Eigen::Matrix2d J;
548  const Eigen::Vector2d x0(*u, *v);
549  Eigen::Vector2d x(*u, *v);
550  Eigen::Vector2d dx;
551  Eigen::Vector2d dx_0b;
552  Eigen::Vector2d dx_0f;
553  Eigen::Vector2d dx_1b;
554  Eigen::Vector2d dx_1f;
555 
556  for (size_t i = 0; i < kNumIterations; ++i) {
557  const double step0 = std::max(std::numeric_limits<double>::epsilon(),
558  std::abs(kRelStepSize * x(0)));
559  const double step1 = std::max(std::numeric_limits<double>::epsilon(),
560  std::abs(kRelStepSize * x(1)));
561  CameraModel::Distortion(params, x(0), x(1), &dx(0), &dx(1));
562  CameraModel::Distortion(params, x(0) - step0, x(1), &dx_0b(0),
563  &dx_0b(1));
564  CameraModel::Distortion(params, x(0) + step0, x(1), &dx_0f(0),
565  &dx_0f(1));
566  CameraModel::Distortion(params, x(0), x(1) - step1, &dx_1b(0),
567  &dx_1b(1));
568  CameraModel::Distortion(params, x(0), x(1) + step1, &dx_1f(0),
569  &dx_1f(1));
570  J(0, 0) = 1 + (dx_0f(0) - dx_0b(0)) / (2 * step0);
571  J(0, 1) = (dx_1f(0) - dx_1b(0)) / (2 * step1);
572  J(1, 0) = (dx_0f(1) - dx_0b(1)) / (2 * step0);
573  J(1, 1) = 1 + (dx_1f(1) - dx_1b(1)) / (2 * step1);
574  const Eigen::Vector2d step_x = J.inverse() * (x + dx - x0);
575  x -= step_x;
576  if (step_x.squaredNorm() < kMaxStepNorm) {
577  break;
578  }
579  }
580 
581  *u = x(0);
582  *v = x(1);
583 }
584 
586 // SimplePinholeCameraModel
587 
589  return "f, cx, cy";
590 }
591 
593  return {0};
594 }
595 
597  return {1, 2};
598 }
599 
601  return {};
602 }
603 
605  const double focal_length, const size_t width, const size_t height) {
606  return {focal_length, width / 2.0, height / 2.0};
607 }
608 
609 template <typename T>
611  const T* params, const T u, const T v, T* x, T* y) {
612  const T f = params[0];
613  const T c1 = params[1];
614  const T c2 = params[2];
615 
616  // No Distortion
617 
618  // Transform to image coordinates
619  *x = f * u + c1;
620  *y = f * v + c2;
621 }
622 
623 template <typename T>
625  const T* params, const T x, const T y, T* u, T* v) {
626  const T f = params[0];
627  const T c1 = params[1];
628  const T c2 = params[2];
629 
630  *u = (x - c1) / f;
631  *v = (y - c2) / f;
632 }
633 
635 // PinholeCameraModel
636 
638  return "fx, fy, cx, cy";
639 }
640 
642  return {0, 1};
643 }
644 
646  return {2, 3};
647 }
648 
650  return {};
651 }
652 
654  const double focal_length, const size_t width, const size_t height) {
655  return {focal_length, focal_length, width / 2.0, height / 2.0};
656 }
657 
658 template <typename T>
660  const T* params, const T u, const T v, T* x, T* y) {
661  const T f1 = params[0];
662  const T f2 = params[1];
663  const T c1 = params[2];
664  const T c2 = params[3];
665 
666  // No Distortion
667 
668  // Transform to image coordinates
669  *x = f1 * u + c1;
670  *y = f2 * v + c2;
671 }
672 
673 template <typename T>
675  const T* params, const T x, const T y, T* u, T* v) {
676  const T f1 = params[0];
677  const T f2 = params[1];
678  const T c1 = params[2];
679  const T c2 = params[3];
680 
681  *u = (x - c1) / f1;
682  *v = (y - c2) / f2;
683 }
684 
686 // SimpleRadialCameraModel
687 
689  return "f, cx, cy, k";
690 }
691 
693  return {0};
694 }
695 
697  return {1, 2};
698 }
699 
701  return {3};
702 }
703 
705  const double focal_length, const size_t width, const size_t height) {
706  return {focal_length, width / 2.0, height / 2.0, 0};
707 }
708 
709 template <typename T>
711  const T* params, const T u, const T v, T* x, T* y) {
712  const T f = params[0];
713  const T c1 = params[1];
714  const T c2 = params[2];
715 
716  // Distortion
717  T du, dv;
718  Distortion(&params[3], u, v, &du, &dv);
719  *x = u + du;
720  *y = v + dv;
721 
722  // Transform to image coordinates
723  *x = f * *x + c1;
724  *y = f * *y + c2;
725 }
726 
727 template <typename T>
729  const T* params, const T x, const T y, T* u, T* v) {
730  const T f = params[0];
731  const T c1 = params[1];
732  const T c2 = params[2];
733 
734  // Lift points to normalized plane
735  *u = (x - c1) / f;
736  *v = (y - c2) / f;
737 
738  IterativeUndistortion(&params[3], u, v);
739 }
740 
741 template <typename T>
743  const T* extra_params, const T u, const T v, T* du, T* dv) {
744  const T k = extra_params[0];
745 
746  const T u2 = u * u;
747  const T v2 = v * v;
748  const T r2 = u2 + v2;
749  const T radial = k * r2;
750  *du = u * radial;
751  *dv = v * radial;
752 }
753 
755 // RadialCameraModel
756 
758  return "f, cx, cy, k1, k2";
759 }
760 
762  return {0};
763 }
764 
766  return {1, 2};
767 }
768 
770  return {3, 4};
771 }
772 
774  const double focal_length, const size_t width, const size_t height) {
775  return {focal_length, width / 2.0, height / 2.0, 0, 0};
776 }
777 
778 template <typename T>
780  const T* params, const T u, const T v, T* x, T* y) {
781  const T f = params[0];
782  const T c1 = params[1];
783  const T c2 = params[2];
784 
785  // Distortion
786  T du, dv;
787  Distortion(&params[3], u, v, &du, &dv);
788  *x = u + du;
789  *y = v + dv;
790 
791  // Transform to image coordinates
792  *x = f * *x + c1;
793  *y = f * *y + c2;
794 }
795 
796 template <typename T>
798  const T* params, const T x, const T y, T* u, T* v) {
799  const T f = params[0];
800  const T c1 = params[1];
801  const T c2 = params[2];
802 
803  // Lift points to normalized plane
804  *u = (x - c1) / f;
805  *v = (y - c2) / f;
806 
807  IterativeUndistortion(&params[3], u, v);
808 }
809 
810 template <typename T>
812  const T* extra_params, const T u, const T v, T* du, T* dv) {
813  const T k1 = extra_params[0];
814  const T k2 = extra_params[1];
815 
816  const T u2 = u * u;
817  const T v2 = v * v;
818  const T r2 = u2 + v2;
819  const T radial = k1 * r2 + k2 * r2 * r2;
820  *du = u * radial;
821  *dv = v * radial;
822 }
823 
825 // OpenCVCameraModel
826 
828  return "fx, fy, cx, cy, k1, k2, p1, p2";
829 }
830 
832  return {0, 1};
833 }
834 
836  return {2, 3};
837 }
838 
840  return {4, 5, 6, 7};
841 }
842 
844  const double focal_length, const size_t width, const size_t height) {
845  return {focal_length, focal_length, width / 2.0, height / 2.0, 0, 0, 0, 0};
846 }
847 
848 template <typename T>
850  const T* params, const T u, const T v, T* x, T* y) {
851  const T f1 = params[0];
852  const T f2 = params[1];
853  const T c1 = params[2];
854  const T c2 = params[3];
855 
856  // Distortion
857  T du, dv;
858  Distortion(&params[4], u, v, &du, &dv);
859  *x = u + du;
860  *y = v + dv;
861 
862  // Transform to image coordinates
863  *x = f1 * *x + c1;
864  *y = f2 * *y + c2;
865 }
866 
867 template <typename T>
869  const T* params, const T x, const T y, T* u, T* v) {
870  const T f1 = params[0];
871  const T f2 = params[1];
872  const T c1 = params[2];
873  const T c2 = params[3];
874 
875  // Lift points to normalized plane
876  *u = (x - c1) / f1;
877  *v = (y - c2) / f2;
878 
879  IterativeUndistortion(&params[4], u, v);
880 }
881 
882 template <typename T>
884  const T* extra_params, const T u, const T v, T* du, T* dv) {
885  const T k1 = extra_params[0];
886  const T k2 = extra_params[1];
887  const T p1 = extra_params[2];
888  const T p2 = extra_params[3];
889 
890  const T u2 = u * u;
891  const T uv = u * v;
892  const T v2 = v * v;
893  const T r2 = u2 + v2;
894  const T radial = k1 * r2 + k2 * r2 * r2;
895  *du = u * radial + T(2) * p1 * uv + p2 * (r2 + T(2) * u2);
896  *dv = v * radial + T(2) * p2 * uv + p1 * (r2 + T(2) * v2);
897 }
898 
900 // OpenCVFisheyeCameraModel
901 
903  return "fx, fy, cx, cy, k1, k2, k3, k4";
904 }
905 
907  return {0, 1};
908 }
909 
911  return {2, 3};
912 }
913 
915  return {4, 5, 6, 7};
916 }
917 
919  const double focal_length, const size_t width, const size_t height) {
920  return {focal_length, focal_length, width / 2.0, height / 2.0, 0, 0, 0, 0};
921 }
922 
923 template <typename T>
925  const T* params, const T u, const T v, T* x, T* y) {
926  const T f1 = params[0];
927  const T f2 = params[1];
928  const T c1 = params[2];
929  const T c2 = params[3];
930 
931  // Distortion
932  T du, dv;
933  Distortion(&params[4], u, v, &du, &dv);
934  *x = u + du;
935  *y = v + dv;
936 
937  // Transform to image coordinates
938  *x = f1 * *x + c1;
939  *y = f2 * *y + c2;
940 }
941 
942 template <typename T>
944  const T* params, const T x, const T y, T* u, T* v) {
945  const T f1 = params[0];
946  const T f2 = params[1];
947  const T c1 = params[2];
948  const T c2 = params[3];
949 
950  // Lift points to normalized plane
951  *u = (x - c1) / f1;
952  *v = (y - c2) / f2;
953 
954  IterativeUndistortion(&params[4], u, v);
955 }
956 
957 template <typename T>
959  const T* extra_params, const T u, const T v, T* du, T* dv) {
960  const T k1 = extra_params[0];
961  const T k2 = extra_params[1];
962  const T k3 = extra_params[2];
963  const T k4 = extra_params[3];
964 
965  const T r = ceres::sqrt(u * u + v * v);
966 
967  if (r > T(std::numeric_limits<double>::epsilon())) {
968  const T theta = ceres::atan(r);
969  const T theta2 = theta * theta;
970  const T theta4 = theta2 * theta2;
971  const T theta6 = theta4 * theta2;
972  const T theta8 = theta4 * theta4;
973  const T thetad = theta * (T(1) + k1 * theta2 + k2 * theta4 +
974  k3 * theta6 + k4 * theta8);
975  *du = u * thetad / r - u;
976  *dv = v * thetad / r - v;
977  } else {
978  *du = T(0);
979  *dv = T(0);
980  }
981 }
982 
984 // FullOpenCVCameraModel
985 
987  return "fx, fy, cx, cy, k1, k2, p1, p2, k3, k4, k5, k6";
988 }
989 
991  return {0, 1};
992 }
993 
995  return {2, 3};
996 }
997 
999  return {4, 5, 6, 7, 8, 9, 10, 11};
1000 }
1001 
1003  const double focal_length, const size_t width, const size_t height) {
1004  return {focal_length,
1005  focal_length,
1006  width / 2.0,
1007  height / 2.0,
1008  0,
1009  0,
1010  0,
1011  0,
1012  0,
1013  0,
1014  0,
1015  0};
1016 }
1017 
1018 template <typename T>
1020  const T* params, const T u, const T v, T* x, T* y) {
1021  const T f1 = params[0];
1022  const T f2 = params[1];
1023  const T c1 = params[2];
1024  const T c2 = params[3];
1025 
1026  // Distortion
1027  T du, dv;
1028  Distortion(&params[4], u, v, &du, &dv);
1029  *x = u + du;
1030  *y = v + dv;
1031 
1032  // Transform to image coordinates
1033  *x = f1 * *x + c1;
1034  *y = f2 * *y + c2;
1035 }
1036 
1037 template <typename T>
1039  const T* params, const T x, const T y, T* u, T* v) {
1040  const T f1 = params[0];
1041  const T f2 = params[1];
1042  const T c1 = params[2];
1043  const T c2 = params[3];
1044 
1045  // Lift points to normalized plane
1046  *u = (x - c1) / f1;
1047  *v = (y - c2) / f2;
1048 
1049  IterativeUndistortion(&params[4], u, v);
1050 }
1051 
1052 template <typename T>
1054  const T* extra_params, const T u, const T v, T* du, T* dv) {
1055  const T k1 = extra_params[0];
1056  const T k2 = extra_params[1];
1057  const T p1 = extra_params[2];
1058  const T p2 = extra_params[3];
1059  const T k3 = extra_params[4];
1060  const T k4 = extra_params[5];
1061  const T k5 = extra_params[6];
1062  const T k6 = extra_params[7];
1063 
1064  const T u2 = u * u;
1065  const T uv = u * v;
1066  const T v2 = v * v;
1067  const T r2 = u2 + v2;
1068  const T r4 = r2 * r2;
1069  const T r6 = r4 * r2;
1070  const T radial = (T(1) + k1 * r2 + k2 * r4 + k3 * r6) /
1071  (T(1) + k4 * r2 + k5 * r4 + k6 * r6);
1072  *du = u * radial + T(2) * p1 * uv + p2 * (r2 + T(2) * u2) - u;
1073  *dv = v * radial + T(2) * p2 * uv + p1 * (r2 + T(2) * v2) - v;
1074 }
1075 
1077 // FOVCameraModel
1078 
1080  return "fx, fy, cx, cy, omega";
1081 }
1082 
1084  return {0, 1};
1085 }
1086 
1088  return {2, 3};
1089 }
1090 
1091 std::vector<size_t> FOVCameraModel::InitializeExtraParamsIdxs() { return {4}; }
1092 
1093 std::vector<double> FOVCameraModel::InitializeParams(const double focal_length,
1094  const size_t width,
1095  const size_t height) {
1096  return {focal_length, focal_length, width / 2.0, height / 2.0, 1e-2};
1097 }
1098 
1099 template <typename T>
1101  const T* params, const T u, const T v, T* x, T* y) {
1102  const T f1 = params[0];
1103  const T f2 = params[1];
1104  const T c1 = params[2];
1105  const T c2 = params[3];
1106 
1107  // Distortion
1108  Distortion(&params[4], u, v, x, y);
1109 
1110  // Transform to image coordinates
1111  *x = f1 * *x + c1;
1112  *y = f2 * *y + c2;
1113 }
1114 
1115 template <typename T>
1117  const T* params, const T x, const T y, T* u, T* v) {
1118  const T f1 = params[0];
1119  const T f2 = params[1];
1120  const T c1 = params[2];
1121  const T c2 = params[3];
1122 
1123  // Lift points to normalized plane
1124  const T uu = (x - c1) / f1;
1125  const T vv = (y - c2) / f2;
1126 
1127  // Undistortion
1128  Undistortion(&params[4], uu, vv, u, v);
1129 }
1130 
1131 template <typename T>
1133  const T* extra_params, const T u, const T v, T* du, T* dv) {
1134  const T omega = extra_params[0];
1135 
1136  // Chosen arbitrarily.
1137  const T kEpsilon = T(1e-4);
1138 
1139  const T radius2 = u * u + v * v;
1140  const T omega2 = omega * omega;
1141 
1142  T factor;
1143  if (omega2 < kEpsilon) {
1144  // Derivation of this case with Matlab:
1145  // syms radius omega;
1146  // factor(radius) = atan(radius * 2 * tan(omega / 2)) / ...
1147  // (radius * omega);
1148  // simplify(taylor(factor, omega, 'order', 3))
1149  factor = (omega2 * radius2) / T(3) - omega2 / T(12) + T(1);
1150  } else if (radius2 < kEpsilon) {
1151  // Derivation of this case with Matlab:
1152  // syms radius omega;
1153  // factor(radius) = atan(radius * 2 * tan(omega / 2)) / ...
1154  // (radius * omega);
1155  // simplify(taylor(factor, radius, 'order', 3))
1156  const T tan_half_omega = ceres::tan(omega / T(2));
1157  factor = (T(-2) * tan_half_omega *
1158  (T(4) * radius2 * tan_half_omega * tan_half_omega - T(3))) /
1159  (T(3) * omega);
1160  } else {
1161  const T radius = ceres::sqrt(radius2);
1162  const T numerator =
1163  ceres::atan(radius * T(2) * ceres::tan(omega / T(2)));
1164  factor = numerator / (radius * omega);
1165  }
1166 
1167  *du = u * factor;
1168  *dv = v * factor;
1169 }
1170 
1171 template <typename T>
1173  const T* extra_params, const T u, const T v, T* du, T* dv) {
1174  T omega = extra_params[0];
1175 
1176  // Chosen arbitrarily.
1177  const T kEpsilon = T(1e-4);
1178 
1179  const T radius2 = u * u + v * v;
1180  const T omega2 = omega * omega;
1181 
1182  T factor;
1183  if (omega2 < kEpsilon) {
1184  // Derivation of this case with Matlab:
1185  // syms radius omega;
1186  // factor(radius) = tan(radius * omega) / ...
1187  // (radius * 2*tan(omega/2));
1188  // simplify(taylor(factor, omega, 'order', 3))
1189  factor = (omega2 * radius2) / T(3) - omega2 / T(12) + T(1);
1190  } else if (radius2 < kEpsilon) {
1191  // Derivation of this case with Matlab:
1192  // syms radius omega;
1193  // factor(radius) = tan(radius * omega) / ...
1194  // (radius * 2*tan(omega/2));
1195  // simplify(taylor(factor, radius, 'order', 3))
1196  factor = (omega * (omega * omega * radius2 + T(3))) /
1197  (T(6) * ceres::tan(omega / T(2)));
1198  } else {
1199  const T radius = ceres::sqrt(radius2);
1200  const T numerator = ceres::tan(radius * omega);
1201  factor = numerator / (radius * T(2) * ceres::tan(omega / T(2)));
1202  }
1203 
1204  *du = u * factor;
1205  *dv = v * factor;
1206 }
1207 
1209 // SimpleRadialFisheyeCameraModel
1210 
1212  return "f, cx, cy, k";
1213 }
1214 
1215 std::vector<size_t>
1217  return {0};
1218 }
1219 
1220 std::vector<size_t>
1222  return {1, 2};
1223 }
1224 
1225 std::vector<size_t>
1227  return {3};
1228 }
1229 
1231  const double focal_length, const size_t width, const size_t height) {
1232  return {focal_length, width / 2.0, height / 2.0, 0};
1233 }
1234 
1235 template <typename T>
1237  const T* params, const T u, const T v, T* x, T* y) {
1238  const T f = params[0];
1239  const T c1 = params[1];
1240  const T c2 = params[2];
1241 
1242  // Distortion
1243  T du, dv;
1244  Distortion(&params[3], u, v, &du, &dv);
1245  *x = u + du;
1246  *y = v + dv;
1247 
1248  // Transform to image coordinates
1249  *x = f * *x + c1;
1250  *y = f * *y + c2;
1251 }
1252 
1253 template <typename T>
1255  const T* params, const T x, const T y, T* u, T* v) {
1256  const T f = params[0];
1257  const T c1 = params[1];
1258  const T c2 = params[2];
1259 
1260  // Lift points to normalized plane
1261  *u = (x - c1) / f;
1262  *v = (y - c2) / f;
1263 
1264  IterativeUndistortion(&params[3], u, v);
1265 }
1266 
1267 template <typename T>
1269  const T* extra_params, const T u, const T v, T* du, T* dv) {
1270  const T k = extra_params[0];
1271 
1272  const T r = ceres::sqrt(u * u + v * v);
1273 
1274  if (r > T(std::numeric_limits<double>::epsilon())) {
1275  const T theta = ceres::atan(r);
1276  const T theta2 = theta * theta;
1277  const T thetad = theta * (T(1) + k * theta2);
1278  *du = u * thetad / r - u;
1279  *dv = v * thetad / r - v;
1280  } else {
1281  *du = T(0);
1282  *dv = T(0);
1283  }
1284 }
1285 
1287 // RadialFisheyeCameraModel
1288 
1290  return "f, cx, cy, k1, k2";
1291 }
1292 
1294  return {0};
1295 }
1296 
1298  return {1, 2};
1299 }
1300 
1302  return {3, 4};
1303 }
1304 
1306  const double focal_length, const size_t width, const size_t height) {
1307  return {focal_length, width / 2.0, height / 2.0, 0, 0};
1308 }
1309 
1310 template <typename T>
1312  const T* params, const T u, const T v, T* x, T* y) {
1313  const T f = params[0];
1314  const T c1 = params[1];
1315  const T c2 = params[2];
1316 
1317  // Distortion
1318  T du, dv;
1319  Distortion(&params[3], u, v, &du, &dv);
1320  *x = u + du;
1321  *y = v + dv;
1322 
1323  // Transform to image coordinates
1324  *x = f * *x + c1;
1325  *y = f * *y + c2;
1326 }
1327 
1328 template <typename T>
1330  const T* params, const T x, const T y, T* u, T* v) {
1331  const T f = params[0];
1332  const T c1 = params[1];
1333  const T c2 = params[2];
1334 
1335  // Lift points to normalized plane
1336  *u = (x - c1) / f;
1337  *v = (y - c2) / f;
1338 
1339  IterativeUndistortion(&params[3], u, v);
1340 }
1341 
1342 template <typename T>
1344  const T* extra_params, const T u, const T v, T* du, T* dv) {
1345  const T k1 = extra_params[0];
1346  const T k2 = extra_params[1];
1347 
1348  const T r = ceres::sqrt(u * u + v * v);
1349 
1350  if (r > T(std::numeric_limits<double>::epsilon())) {
1351  const T theta = ceres::atan(r);
1352  const T theta2 = theta * theta;
1353  const T theta4 = theta2 * theta2;
1354  const T thetad = theta * (T(1) + k1 * theta2 + k2 * theta4);
1355  *du = u * thetad / r - u;
1356  *dv = v * thetad / r - v;
1357  } else {
1358  *du = T(0);
1359  *dv = T(0);
1360  }
1361 }
1362 
1364 // ThinPrismFisheyeCameraModel
1365 
1367  return "fx, fy, cx, cy, k1, k2, p1, p2, k3, k4, sx1, sy1";
1368 }
1369 
1371  return {0, 1};
1372 }
1373 
1374 std::vector<size_t>
1376  return {2, 3};
1377 }
1378 
1380  return {4, 5, 6, 7, 8, 9, 10, 11};
1381 }
1382 
1384  const double focal_length, const size_t width, const size_t height) {
1385  return {focal_length,
1386  focal_length,
1387  width / 2.0,
1388  height / 2.0,
1389  0,
1390  0,
1391  0,
1392  0,
1393  0,
1394  0,
1395  0,
1396  0};
1397 }
1398 
1399 template <typename T>
1401  const T* params, const T u, const T v, T* x, T* y) {
1402  const T f1 = params[0];
1403  const T f2 = params[1];
1404  const T c1 = params[2];
1405  const T c2 = params[3];
1406 
1407  const T r = ceres::sqrt(u * u + v * v);
1408 
1409  T uu, vv;
1410  if (r > T(std::numeric_limits<double>::epsilon())) {
1411  const T theta = ceres::atan(r);
1412  uu = theta * u / r;
1413  vv = theta * v / r;
1414  } else {
1415  uu = u;
1416  vv = v;
1417  }
1418 
1419  // Distortion
1420  T du, dv;
1421  Distortion(&params[4], uu, vv, &du, &dv);
1422  *x = uu + du;
1423  *y = vv + dv;
1424 
1425  // Transform to image coordinates
1426  *x = f1 * *x + c1;
1427  *y = f2 * *y + c2;
1428 }
1429 
1430 template <typename T>
1432  const T* params, const T x, const T y, T* u, T* v) {
1433  const T f1 = params[0];
1434  const T f2 = params[1];
1435  const T c1 = params[2];
1436  const T c2 = params[3];
1437 
1438  // Lift points to normalized plane
1439  *u = (x - c1) / f1;
1440  *v = (y - c2) / f2;
1441 
1442  IterativeUndistortion(&params[4], u, v);
1443 
1444  const T theta = ceres::sqrt(*u * *u + *v * *v);
1445  const T theta_cos_theta = theta * ceres::cos(theta);
1446  if (theta_cos_theta > T(std::numeric_limits<double>::epsilon())) {
1447  const T scale = ceres::sin(theta) / theta_cos_theta;
1448  *u *= scale;
1449  *v *= scale;
1450  }
1451 }
1452 
1453 template <typename T>
1455  const T* extra_params, const T u, const T v, T* du, T* dv) {
1456  const T k1 = extra_params[0];
1457  const T k2 = extra_params[1];
1458  const T p1 = extra_params[2];
1459  const T p2 = extra_params[3];
1460  const T k3 = extra_params[4];
1461  const T k4 = extra_params[5];
1462  const T sx1 = extra_params[6];
1463  const T sy1 = extra_params[7];
1464 
1465  const T u2 = u * u;
1466  const T uv = u * v;
1467  const T v2 = v * v;
1468  const T r2 = u2 + v2;
1469  const T r4 = r2 * r2;
1470  const T r6 = r4 * r2;
1471  const T r8 = r6 * r2;
1472  const T radial = k1 * r2 + k2 * r4 + k3 * r6 + k4 * r8;
1473  *du = u * radial + T(2) * p1 * uv + p2 * (r2 + T(2) * u2) + sx1 * r2;
1474  *dv = v * radial + T(2) * p2 * uv + p1 * (r2 + T(2) * v2) + sy1 * r2;
1475 }
1476 
1478 
1480  const std::vector<double>& params,
1481  const double u,
1482  const double v,
1483  double* x,
1484  double* y) {
1485  switch (model_id) {
1486 #define CAMERA_MODEL_CASE(CameraModel) \
1487  case CameraModel::kModelId: \
1488  CameraModel::WorldToImage(params.data(), u, v, x, y); \
1489  break;
1490 
1492 
1493 #undef CAMERA_MODEL_CASE
1494  }
1495 }
1496 
1498  const std::vector<double>& params,
1499  const double x,
1500  const double y,
1501  double* u,
1502  double* v) {
1503  switch (model_id) {
1504 #define CAMERA_MODEL_CASE(CameraModel) \
1505  case CameraModel::kModelId: \
1506  CameraModel::ImageToWorld(params.data(), x, y, u, v); \
1507  break;
1508 
1510 
1511 #undef CAMERA_MODEL_CASE
1512  }
1513 }
1514 
1516  const std::vector<double>& params,
1517  const double threshold) {
1518  switch (model_id) {
1519 #define CAMERA_MODEL_CASE(CameraModel) \
1520  case CameraModel::kModelId: \
1521  return CameraModel::ImageToWorldThreshold(params.data(), threshold); \
1522  break;
1523 
1525 
1526 #undef CAMERA_MODEL_CASE
1527  }
1528 
1529  return -1;
1530 }
1531 
1532 } // namespace colmap
int width
int height
math::float2 uv
#define CAMERA_MODEL_DEFINITIONS(model_id_value, model_name_value, num_params_value)
Definition: camera_models.h:58
#define CAMERA_MODEL_SWITCH_CASES
const double * e
normal_z y
normal_z x
void CameraModelImageToWorld(const int model_id, const std::vector< double > &params, const double x, const double y, double *u, double *v)
const std::vector< size_t > & CameraModelFocalLengthIdxs(const int model_id)
static const int kInvalidCameraModelId
Definition: camera_models.h:55
bool ExistsCameraModelWithId(const int model_id)
bool ExistsCameraModelWithName(const std::string &model_name)
bool CameraModelHasBogusParams(const int model_id, const std::vector< double > &params, const size_t width, const size_t height, const double min_focal_length_ratio, const double max_focal_length_ratio, const double max_extra_param)
size_t CameraModelNumParams(const int model_id)
bool CameraModelVerifyParams(const int model_id, const std::vector< double > &params)
const std::vector< size_t > & CameraModelExtraParamsIdxs(const int model_id)
std::string CameraModelIdToName(const int model_id)
const std::vector< size_t > & CameraModelPrincipalPointIdxs(const int model_id)
double CameraModelImageToWorldThreshold(const int model_id, const std::vector< double > &params, const double threshold)
std::string CameraModelParamsInfo(const int model_id)
void CameraModelWorldToImage(const int model_id, const std::vector< double > &params, const double u, const double v, double *x, double *y)
std::vector< double > CameraModelInitializeParams(const int model_id, const double focal_length, const size_t width, const size_t height)
int CameraModelNameToId(const std::string &model_name)
static bool HasBogusPrincipalPoint(const std::vector< T > &params, const size_t width, const size_t height)
static bool HasBogusFocalLength(const std::vector< T > &params, const size_t width, const size_t height, const T min_focal_length_ratio, const T max_focal_length_ratio)
static bool HasBogusExtraParams(const std::vector< T > &params, const T max_extra_param)
static bool HasBogusParams(const std::vector< T > &params, const size_t width, const size_t height, const T min_focal_length_ratio, const T max_focal_length_ratio, const T max_extra_param)
static T ImageToWorldThreshold(const T *params, const T threshold)
static void IterativeUndistortion(const T *params, T *u, T *v)
static std::vector< size_t > InitializeExtraParamsIdxs()
static const std::string model_name
static const int model_id
static void Undistortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< size_t > InitializeFocalLengthIdxs()
static std::string InitializeParamsInfo()
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static std::vector< size_t > InitializePrincipalPointIdxs()
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< size_t > InitializePrincipalPointIdxs()
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::string InitializeParamsInfo()
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::vector< size_t > InitializePrincipalPointIdxs()
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::string InitializeParamsInfo()
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::string InitializeParamsInfo()
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::string InitializeParamsInfo()
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::string InitializeParamsInfo()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::vector< size_t > InitializeFocalLengthIdxs()
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::string InitializeParamsInfo()
static std::vector< size_t > InitializeExtraParamsIdxs()
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static std::string InitializeParamsInfo()
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::string InitializeParamsInfo()
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static std::vector< size_t > InitializeFocalLengthIdxs()
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static std::vector< size_t > InitializeFocalLengthIdxs()
static std::vector< size_t > InitializeExtraParamsIdxs()
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static std::vector< size_t > InitializeFocalLengthIdxs()
static void ImageToWorld(const T *params, const T x, const T y, T *u, T *v)
static void WorldToImage(const T *params, const T u, const T v, T *x, T *y)
static void Distortion(const T *extra_params, const T u, const T v, T *du, T *dv)
static std::vector< double > InitializeParams(const double focal_length, const size_t width, const size_t height)
static std::vector< size_t > InitializeExtraParamsIdxs()
static std::vector< size_t > InitializePrincipalPointIdxs()
static std::string InitializeParamsInfo()