Module: Gsplat::IO::ColmapBinary
- Defined in:
- lib/gsplat/io/colmap_binary.rb
Overview
Decoder for COLMAP sparse-model binary files.
Defined Under Namespace
Classes: Cursor
Constant Summary collapse
- CAMERA_PARAM_COUNTS =
{ 0 => 3, 1 => 4, 2 => 4, 3 => 5, 4 => 8, 5 => 8, 6 => 12, 7 => 5, 8 => 4, 9 => 5, 10 => 12 }.freeze
Class Method Summary collapse
Class Method Details
.cameras(data) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gsplat/io/colmap_binary.rb', line 43 def cameras(data) cursor = Cursor.new(data) Array.new(cursor.scalar("Q<", 8)).to_h do id = cursor.scalar("l<", 4) model = cursor.scalar("l<", 4) count = CAMERA_PARAM_COUNTS.fetch(model) do raise NotSupportedError, "unknown COLMAP camera model id #{model}" end width = cursor.scalar("Q<", 8) height = cursor.scalar("Q<", 8) [id, { id: id, model: model, width: width, height: height, params: cursor.array("E", 8, count) }] end end |
.images(data) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/gsplat/io/colmap_binary.rb', line 57 def images(data) cursor = Cursor.new(data) Array.new(cursor.scalar("Q<", 8)).to_h do id = cursor.scalar("l<", 4) qvec = cursor.array("E", 8, 4) tvec = cursor.array("E", 8, 3) camera_id = cursor.scalar("l<", 4) name = cursor.cstring count = cursor.scalar("Q<", 8) points2d, point3d_ids = image_points(cursor, count) [id, { id: id, qvec: qvec, tvec: tvec, camera_id: camera_id, name: name, points2d: points2d, point3d_ids: point3d_ids }] end end |
.points3d(data) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gsplat/io/colmap_binary.rb', line 72 def points3d(data) cursor = Cursor.new(data) Array.new(cursor.scalar("Q<", 8)).to_h do id = cursor.scalar("Q<", 8) xyz = cursor.array("E", 8, 3) rgb = cursor.array("C", 1, 3) error = cursor.scalar("E", 8) track_count = cursor.scalar("Q<", 8) track = Array.new(track_count) { [cursor.scalar("l<", 4), cursor.scalar("l<", 4)] } [id, { id: id, xyz: xyz, rgb: rgb, error: error, track: track }] end end |