1- #include < colmap/camera/models .h>
2- #include < colmap/geometry/projection .h>
1+ #include < colmap/scene/projection .h>
2+ #include < colmap/sensor/models .h>
33#include < colmap/util/types.h>
44
55#include < ceres/ceres.h>
@@ -15,12 +15,9 @@ inline void WorldToPixel(const T* camera_params, const T* qvec, const T* tvec,
1515 projection[1 ] += tvec[1 ];
1616 projection[2 ] += tvec[2 ];
1717
18- // Project to image plane.
19- projection[0 ] /= projection[2 ]; // u
20- projection[1 ] /= projection[2 ]; // v
21-
2218 // Distort and transform to pixel space.
23- CameraModel::WorldToImage (camera_params, projection[0 ], projection[1 ], &xy[0 ], &xy[1 ]);
19+ CameraModel::ImgFromCam (camera_params, projection[0 ], projection[1 ], projection[2 ],
20+ &xy[0 ], &xy[1 ]);
2421}
2522
2623template <typename T>
@@ -43,7 +40,7 @@ class BundleAdjustmentCost {
4340 static ceres::CostFunction* Create (const Eigen::Vector2d& point2D,
4441 const double stddev) {
4542 return (new ceres::AutoDiffCostFunction<BundleAdjustmentCost<CameraModel>, 2 , 4 , 3 , 3 ,
46- CameraModel::kNumParams >(
43+ CameraModel::num_params >(
4744 new BundleAdjustmentCost (point2D, stddev)));
4845 }
4946
@@ -78,7 +75,7 @@ class BundleAdjustmentConstantPoseCost : public BundleAdjustmentCost<CameraModel
7875 const Eigen::Vector4d qvec,
7976 const Eigen::Vector3d tvec) {
8077 return (new ceres::AutoDiffCostFunction<BundleAdjustmentConstantPoseCost<CameraModel>,
81- 2 , 3 , CameraModel::kNumParams >(
78+ 2 , 3 , CameraModel::num_params >(
8279 new BundleAdjustmentConstantPoseCost (point2D, stddev, qvec, tvec)));
8380 }
8481
@@ -111,7 +108,7 @@ class BundleAdjustmentConstantRigCost : public BundleAdjustmentCost<CameraModel>
111108 const Eigen::Vector4d rel_qvec,
112109 const Eigen::Vector3d rel_tvec) {
113110 return (new ceres::AutoDiffCostFunction<BundleAdjustmentConstantRigCost<CameraModel>,
114- 2 , 4 , 3 , 3 , CameraModel::kNumParams >(
111+ 2 , 4 , 3 , 3 , CameraModel::num_params >(
115112 new BundleAdjustmentConstantRigCost (point2D, stddev, rel_qvec, rel_tvec)));
116113 }
117114
@@ -144,7 +141,7 @@ class BundleAdjustmentRigCost : public BundleAdjustmentCost<CameraModel> {
144141 static ceres::CostFunction* Create (const Eigen::Vector2d& point2D,
145142 const double stddev) {
146143 return (new ceres::AutoDiffCostFunction<BundleAdjustmentRigCost<CameraModel>, 2 , 4 , 3 ,
147- 4 , 3 , 3 , CameraModel::kNumParams >(
144+ 4 , 3 , 3 , CameraModel::num_params >(
148145 new BundleAdjustmentRigCost (point2D, stddev)));
149146 }
150147
@@ -159,12 +156,12 @@ class BundleAdjustmentRigCost : public BundleAdjustmentCost<CameraModel> {
159156 }
160157};
161158
162- ceres::CostFunction* CreateBundleAdjustmentCost (int camera_model_id,
163- const Eigen::Vector2d& point2D,
164- const double stddev) {
159+ ceres::CostFunction* CreateBundleAdjustmentCost (
160+ const colmap::CameraModelId camera_model_id, const Eigen::Vector2d& point2D,
161+ const double stddev) {
165162 switch (camera_model_id) {
166163#define CAMERA_MODEL_CASE (CameraModel ) \
167- case colmap::CameraModel::kModelId : \
164+ case colmap::CameraModel::model_id : \
168165 return BundleAdjustmentCost<colmap::CameraModel>::Create (point2D, stddev); \
169166 break ;
170167 CAMERA_MODEL_SWITCH_CASES
@@ -173,11 +170,11 @@ ceres::CostFunction* CreateBundleAdjustmentCost(int camera_model_id,
173170}
174171
175172ceres::CostFunction* CreateBundleAdjustmentConstantPoseCost (
176- int camera_model_id, const Eigen::Vector2d& point2D , const Eigen::Vector4d& qvec ,
177- const Eigen::Vector3d& tvec, const double stddev) {
173+ const colmap::CameraModelId camera_model_id , const Eigen::Vector2d& point2D ,
174+ const Eigen::Vector4d& qvec, const Eigen:: Vector3d& tvec, const double stddev) {
178175 switch (camera_model_id) {
179176#define CAMERA_MODEL_CASE (CameraModel ) \
180- case colmap::CameraModel::kModelId : \
177+ case colmap::CameraModel::model_id : \
181178 return BundleAdjustmentConstantPoseCost<colmap::CameraModel>::Create ( \
182179 point2D, stddev, qvec, tvec); \
183180 break ;
@@ -187,11 +184,12 @@ ceres::CostFunction* CreateBundleAdjustmentConstantPoseCost(
187184}
188185
189186ceres::CostFunction* CreateBundleAdjustmentConstantRigCost (
190- int camera_model_id, const Eigen::Vector2d& point2D, const Eigen::Vector4d& rel_qvec,
191- const Eigen::Vector3d& rel_tvec, const double stddev) {
187+ const colmap::CameraModelId camera_model_id, const Eigen::Vector2d& point2D,
188+ const Eigen::Vector4d& rel_qvec, const Eigen::Vector3d& rel_tvec,
189+ const double stddev) {
192190 switch (camera_model_id) {
193191#define CAMERA_MODEL_CASE (CameraModel ) \
194- case colmap::CameraModel::kModelId : \
192+ case colmap::CameraModel::model_id : \
195193 return BundleAdjustmentConstantRigCost<colmap::CameraModel>::Create ( \
196194 point2D, stddev, rel_qvec, rel_tvec); \
197195 break ;
@@ -200,12 +198,12 @@ ceres::CostFunction* CreateBundleAdjustmentConstantRigCost(
200198 }
201199}
202200
203- ceres::CostFunction* CreateBundleAdjustmentRigCost (int camera_model_id,
204- const Eigen::Vector2d& point2D,
205- const double stddev) {
201+ ceres::CostFunction* CreateBundleAdjustmentRigCost (
202+ const colmap::CameraModelId camera_model_id, const Eigen::Vector2d& point2D,
203+ const double stddev) {
206204 switch (camera_model_id) {
207205#define CAMERA_MODEL_CASE (CameraModel ) \
208- case colmap::CameraModel::kModelId : \
206+ case colmap::CameraModel::model_id : \
209207 return BundleAdjustmentRigCost<colmap::CameraModel>::Create (point2D, stddev); \
210208 break ;
211209 CAMERA_MODEL_SWITCH_CASES
0 commit comments