Image & Lens API
Source: raptor/image.hpp, raptor/lens.hpp
Types
| Name | Description |
|---|---|
| Image | Owning image container. |
| ImageType | Image format type identifier. |
| ImageView | Non-owning view over image data. |
| LensModel | Type-erased lens model. |
Image types and containers
ImageType
enum class ImageType : std::uint32_t
Image format type identifier
Enumeration identifying the pixel format of an image.
Gray8 = 0 : Single channel, 8 bits per pixel
Rgb8 = 1 : 3 channels (red, green, blue), 8 bits per channel
Rgba8 = 2 : 4 channels (red, green, blue, alpha), 8 bits per channel
ImageView
class ImageView
Non-owning view over image data
Lightweight container for passing images without ownership. Provides direct access to image properties and data.
The caller must ensure the underlying data outlives the ImageView.
Example:
ImageView view{ImageType::Rgb8, 1920, 1080, data};
std::int32_t w = view.width();
std::int32_t h = view.height();
std::uint32_t ch = view.channels();
const std::uint8_t* ptr = view.bytes().data();
Functions
| Name | Description |
|---|---|
| ImageView(span) | Construct a view from raw image data (span). |
| ImageView(uint8_t) | Construct a view from raw image data (pointer). |
| ImageView(Image) | Construct a view from an Image. |
| type | Image format type. |
| width | Image width in pixels. |
| height | Image height in pixels. |
| channels | Number of channels per pixel. |
| numPixels | Total number of pixels (width * height). |
| bytes | Image data as a span of bytes. |
Function Details
ImageView
ImageView(ImageType type, std::int32_t width, std::int32_t height, std::span<const std::uint8_t> data) noexcept
Construct a view from raw image data (span) Parameters:
type- Image format typewidth- Image width in pixelsheight- Image height in pixelsdata- Span of image data (must outlive this view)
ImageView(ImageType type, std::int32_t width, std::int32_t height, const std::uint8_t* data) noexcept
Construct a view from raw image data (pointer) Parameters:
type- Image format typewidth- Image width in pixelsheight- Image height in pixelsdata- Pointer to image data (must outlive this view)
ImageView(const Image& image) noexcept
Construct a view from an Image Parameters:
image- The image to create a view from (must outlive this view)
type
[[nodiscard]] ImageType type() const noexcept
Returns: Image format type
width
[[nodiscard]] std::int32_t width() const noexcept
Returns: Image width in pixels
height
[[nodiscard]] std::int32_t height() const noexcept
Returns: Image height in pixels
channels
[[nodiscard]] std::uint32_t channels() const noexcept
Returns: Number of channels per pixel
numPixels
[[nodiscard]] std::size_t numPixels() const noexcept
Returns: Total number of pixels (width * height)
bytes
[[nodiscard]] std::span<const std::uint8_t> bytes() const noexcept
Returns: Image data as a span of bytes
Image
class Image
Owning image container
Owns the image data and provides direct access to image properties.
Example:
Image image{ImageType::Rgb8, 1920, 1080, data};
std::int32_t w = image.width();
std::int32_t h = image.height();
std::uint8_t* ptr = image.bytes().data();
Functions
| Name | Description |
|---|---|
| Image(span) | Construct an image from raw image data (copies data from span). |
| Image(uint8_t) | Construct an image from raw image data (copies data from pointer). |
| Image(ImageView) | Construct an image from an ImageView (copies data). |
| type | Image format type. |
| width | Image width in pixels. |
| height | Image height in pixels. |
| channels | Number of channels per pixel. |
| numPixels | Total number of pixels (width * height). |
| bytes(1) | Image data as a mutable span of bytes. |
| bytes(2) | Image data as a const span of bytes. |
Function Details
Image
Image(ImageType type, std::int32_t width, std::int32_t height, std::span<const std::uint8_t> data)
Construct an image from raw image data (copies data from span) Parameters:
type- Image format typewidth- Image width in pixelsheight- Image height in pixelsdata- Span of image data to copy Throws:std::invalid_argument- If width or height is non-positive, data is empty, or data.size() does not equal width * height * channels(type).
Image(ImageType type, std::int32_t width, std::int32_t height, const std::uint8_t* data)
Construct an image from raw image data (copies data from pointer) Parameters:
type- Image format typewidth- Image width in pixelsheight- Image height in pixelsdata- Pointer to image data to copy Throws:std::invalid_argument- If width or height is non-positive, or data is null.
explicit Image(const ImageView& view)
Construct an image from an ImageView (copies data) Parameters:
view- View to copy data from Throws:std::invalid_argument- If the view has non-positive dimensions or empty data.
type
[[nodiscard]] ImageType type() const noexcept
Returns: Image format type
width
[[nodiscard]] std::int32_t width() const noexcept
Returns: Image width in pixels
height
[[nodiscard]] std::int32_t height() const noexcept
Returns: Image height in pixels
channels
[[nodiscard]] std::uint32_t channels() const noexcept
Returns: Number of channels per pixel
numPixels
[[nodiscard]] std::size_t numPixels() const noexcept
Returns: Total number of pixels (width * height)
bytes
[[nodiscard]] std::span<std::uint8_t> bytes() noexcept
Returns: Image data as a mutable span of bytes
[[nodiscard]] std::span<const std::uint8_t> bytes() const noexcept
Returns: Image data as a const span of bytes
Lens model types for various projection equations
Pinhole
struct Pinhole
Pinhole lens parameters
Standard pinhole camera with focal lengths and principal point. No lens distortion.