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

Method ReadTwoViewGeometry

src/colmap/scene/database_sqlite.cc:938–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

936 }
937
938 TwoViewGeometry ReadTwoViewGeometry(const image_t image_id1,
939 const image_t image_id2) const override {
940 Sqlite3StmtContext context(sql_stmt_read_two_view_geometry_);
941
942 const image_pair_t pair_id = ImagePairToPairId(image_id1, image_id2);
943 SQLITE3_CALL(
944 sqlite3_bind_int64(sql_stmt_read_two_view_geometry_, 1, pair_id));
945
946 const int rc = SQLITE3_CALL(sqlite3_step(sql_stmt_read_two_view_geometry_));
947
948 TwoViewGeometry two_view_geometry;
949
950 FeatureMatchesBlob blob = ReadDynamicMatrixBlob<FeatureMatchesBlob>(
951 sql_stmt_read_two_view_geometry_, rc, 0);
952
953 two_view_geometry.config = static_cast<int>(
954 sqlite3_column_int64(sql_stmt_read_two_view_geometry_, 3));
955
956 // Read matrix data if present (NULL means not set).
957 if (sqlite3_column_type(sql_stmt_read_two_view_geometry_, 4) !=
958 SQLITE_NULL) {
959 two_view_geometry.F = ReadStaticMatrixBlob<Eigen::Matrix3d>(
960 sql_stmt_read_two_view_geometry_, rc, 4);
961 }
962 if (sqlite3_column_type(sql_stmt_read_two_view_geometry_, 5) !=
963 SQLITE_NULL) {
964 two_view_geometry.E = ReadStaticMatrixBlob<Eigen::Matrix3d>(
965 sql_stmt_read_two_view_geometry_, rc, 5);
966 }
967 if (sqlite3_column_type(sql_stmt_read_two_view_geometry_, 6) !=
968 SQLITE_NULL) {
969 two_view_geometry.H = ReadStaticMatrixBlob<Eigen::Matrix3d>(
970 sql_stmt_read_two_view_geometry_, rc, 6);
971 }
972
973 // Read the pose data if present (NULL means not set).
974 const bool has_qvec =
975 sqlite3_column_type(sql_stmt_read_two_view_geometry_, 7) != SQLITE_NULL;
976 const bool has_tvec =
977 sqlite3_column_type(sql_stmt_read_two_view_geometry_, 8) != SQLITE_NULL;
978 THROW_CHECK_EQ(has_qvec, has_tvec)
979 << "qvec and tvec must both be NULL or both be non-NULL";
980 if (has_qvec) {
981 const Eigen::Vector4d quat_wxyz = ReadStaticMatrixBlob<Eigen::Vector4d>(
982 sql_stmt_read_two_view_geometry_, rc, 7);
983 Rigid3d cam2_from_cam1;
984 cam2_from_cam1.rotation() = Eigen::Quaterniond(
985 quat_wxyz(0), quat_wxyz(1), quat_wxyz(2), quat_wxyz(3));
986 cam2_from_cam1.translation() = ReadStaticMatrixBlob<Eigen::Vector3d>(
987 sql_stmt_read_two_view_geometry_, rc, 8);
988 two_view_geometry.cam2_from_cam1 = cam2_from_cam1;
989 }
990
991 two_view_geometry.inlier_matches = FeatureMatchesFromBlob(blob);
992 if (two_view_geometry.F) {
993 two_view_geometry.F->transposeInPlace();
994 }
995 if (two_view_geometry.E) {

Callers 6

TEST_PFunction · 0.45
TESTFunction · 0.45
GetTwoViewGeometryMethod · 0.45
ExistsInlierMatchesMethod · 0.45
TESTFunction · 0.45
ReloadMethod · 0.45

Calls 6

ImagePairToPairIdFunction · 0.85
FeatureMatchesFromBlobFunction · 0.85
ShouldSwapImagePairFunction · 0.85
rotationMethod · 0.45
translationMethod · 0.45
InvertMethod · 0.45

Tested by 3

TEST_PFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36