MCPcopy Create free account
hub / github.com/colmap/colmap / CameraModelCamRayFromImg

Method CameraModelCamRayFromImg

src/colmap/sensor/models.h:2853–2872  ·  view source on GitHub ↗

Unproject a pixel to a unit bearing vector in camera coordinates. Unlike CameraModelCamFromImg (which is limited to the forward hemisphere via the 2D normalized-coordinate representation), this function returns a valid 3D unit ray for any pixel on the camera model's image plane, including back-facing rays on omnidirectional cameras. Downstream geometry code (two-view geometry, absolute/relative

Source from the content-addressed store, hash-verified

2851// Downstream geometry code (two-view geometry, absolute/relative pose,
2852// triangulation) should prefer this function when a 3D bearing is needed.
2853std::optional<Eigen::Vector3d> CameraModelCamRayFromImg(
2854 const CameraModelId model_id,
2855 const std::vector<double>& params,
2856 const Eigen::Vector2d& xy) {
2857 Eigen::Vector3d ray;
2858 switch (model_id) {
2859#define CAMERA_MODEL_CASE(CameraModel) \
2860 case CameraModel::model_id: \
2861 if (CameraModel::CamRayFromImg( \
2862 params.data(), xy.x(), xy.y(), &ray.x(), &ray.y(), &ray.z())) { \
2863 return ray; \
2864 } \
2865 break;
2866
2867 CAMERA_MODEL_SWITCH_CASES
2868
2869#undef CAMERA_MODEL_CASE
2870 }
2871 return std::nullopt;
2872}
2873
2874double CameraModelCamFromImgThreshold(const CameraModelId model_id,
2875 const std::vector<double>& params,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected