Struct RawImage¶
Defined in File messages.hpp
Struct Documentation¶
-
struct RawImage¶
A raw image.
Public Functions
-
FoxgloveError encode(uint8_t *ptr, size_t len, size_t *encoded_len)¶
Encoded the RawImage as protobuf to the provided buffer.
On success, writes the serialized length to *encoded_len. If the provided buffer has insufficient capacity, writes the required capacity to *encoded_len and returns FoxgloveError::BufferTooShort. If the message cannot be encoded, writes the reason to stderr and returns FoxgloveError::EncodeError.
- Parameters:
ptr – the destination buffer. must point to at least len valid bytes.
len – the length of the destination buffer.
encoded_len – where the serialized length or required capacity will be written to.
Public Members
-
std::string frame_id¶
Frame of reference for the image. The origin of the frame is the optical center of the camera. +x points to the right in the image, +y points down, and +z points into the plane of the image.
-
uint32_t width = 0¶
Image width in pixels.
-
uint32_t height = 0¶
Image height in pixels.
-
std::string encoding¶
Encoding of the raw image data. See the
datafield description for supported values.
-
uint32_t step = 0¶
Byte length of a single row. This is usually some multiple of
widthdepending on the encoding, but can be greater to incorporate padding.
-
std::vector<std::byte> data¶
Raw image data.
For each
encodingvalue, thedatafield contains image pixel data serialized as follows:yuv422oruyvy:Pixel colors are decomposed into Y’UV channels.
Pixel channel values are represented as unsigned 8-bit integers.
U and V values are shared between horizontal pairs of pixels. Each pair of output pixels is serialized as [U, Y1, V, Y2].
stepmust be greater than or equal towidth* 2.
yuv422_yuy2oryuyv:Pixel colors are decomposed into Y’UV channels.
Pixel channel values are represented as unsigned 8-bit integers.
U and V values are shared between horizontal pairs of pixels. Each pair of output pixels is encoded as [Y1, U, Y2, V].
stepmust be greater than or equal towidth* 2.
nv12:Pixel colors are decomposed into Y’UV channels using 4:2:0 chroma subsampling. The data is stored in NV12 semi-planar layout with two contiguous planes: a Y (luma) plane followed by an interleaved UV (chroma) plane.
All channel values are represented as unsigned 8-bit integers.
Both planes use
stepas their row stride.The Y plane contains one luma value per pixel (
step*heightbytes).The UV plane contains interleaved U, V chroma pairs, subsampled by a factor of 2 in both dimensions (
width/2 pairs per row,height/2 rows,step*height/2 bytes). Each U, V pair is shared by a 2x2 block of pixels.widthandheightmust be even.stepmust be greater than or equal towidth.Total
datalength isstep*height* 3/2 bytes.
rgb8:Pixel colors are decomposed into Red, Green, and Blue channels.
Pixel channel values are represented as unsigned 8-bit integers.
Each output pixel is serialized as [R, G, B].
stepmust be greater than or equal towidth* 3.
rgba8:Pixel colors are decomposed into Red, Green, Blue, and Alpha channels.
Pixel channel values are represented as unsigned 8-bit integers.
Each output pixel is serialized as [R, G, B, Alpha].
stepmust be greater than or equal towidth* 4.
bgr8or8UC3:Pixel colors are decomposed into Blue, Green, and Red channels.
Pixel channel values are represented as unsigned 8-bit integers.
Each output pixel is serialized as [B, G, R].
stepmust be greater than or equal towidth* 3.
bgra8:Pixel colors are decomposed into Blue, Green, Red, and Alpha channels.
Pixel channel values are represented as unsigned 8-bit integers.
Each output pixel is encoded as [B, G, R, Alpha].
stepmust be greater than or equal towidth* 4.
32FC1:Pixel brightness is represented as a single-channel, 32-bit little-endian IEEE 754 floating-point value, ranging from 0.0 (black) to 1.0 (white).
stepmust be greater than or equal towidth* 4.
bayer_rggb8,bayer_bggr8,bayer_gbrg8, orbayer_grbg8:Pixel colors are decomposed into Red, Blue and Green channels.
Pixel channel values are represented as unsigned 8-bit integers, and serialized in a 2x2 bayer filter pattern.
The order of the four letters after
bayer_determine the layout, so forbayer_wxyz8the pattern is:w | x - + - y | z
stepmust be greater than or equal towidth.
mono8or8UC1:Pixel brightness is represented as unsigned 8-bit integers.
stepmust be greater than or equal towidth.
mono16or16UC1:Pixel brightness is represented as 16-bit unsigned little-endian integers. Rendering of these values is controlled in Image panel color mode settings.
stepmust be greater than or equal towidth* 2.
-
FoxgloveError encode(uint8_t *ptr, size_t len, size_t *encoded_len)¶