Ocean
Ocean::Media::Special::ImageNpy Class Reference

This class implements read and write functions for NPY (NumPy) images. More...

Static Public Member Functions

static Frame decodeImage (const void *buffer, const size_t size)
 Decodes a NPY image from a given binary buffer. More...
 
static bool encodeImage (const Frame &frame, std::vector< uint8_t > &buffer)
 Encodes a given frame as NPY image to a resulting buffer. More...
 
static bool isPixelFormatSupported (const FrameType::PixelFormat pixelFormat)
 Returns whether a given pixel format is supported natively. More...
 
static bool isPixelOriginSupported (const FrameType::PixelOrigin pixelOrigin)
 Returns whether a given pixel origin is supported natively. More...
 
static bool isFrameTypeSupported (const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin)
 Returns whether a given pixel format together with a given pixel origin is supported natively. More...
 

Static Protected Member Functions

static bool readHeader (const uint8_t *&data, size_t &size, FrameType &frameType, bool &isRowMajor)
 Reads the header of a NPY file. More...
 
static FrameType::PixelFormat translatePixelFormat (const std::string &pixelFormat)
 Translates the pixel format. More...
 
static std::string translatePixelFormat (const FrameType::PixelFormat pixelFormat)
 Translates the pixel format. More...
 

Detailed Description

This class implements read and write functions for NPY (NumPy) images.

Member Function Documentation

◆ decodeImage()

static Frame Ocean::Media::Special::ImageNpy::decodeImage ( const void *  buffer,
const size_t  size 
)
static

Decodes a NPY image from a given binary buffer.

Parameters
bufferThe buffer from which the image will be loaded, must be valid
sizeThe size of the given buffer in bytes, with range [1, infinity)
Returns
The frame containing the image information, an invalid frame if the image could not be loaded

◆ encodeImage()

static bool Ocean::Media::Special::ImageNpy::encodeImage ( const Frame frame,
std::vector< uint8_t > &  buffer 
)
static

Encodes a given frame as NPY image to a resulting buffer.

Parameters
frameThe frame to be written, must be valid
bufferThe resulting buffer storing the binary information of the NPY image
Returns
True, if succeeded

◆ isFrameTypeSupported()

bool Ocean::Media::Special::ImageNpy::isFrameTypeSupported ( const FrameType::PixelFormat  pixelFormat,
const FrameType::PixelOrigin  pixelOrigin 
)
inlinestatic

Returns whether a given pixel format together with a given pixel origin is supported natively.

Parameters
pixelFormatThe pixel format to be checked
pixelOriginThe pixel origin to be checked
Returns
True, if so; False, if a conversion will be necessary

◆ isPixelFormatSupported()

bool Ocean::Media::Special::ImageNpy::isPixelFormatSupported ( const FrameType::PixelFormat  pixelFormat)
inlinestatic

Returns whether a given pixel format is supported natively.

Parameters
pixelFormatThe pixel format to be checked
Returns
True, if so; False, if a conversion will be necessary

◆ isPixelOriginSupported()

bool Ocean::Media::Special::ImageNpy::isPixelOriginSupported ( const FrameType::PixelOrigin  pixelOrigin)
inlinestatic

Returns whether a given pixel origin is supported natively.

Parameters
pixelOriginThe pixel origin to be checked
Returns
True, if so; False, if a conversion will be necessary

◆ readHeader()

static bool Ocean::Media::Special::ImageNpy::readHeader ( const uint8_t *&  data,
size_t &  size,
FrameType frameType,
bool &  isRowMajor 
)
staticprotected

Reads the header of a NPY file.

Parameters
dataThe data buffer, will be moved if the header could be read successfully, must be valid
sizeThe size of the buffer in bytes, will be reduced if the header could be read successfully, must be valid
frameTypeThe resulting frame type
isRowMajorTrue, if the data is given in row-major order; False, if the data is given in column-major order
Returns
True, if succeeded

◆ translatePixelFormat() [1/2]

static std::string Ocean::Media::Special::ImageNpy::translatePixelFormat ( const FrameType::PixelFormat  pixelFormat)
staticprotected

Translates the pixel format.

Parameters
pixelFormatThe pixel format to be translated
Returns
The resulting pixel format as string, empty if unknown

◆ translatePixelFormat() [2/2]

static FrameType::PixelFormat Ocean::Media::Special::ImageNpy::translatePixelFormat ( const std::string &  pixelFormat)
staticprotected

Translates the pixel format.

Parameters
pixelFormatThe pixel format to be translated given as string
Returns
The resulting pixel format, FORMAT_UNDEFINED if unknown

The documentation for this class was generated from the following file: