Xavia SDK c++ API 2.1.0
API description of the xavia library
Loading...
Searching...
No Matches
IImage Class Referenceabstract

The interface of the image object. More...

Public Member Functions

virtual void Deserialize (const std::uint8_t *pBuffer, const std::size_t size)=0
 Fill this image object from binary data.
virtual void Deserialize (const std::vector< std::uint8_t > &data)=0
 Fill this image object from binary data.
virtual std::uint32_t GetHeight () const =0
 Get the height of the image.
virtual const ImageMetaDataGetMetaData () const =0
 Get the metadata of the current image.
virtual const std::vector< std::uint8_t > & GetPixelData () const =0
 Get the raw pixel data.
virtual xavia::sdk::PixelFormat GetPixelFormat () const =0
 Get the pixel format.
virtual std::uint32_t GetWidth () const =0
 Get the width of the image.
virtual void SaveAsJpeg (const std::wstring &filePath, const int quality=90, const bool chromaticSubsampling=false) const =0
 Save the image as an 8 bit jpeg file.
virtual std::vector< std::uint8_t > Serialize ()=0
 Convert this image object into binary data.

Detailed Description

The interface of the image object.

Returned by the image callback, each image object represents a single frame from the camera.

The image object contains the pixel data, metadata such as timestamps and frame numbers, and dimensions.

Member Function Documentation

◆ Deserialize() [1/2]

virtual void Deserialize ( const std::uint8_t * pBuffer,
const std::size_t size )
pure virtual

Fill this image object from binary data.

Parameters
[in]pBufferpointer to the start of the binary data.
[in]sizenumber of bytes to read from the buffer.

Use this to efficiently load the image from the XenomatiX proprietary format. The opposite of the Serialize() function.

Note
although it is acceptable to provide too many bytes, it is best that size matches exactly the required size. This function will keep an internal copy of the provided data.

◆ Deserialize() [2/2]

virtual void Deserialize ( const std::vector< std::uint8_t > & data)
pure virtual

Fill this image object from binary data.

Parameters
[in]datavector of bytes that hold the image information.

Use this to efficiently load the image from the XenomatiX proprietary format. The opposite of the Serialize() function.

Note
although it is acceptable to provide too many bytes, it is best that size matches exactly the required size. This function will keep an internal copy of the provided data.

◆ GetHeight()

virtual std::uint32_t GetHeight ( ) const
pure virtual

Get the height of the image.

Returns
Height in pixels.

◆ GetMetaData()

virtual const ImageMetaData & GetMetaData ( ) const
pure virtual

Get the metadata of the current image.

Returns
const reference to the metadata struct,
See also
ImageMetaData.

◆ GetPixelData()

virtual const std::vector< std::uint8_t > & GetPixelData ( ) const
pure virtual

Get the raw pixel data.

Returns
const reference to the vector of pixel data. The size and interpretation depend on width, height, and pixel format.

◆ GetPixelFormat()

virtual xavia::sdk::PixelFormat GetPixelFormat ( ) const
pure virtual

Get the pixel format.

Returns
Pixel format identifier (0=RGB8, 1=BGR8, 2=Mono8, etc.).

◆ GetWidth()

virtual std::uint32_t GetWidth ( ) const
pure virtual

Get the width of the image.

Returns
Width in pixels.

◆ SaveAsJpeg()

virtual void SaveAsJpeg ( const std::wstring & filePath,
const int quality = 90,
const bool chromaticSubsampling = false ) const
pure virtual

Save the image as an 8 bit jpeg file.

Parameters
[in]filePathpath to the output jpeg file.
[in]qualityJPEG quality (0-100) (default 90).
[in]chromaticSubsamplingEnable or disable chromatic subsampling (default false).

JPEG saving is only supported for RGB8 format. If the image is in Bayer format, it will be demosaiced before saving. If the image was converted to RGB12, it will be scaled down to 8 bits per channel.

◆ Serialize()

virtual std::vector< std::uint8_t > Serialize ( )
pure virtual

Convert this image object into binary data.

Returns
vector of bytes that hold the image information

Use this to efficiently store the image in the XenomatiX proprietary format. When dumping to disk, it is customary to use the .ximg extension.

See also
Deserialize() functions to read the information back.