Module: Gsplat::Backend::RubyProjection
- Defined in:
- lib/gsplat/backend/ruby/projection.rb
Overview
Numo implementation of dense fused Gaussian projection.
Class Method Summary collapse
-
.forward(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d:, near_plane:, far_plane:, radius_clip:, calc_compensations:, camera_model:, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil, global_z_order: true) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
.prepare_inputs(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d, near_plane, far_plane, radius_clip, camera_model, radial_coeffs = nil, tangential_coeffs = nil, thin_prism_coeffs = nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/ParameterLists.
-
.project(means, covars, intrinsics, width, height, camera_model, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
Class Method Details
.forward(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d:, near_plane:, far_plane:, radius_clip:, calc_compensations:, camera_model:, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil, global_z_order: true) ⇒ Object
rubocop:disable Metrics/ParameterLists
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/gsplat/backend/ruby/projection.rb', line 10 def forward(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d:, near_plane:, far_plane:, radius_clip:, calc_compensations:, camera_model:, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil, global_z_order: true) # rubocop:enable Metrics/ParameterLists inputs = prepare_inputs( means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d, near_plane, far_plane, radius_clip, camera_model, radial_coeffs, tangential_coeffs, thin_prism_coeffs ) means, covars, viewmats, intrinsics = inputs camera_means, camera_covars = Math::CameraProjection.world_to_cam(means, covars, viewmats) projection_means = projection_safe_means(camera_means, near_plane, far_plane) means2d, covars2d = project( projection_means, camera_covars, intrinsics, width, height, camera_model, radial_coeffs: radial_coeffs, tangential_coeffs: tangential_coeffs, thin_prism_coeffs: thin_prism_coeffs ) finish_projection( camera_means, means2d, covars2d, width, height, eps2d, near_plane, far_plane, radius_clip, calc_compensations, global_z_order: global_z_order ) end |
.prepare_inputs(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d, near_plane, far_plane, radius_clip, camera_model, radial_coeffs = nil, tangential_coeffs = nil, thin_prism_coeffs = nil) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/ParameterLists
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/gsplat/backend/ruby/projection.rb', line 50 def prepare_inputs(means, covars, quaternions, scales, viewmats, intrinsics, width, height, eps2d, near_plane, far_plane, radius_clip, camera_model, radial_coeffs = nil, tangential_coeffs = nil, thin_prism_coeffs = nil) # rubocop:enable Metrics/AbcSize, Metrics/ParameterLists unless means.is_a?(Numo::NArray) && [Numo::SFloat, Numo::DFloat].include?(means.class) raise ArgumentError, "means must be Numo::SFloat or Numo::DFloat" end valid_means = means.ndim == 2 && means.shape[-1] == 3 raise ShapeError, "expected means [N,3], got #{means.shape.inspect}" unless valid_means covars = prepare_covariances(means, covars, quaternions, scales) viewmats = means.class.cast(viewmats) intrinsics = means.class.cast(intrinsics) unless viewmats.ndim == 3 && viewmats.shape[1..] == [4, 4] raise ShapeError, "expected viewmats [C,4,4], got #{viewmats.shape.inspect}" end unless intrinsics.shape == [viewmats.shape[0], 3, 3] raise ShapeError, "expected intrinsics [#{viewmats.shape[0]},3,3], got #{intrinsics.shape.inspect}" end ( width: width, height: height, eps2d: eps2d, near_plane: near_plane, far_plane: far_plane, radius_clip: radius_clip, camera_model: camera_model ) validate_distortion!( viewmats.shape[0], camera_model, radial_coeffs, tangential_coeffs, thin_prism_coeffs ) [means, covars, viewmats, intrinsics] end |
.project(means, covars, intrinsics, width, height, camera_model, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/gsplat/backend/ruby/projection.rb', line 157 def project(means, covars, intrinsics, width, height, camera_model, radial_coeffs: nil, tangential_coeffs: nil, thin_prism_coeffs: nil) # rubocop:enable Metrics/ParameterLists if camera_model.to_s == "ortho" return Math::CameraProjection.ortho_proj(means, covars, intrinsics, width, height) end if camera_model.to_s == "fisheye" || [radial_coeffs, tangential_coeffs, thin_prism_coeffs].any? return Math::CameraProjection.distorted_proj( means, covars, intrinsics, camera_model, radial_coeffs: radial_coeffs, tangential_coeffs: tangential_coeffs, thin_prism_coeffs: thin_prism_coeffs ) end Math::CameraProjection.persp_proj(means, covars, intrinsics, width, height) end |