/
NNImage

NNImage

NNImageFormat

typedef enum NNImageFormat { NN_IMAGE_FMT_BGR888 = 0x01, NN_IMAGE_FMT_UNKNOWN = 0xFF } NNImageFormat;

Introduction to the Enum

Enumeration representing different image formats supported by the neural network framework. This enumeration lists the formats that can be used to specify the layout of image data.

Introduction to the Enum's items

  1. NN_IMAGE_FMT_BGR888: BGR format with 8 bits per channel.

  2. NN_IMAGE_FMT_UNKNOWN:An unknown or unsupported image format.

NNImage

/** * @class NNImage * @brief The NNImage class represents an image data entity within the neural network framework. * It inherits from the NNData class and provides methods to create, manipulate, and retrieve image data. */ class NNImage : public NNData { public: static std::shared_ptr<NNImage> createImage(std::string fileName); static std::shared_ptr<NNImage> createImage(uint8_t* data, uint32_t dataSize, uint32_t dataFormat, uint32_t width, uint32_t height); static std::shared_ptr<NNImage> createImage(std::shared_ptr<NNRawData> rawData, uint32_t dataFormat, uint32_t width, uint32_t height); public: std::string getImageName(); std::string getFileName(); void setImageName(std::string fileName); void setFileName(std::string fileName); uint8_t* getData(); uint32_t getDataSize(); uint32_t getDataFormat(); uint32_t getWidth(); uint32_t getHeight(); public: void save(std::string fileName); public: virtual std::string getType(); virtual std::string toString(); virtual std::shared_ptr<NNData> clone(bool deep); };

Introduction to the class

The NNImage class represents an image data entity within the neural network framework.

It inherits from the NNData class and provides methods to create, manipulate, and retrieve image data.

Introduction to the Class's Methods

  1. static std::shared_ptr<NNImage> createImage(std::string fileName)

    • brief: Creates a new NNImage object from a file.

    • param

      • fileName: The path to the image file.

    • return shared_ptr<NNImage>: A shared pointer to the created NNImage object.

  2. static std::shared_ptr<NNImage> createImage(uint8_t* data, uint32_t dataSize, uint32_t dataFormat, uint32_t width, uint32_t height)

    • brief: Creates a new NNImage object from raw image data.

    • param

      • data: A pointer to the raw image data.

      • dataSize: The size of the raw image data in bytes.

      • dataFormat: The format of the raw image data (see NNImageFormat).

      • width: The width of the image in pixels.

      • height: The height of the image in pixels.

    • return shared_ptr<NNImage>: A shared pointer to the created NNImage object.

  3. static std::shared_ptr<NNImage> createImage(std::shared_ptr<NNRawData> rawData, uint32_t dataFormat, uint32_t width, uint32_t height)

    • brief: Creates a new NNImage object from a shared pointer to raw data.

    • param

      • rawData: A shared pointer to the raw data containing the image.

      • dataFormat: The format of the raw image data (see NNImageFormat).

      • width: The width of the image in pixels.

      • height: The height of the image in pixels.

    • return shared_ptr<NNImage>: A shared pointer to the created NNImage object.

  4. std::string getImageName()

    • brief: Retrieves the name of the image (not the filename, but a potential user-defined name).

    • return string: A string containing the image name.

  5. std::string getFileName()

    • brief: Retrieves the filename associated with the image (if applicable).

    • return string: A string containing the filename.

  6. void setImageName(std::string imageName);

    • brief: Sets the name of the image.

    • param

      • imageName: The new name for the image.

  7. void setFileName(std::string fileName);

    • brief: Sets the filename associated with the image.

    • param

      • fileName: The new filename for the image.

  8. void* getData()

    • brief: Retrieves a pointer to the raw image data.

    • return void*: A pointer to the raw image data.

  9. uint32_t getDataSize()

    • brief: Retrieves the size of the raw image data in bytes.

    • return uint32_t: The size of the raw image data.

  10. uint32_t getDataFormat()

    • brief: Retrieves the format of the raw image data (see NNImageFormat).

    • return uint32_t: The format of the raw image data.

  11. uint32_t getWidth()

    • brief: Retrieves the width of the image in pixels.

    • return uint32_t: The width of the image..

  12. uint32_t getHeight()

    • brief: Retrieves the height of the image in pixels.

    • return uint32_t: The height of the image.

  13. void save(std::string fileName)

    • brief: Saves the image to a file.

    • param

      • fileName: The path to save the image file.

  14. std::string getType()

    • brief: Gets a string identifying the type of this image.

    • return string: A string representing the type of image.

  15. std::string toString()

    • brief: Returns a string representation of the object, including image dimensions and format.

    • return string: A formatted string containing information about the object.

  16. std::shared_ptr<NNPoint> clone(bool deep)

    • brief: Creates a copy of this object. If deep is true, performs a deep copy; otherwise, a shallow copy.

    • param

      • deep: Specifies whether to perform a deep copy (true) or a shallow copy (false).

    • return shared_ptr<NNData>: A shared pointer to the created copy of the object.

Related content

NNModelInfo
More like this
NNModelPluginInfo
NNModelPluginInfo
More like this
NNFloatData
More like this
NNFile
More like this
NNRawData
More like this
NNData
More like this