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

Function WriteProjectionMatrix

src/colmap/controllers/undistorters.cc:66–90  ·  view source on GitHub ↗

Write projection matrix P = K * [R t] to file and prepend given header.

Source from the content-addressed store, hash-verified

64
65// Write projection matrix P = K * [R t] to file and prepend given header.
66void WriteProjectionMatrix(const std::filesystem::path& path,
67 const Camera& camera,
68 const Image& image,
69 const std::string& header) {
70 THROW_CHECK(camera.model_id == PinholeCameraModel::model_id);
71
72 std::ofstream file(path, std::ios::trunc);
73 THROW_CHECK_FILE_OPEN(file, path);
74 file.imbue(std::locale::classic());
75
76 Eigen::Matrix3d calib_matrix = Eigen::Matrix3d::Identity();
77 calib_matrix(0, 0) = camera.FocalLengthX();
78 calib_matrix(1, 1) = camera.FocalLengthY();
79 calib_matrix(0, 2) = camera.PrincipalPointX();
80 calib_matrix(1, 2) = camera.PrincipalPointY();
81
82 const Eigen::Matrix3x4d img_from_world =
83 calib_matrix * image.CamFromWorld().ToMatrix();
84
85 if (!header.empty()) {
86 file << header << '\n';
87 }
88
89 WriteMatrix(img_from_world, &file);
90}
91
92void WriteCOLMAPCommands(const bool geometric,
93 const std::filesystem::path& workspace_path,

Callers 1

UndistortMethod · 0.85

Calls 8

WriteMatrixFunction · 0.85
FocalLengthXMethod · 0.80
FocalLengthYMethod · 0.80
PrincipalPointXMethod · 0.80
PrincipalPointYMethod · 0.80
CamFromWorldMethod · 0.80
emptyMethod · 0.80
ToMatrixMethod · 0.45

Tested by

no test coverage detected