Class: Gsplat::Training::Scene
- Inherits:
-
Object
- Object
- Gsplat::Training::Scene
- Defined in:
- lib/gsplat/training/scene.rb
Overview
In-memory multi-view training scene.
Instance Attribute Summary collapse
-
#colors ⇒ Object
readonly
Returns the value of attribute colors.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#images ⇒ Object
readonly
Returns the value of attribute images.
-
#intrinsics ⇒ Object
readonly
Returns the value of attribute intrinsics.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
-
#scene_scale ⇒ Object
readonly
Returns the value of attribute scene_scale.
-
#viewmats ⇒ Object
readonly
Returns the value of attribute viewmats.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Class Method Summary collapse
-
.from_colmap(path, data_factor: 1) ⇒ Scene
Loads a COLMAP sparse model and its corresponding RGB images.
Instance Method Summary collapse
-
#camera_count ⇒ Integer
Number of registered training views.
-
#initialize(viewmats:, intrinsics:, images:, points:, colors:, names: nil, scene_scale: nil) ⇒ Scene
constructor
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(viewmats:, intrinsics:, images:, points:, colors:, names: nil, scene_scale: nil) ⇒ Scene
rubocop:disable Metrics/ParameterLists
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/gsplat/training/scene.rb', line 12 def initialize(viewmats:, intrinsics:, images:, points:, colors:, names: nil, scene_scale: nil) # rubocop:enable Metrics/ParameterLists @viewmats = viewmats @intrinsics = intrinsics @images = images @points = points @colors = colors @names = names || Array.new(images.shape[0]) { |index| format("camera_%03d", index) } @height = images.shape[1] @width = images.shape[2] validate! @scene_scale = scene_scale || infer_scene_scale end |
Instance Attribute Details
#colors ⇒ Object (readonly)
Returns the value of attribute colors.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def colors @colors end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def height @height end |
#images ⇒ Object (readonly)
Returns the value of attribute images.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def images @images end |
#intrinsics ⇒ Object (readonly)
Returns the value of attribute intrinsics.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def intrinsics @intrinsics end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def names @names end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def points @points end |
#scene_scale ⇒ Object (readonly)
Returns the value of attribute scene_scale.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def scene_scale @scene_scale end |
#viewmats ⇒ Object (readonly)
Returns the value of attribute viewmats.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def viewmats @viewmats end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/gsplat/training/scene.rb', line 8 def width @width end |
Class Method Details
.from_colmap(path, data_factor: 1) ⇒ Scene
Loads a COLMAP sparse model and its corresponding RGB images.
rubocop:disable Metrics/AbcSize
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gsplat/training/scene.rb', line 32 def self.from_colmap(path, data_factor: 1) dataset = IO::Colmap.read(path, data_factor: data_factor) records = dataset.images.values.sort_by(&:name) views = Numo::SFloat.cast(stack(records.map(&:world_to_camera))) intrinsics = Numo::SFloat.cast( stack(records.map { |record| dataset.cameras.fetch(record.camera_id).intrinsics }) ) image_directory = resolve_image_directory(path, data_factor) images = Numo::SFloat.cast( stack(records.map { |record| IO::Image.read(File.join(image_directory, record.name)) }) ) points = dataset.points3d.values.sort_by(&:id) new( viewmats: views, intrinsics: intrinsics, images: images, points: Numo::SFloat.cast(stack_rows(points.map(&:xyz))), colors: Numo::SFloat.cast(stack_rows(points.map { |point| Numo::DFloat.cast(point.rgb) / 255.0 })), names: records.map(&:name) ) end |
Instance Method Details
#camera_count ⇒ Integer
Number of registered training views.
58 59 60 |
# File 'lib/gsplat/training/scene.rb', line 58 def camera_count images.shape[0] end |