| 97 | return np.frombuffer(blob, dtype=dtype).reshape(*shape) |
| 98 | |
| 99 | class COLMAPDatabase(sqlite3.Connection): |
| 100 | |
| 101 | @staticmethod |
| 102 | def connect(database_path): |
| 103 | return sqlite3.connect(database_path, factory=COLMAPDatabase) |
| 104 | |
| 105 | def __init__(self, *args, **kwargs): |
| 106 | super(COLMAPDatabase, self).__init__(*args, **kwargs) |
| 107 | |
| 108 | self.create_tables = lambda: self.executescript(CREATE_ALL) |
| 109 | self.create_cameras_table = \ |
| 110 | lambda: self.executescript(CREATE_CAMERAS_TABLE) |
| 111 | self.create_descriptors_table = \ |
| 112 | lambda: self.executescript(CREATE_DESCRIPTORS_TABLE) |
| 113 | self.create_images_table = \ |
| 114 | lambda: self.executescript(CREATE_IMAGES_TABLE) |
| 115 | self.create_two_view_geometries_table = \ |
| 116 | lambda: self.executescript(CREATE_TWO_VIEW_GEOMETRIES_TABLE) |
| 117 | self.create_keypoints_table = \ |
| 118 | lambda: self.executescript(CREATE_KEYPOINTS_TABLE) |
| 119 | self.create_matches_table = \ |
| 120 | lambda: self.executescript(CREATE_MATCHES_TABLE) |
| 121 | self.create_name_index = lambda: self.executescript(CREATE_NAME_INDEX) |
| 122 | |
| 123 | def update_camera(self, model, width, height, params, camera_id): |
| 124 | params = np.asarray(params, np.float64) |
| 125 | cursor = self.execute( |
| 126 | "UPDATE cameras SET model=?, width=?, height=?, params=?, prior_focal_length=1 WHERE camera_id=?", |
| 127 | (model, width, height, array_to_blob(params),camera_id)) |
| 128 | return cursor.lastrowid |
| 129 | |
| 130 | def camTodatabase(txtfile, database_path): |
| 131 | import os |
nothing calls this directly
no outgoing calls
no test coverage detected