34 #include <unordered_map>
36 #include <boost/algorithm/string.hpp>
42 #define CAMERA_MODEL_CASE(CameraModel) \
43 const int CameraModel::model_id = InitializeModelId(); \
44 const std::string CameraModel::model_name = \
45 CameraModel::InitializeModelName(); \
46 const size_t CameraModel::num_params = InitializeNumParams(); \
47 const std::string CameraModel::params_info = \
48 CameraModel::InitializeParamsInfo(); \
49 const std::vector<size_t> CameraModel::focal_length_idxs = \
50 CameraModel::InitializeFocalLengthIdxs(); \
51 const std::vector<size_t> CameraModel::principal_point_idxs = \
52 CameraModel::InitializePrincipalPointIdxs(); \
53 const std::vector<size_t> CameraModel::extra_params_idxs = \
54 CameraModel::InitializeExtraParamsIdxs();
58 #undef CAMERA_MODEL_CASE
61 std::unordered_map<std::string, int> camera_model_name_to_id;
63 #define CAMERA_MODEL_CASE(CameraModel) \
64 camera_model_name_to_id.emplace(CameraModel::model_name, \
65 CameraModel::model_id);
69 #undef CAMERA_MODEL_CASE
71 return camera_model_name_to_id;
75 std::unordered_map<int, std::string> camera_model_id_to_name;
77 #define CAMERA_MODEL_CASE(CameraModel) \
78 camera_model_id_to_name.emplace(CameraModel::model_id, \
79 CameraModel::model_name);
83 #undef CAMERA_MODEL_CASE
85 return camera_model_id_to_name;
121 const double focal_length,
128 #define CAMERA_MODEL_CASE(CameraModel) \
129 case CameraModel::kModelId: \
130 return CameraModel::InitializeParams(focal_length, width, height); \
135 #undef CAMERA_MODEL_CASE
141 #define CAMERA_MODEL_CASE(CameraModel) \
142 case CameraModel::kModelId: \
143 return CameraModel::params_info; \
148 #undef CAMERA_MODEL_CASE
151 return "Camera model does not exist";
158 #define CAMERA_MODEL_CASE(CameraModel) \
159 case CameraModel::kModelId: \
160 return CameraModel::focal_length_idxs; \
165 #undef CAMERA_MODEL_CASE
173 #define CAMERA_MODEL_CASE(CameraModel) \
174 case CameraModel::kModelId: \
175 return CameraModel::principal_point_idxs; \
180 #undef CAMERA_MODEL_CASE
188 #define CAMERA_MODEL_CASE(CameraModel) \
189 case CameraModel::kModelId: \
190 return CameraModel::extra_params_idxs; \
195 #undef CAMERA_MODEL_CASE
203 #define CAMERA_MODEL_CASE(CameraModel) \
204 case CameraModel::kModelId: \
205 return CameraModel::num_params;
209 #undef CAMERA_MODEL_CASE
216 const std::vector<double>& params) {
218 #define CAMERA_MODEL_CASE(CameraModel) \
219 case CameraModel::kModelId: \
220 if (params.size() == CameraModel::num_params) { \
227 #undef CAMERA_MODEL_CASE
234 const std::vector<double>& params,
236 const double min_focal_length_ratio,
237 const double max_focal_length_ratio,
238 const double max_extra_param) {
240 #define CAMERA_MODEL_CASE(CameraModel) \
241 case CameraModel::kModelId: \
242 return CameraModel::HasBogusParams( \
243 params, width, height, min_focal_length_ratio, max_focal_length_ratio, \
249 #undef CAMERA_MODEL_CASE
#define CAMERA_MODEL_CASES
#define CAMERA_MODEL_SWITCH_CASES
const std::vector< size_t > & CameraModelFocalLengthIdxs(const int model_id)
static const int kInvalidCameraModelId
bool ExistsCameraModelWithId(const int model_id)
static const std::unordered_map< std::string, int > CAMERA_MODEL_NAME_TO_ID
static const std::vector< size_t > EMPTY_IDXS
bool ExistsCameraModelWithName(const std::string &model_name)
bool CameraModelHasBogusParams(const int model_id, const std::vector< double > ¶ms, 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)
static const std::unordered_map< int, std::string > CAMERA_MODEL_ID_TO_NAME
size_t CameraModelNumParams(const int model_id)
bool CameraModelVerifyParams(const int model_id, const std::vector< double > ¶ms)
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)
std::unordered_map< int, std::string > InitialzeCameraModelIdToName()
CAMERA_MODEL_CASES std::unordered_map< std::string, int > InitialzeCameraModelNameToId()
std::string CameraModelParamsInfo(const int model_id)
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)