Module: Gsplat::IO::ColmapText
- Defined in:
- lib/gsplat/io/colmap_text.rb
Overview
Decoder for COLMAP sparse-model text files.
Class Method Summary collapse
Class Method Details
.cameras(data) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gsplat/io/colmap_text.rb', line 9 def cameras(data) content_lines(data).to_h do |line| fields = line.split id = Integer(fields.shift, 10) model = fields.shift width = Integer(fields.shift, 10) height = Integer(fields.shift, 10) [id, { id: id, model: model, width: width, height: height, params: fields.map { |item| Float(item) } }] end end |
.images(data) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gsplat/io/colmap_text.rb', line 20 def images(data) lines = data.lines(chomp: true) output = {} until lines.empty? = (lines) break unless fields = .split id = Integer(fields.shift, 10) qvec = fields.shift(4).map { |item| Float(item) } tvec = fields.shift(3).map { |item| Float(item) } camera_id = Integer(fields.shift, 10) name = fields.join(" ") points_line = lines.shift.to_s.strip points2d, point3d_ids = parse_image_points(points_line) output[id] = { id: id, qvec: qvec, tvec: tvec, camera_id: camera_id, name: name, points2d: points2d, point3d_ids: point3d_ids } end output end |
.points3d(data) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/gsplat/io/colmap_text.rb', line 43 def points3d(data) content_lines(data).to_h do |line| fields = line.split id = Integer(fields.shift, 10) xyz = fields.shift(3).map { |item| Float(item) } rgb = fields.shift(3).map { |item| Integer(item, 10) } error = Float(fields.shift) track = fields.each_slice(2).map { |image_id, point_index| [Integer(image_id, 10), Integer(point_index, 10)] } [id, { id: id, xyz: xyz, rgb: rgb, error: error, track: track }] end end |