diff --git a/libraries/wavemap/include/wavemap/integrator/projection_model/ouster_projector.h b/libraries/wavemap/include/wavemap/integrator/projection_model/ouster_projector.h index 3748883f4..3f270671e 100644 --- a/libraries/wavemap/include/wavemap/integrator/projection_model/ouster_projector.h +++ b/libraries/wavemap/include/wavemap/integrator/projection_model/ouster_projector.h @@ -51,8 +51,6 @@ class OusterProjector : public ProjectorBase { explicit OusterProjector(const Config& config); - IndexElement getNumRows() const final { return config_.elevation.num_cells; } - IndexElement getNumColumns() const final { return config_.azimuth.num_cells; } Vector2D getMinImageCoordinates() const final { return {config_.elevation.min_angle, config_.azimuth.min_angle}; } diff --git a/libraries/wavemap/include/wavemap/integrator/projection_model/pinhole_camera_projector.h b/libraries/wavemap/include/wavemap/integrator/projection_model/pinhole_camera_projector.h index 80219917d..4f37fc86d 100644 --- a/libraries/wavemap/include/wavemap/integrator/projection_model/pinhole_camera_projector.h +++ b/libraries/wavemap/include/wavemap/integrator/projection_model/pinhole_camera_projector.h @@ -46,11 +46,10 @@ class PinholeCameraProjector : public ProjectorBase { using Config = PinholeCameraProjectorConfig; explicit PinholeCameraProjector(const Config& config) - : ProjectorBase(Vector2D::Ones(), Vector2D::Zero()), + : ProjectorBase({config_.width, config_.height}, Vector2D::Ones(), + Vector2D::Zero()), config_(config.checkValid()) {} - IndexElement getNumRows() const final { return config_.width; } - IndexElement getNumColumns() const final { return config_.height; } Vector2D getMinImageCoordinates() const final { return indexToImage(Index2D::Zero()); } diff --git a/libraries/wavemap/include/wavemap/integrator/projection_model/projector_base.h b/libraries/wavemap/include/wavemap/integrator/projection_model/projector_base.h index 99dfcc9ec..7743a1891 100644 --- a/libraries/wavemap/include/wavemap/integrator/projection_model/projector_base.h +++ b/libraries/wavemap/include/wavemap/integrator/projection_model/projector_base.h @@ -28,14 +28,16 @@ class ProjectorBase { using Ptr = std::shared_ptr; using ConstPtr = std::shared_ptr; - ProjectorBase(Vector2D index_to_image_scale_factor, Vector2D image_offset) - : index_to_image_scale_factor_(std::move(index_to_image_scale_factor)), + ProjectorBase(Index2D dimensions, Vector2D index_to_image_scale_factor, + Vector2D image_offset) + : dimensions_(std::move(dimensions)), + index_to_image_scale_factor_(std::move(index_to_image_scale_factor)), image_offset_(std::move(image_offset)) {} virtual ~ProjectorBase() = default; - virtual IndexElement getNumRows() const = 0; - virtual IndexElement getNumColumns() const = 0; - Index2D getDimensions() const { return {getNumRows(), getNumColumns()}; } + IndexElement getNumRows() const { dimensions_.x(); } + IndexElement getNumColumns() const { dimensions_.y(); } + Index2D getDimensions() const { return dimensions_; } virtual Vector2D getMinImageCoordinates() const = 0; virtual Vector2D getMaxImageCoordinates() const = 0; virtual Eigen::Matrix sensorAxisIsPeriodic() const = 0; @@ -90,6 +92,7 @@ class ProjectorBase { const Point3D& t_W_C) const = 0; protected: + const Index2D dimensions_; const Vector2D index_to_image_scale_factor_; const Vector2D image_to_index_scale_factor_ = Vector2D::Ones().cwiseQuotient(index_to_image_scale_factor_); diff --git a/libraries/wavemap/include/wavemap/integrator/projection_model/spherical_projector.h b/libraries/wavemap/include/wavemap/integrator/projection_model/spherical_projector.h index 5247fac85..555e63a83 100644 --- a/libraries/wavemap/include/wavemap/integrator/projection_model/spherical_projector.h +++ b/libraries/wavemap/include/wavemap/integrator/projection_model/spherical_projector.h @@ -37,8 +37,6 @@ class SphericalProjector : public ProjectorBase { explicit SphericalProjector(const Config& config); - IndexElement getNumRows() const final { return config_.elevation.num_cells; } - IndexElement getNumColumns() const final { return config_.azimuth.num_cells; } Vector2D getMinImageCoordinates() const final { return {config_.elevation.min_angle, config_.azimuth.min_angle}; } diff --git a/libraries/wavemap/src/integrator/projection_model/ouster_projector.cc b/libraries/wavemap/src/integrator/projection_model/ouster_projector.cc index bd108c29f..9bf037c3d 100644 --- a/libraries/wavemap/src/integrator/projection_model/ouster_projector.cc +++ b/libraries/wavemap/src/integrator/projection_model/ouster_projector.cc @@ -5,12 +5,13 @@ namespace wavemap { OusterProjector::OusterProjector(const OusterProjector::Config& config) : ProjectorBase( + {config_.elevation.num_cells, config_.azimuth.num_cells}, Vector2D(config.elevation.max_angle - config.elevation.min_angle, config.azimuth.max_angle - config.azimuth.min_angle) .cwiseQuotient(Index2D(config.elevation.num_cells - 1, config.azimuth.num_cells - 1) .cast()), - Vector2D(config.elevation.min_angle, config.azimuth.min_angle)), + {config.elevation.min_angle, config.azimuth.min_angle}), config_(config.checkValid()) {} Eigen::Matrix OusterProjector::sensorAxisIsPeriodic() const { diff --git a/libraries/wavemap/src/integrator/projection_model/spherical_projector.cc b/libraries/wavemap/src/integrator/projection_model/spherical_projector.cc index e68ee12dd..ae8df498f 100644 --- a/libraries/wavemap/src/integrator/projection_model/spherical_projector.cc +++ b/libraries/wavemap/src/integrator/projection_model/spherical_projector.cc @@ -5,12 +5,13 @@ namespace wavemap { SphericalProjector::SphericalProjector(const SphericalProjector::Config& config) : ProjectorBase( + {config_.elevation.num_cells, config_.azimuth.num_cells}, Vector2D(config.elevation.max_angle - config.elevation.min_angle, config.azimuth.max_angle - config.azimuth.min_angle) .cwiseQuotient(Index2D(config.elevation.num_cells - 1, config.azimuth.num_cells - 1) .cast()), - Vector2D(config.elevation.min_angle, config.azimuth.min_angle)), + {config.elevation.min_angle, config.azimuth.min_angle}), config_(config.checkValid()) {} Eigen::Matrix SphericalProjector::sensorAxisIsPeriodic() const {