Skip to content

util functions

util functions

Public Functions

Type Name
void SaigeInitTextFormatting (SaigeTextFormatting * formatting)
SaigeInitTextFormatting.
unsigned int SaigeConvertImageType (const int channel, const int type)
SaigeConvertImageType.
int SaigeOverlaySegmentedObjects (const void * baseImage, const SaigeSegmentedObject * objects, SaigeModelInfo * modelInfo, const int numOfSegmentedObjects, const int width, const int height, const int channels, const int type, const bool isRGB, const double overlayAlpha, void * resultImage)
SaigeOverlaySegmentedObjects.
int SaigeOverlayDetectedObjects (const void * baseImage, const SaigeDetectedObject * objects, SaigeModelInfo * modelInfo, const int numOfDetectedObjects, const int width, const int height, const int channels, const int type, const bool withClassName, const bool isRGB, const double overlayAlpha, void * resultImage)
SaigeOverlayDetectedObjects.
int SaigeOverlayTextObjects (const void * baseImage, const SaigeTextObject * objects, const int numOfTextObjects, const int width, const int height, const int channels, const int type, const bool isRGB, const double overlayAlpha, const double textScale, void * resultImage)
SaigeOverlayTextObjects.
int SaigeOverlayHeatmap (const void * baseImage, const float * heatmap, const int width, const int height, const int channels, const int type, const bool isRGB, const double overlayAlpha, void * resultImage)
SaigeOverlayHeatmaps.
int SaigeShowImage (const void * image, const int width, const int height, const int channels, const int type, const bool isRGB, const bool invert, const double alpha, const int waitMS)
SaigeShowImage.

Public Functions Documentation

SaigeInitTextFormatting

SaigeInitTextFormatting.

void SaigeInitTextFormatting (
    SaigeTextFormatting * formatting
) 

Initializes the boolean array indicating the inclusion of character sets in the given SaigeTextFormatting to false for all values. This prepares the formatting settings for use in text recognition tasks.

Parameters:

  • formatting Pointer to the variable to be set.

SaigeConvertImageType

SaigeConvertImageType.

unsigned int SaigeConvertImageType (
    const int channel,
    const int type
) 

Converts the number of channels and SaigeImageType into the image flag macro used in SaigeInferFromByteArray. This function is useful for preparing image data for inference.

Parameters:

  • channel The number of channels in the image.
  • type The data type of the image. Refer to SaigeDrawImage for setting options.

Returns:

imageFlag Returns the converted image flag macro.

SaigeOverlaySegmentedObjects

SaigeOverlaySegmentedObjects.

int SaigeOverlaySegmentedObjects (
    const void * baseImage,
    const SaigeSegmentedObject * objects,
    SaigeModelInfo * modelInfo,
    const int numOfSegmentedObjects,
    const int width,
    const int height,
    const int channels,
    const int type,
    const bool isRGB,
    const double overlayAlpha,
    void * resultImage
) 

Draws segmented objects on a base image and stores the result in an output image. This function allows for the visualization of segmentation results overlaid on an original image.

Parameters:

  • baseImage The base image data on which segmented objects will be drawn.
  • objects The array of segmented objects detected from inference.
  • modelInfo The model information, used for class colors; if null, the color red will be used.
  • numOfSegmentedObjects The number of segmented objects.
  • width The width of the base and result images.
  • height The height of the base and result images.
  • channels The number of channels in the base and result images.
  • type The type of the image. Refer to SaigeImageType for details.
  • overlayAlpha The transparency value for visualizing segmented objects; the range is 0 to 1, where values closer to 1 make the segmented objects more transparent.
  • resultImage [out] The image data that stores the result with segmented objects drawn on it.

Returns:

errorCode Returns 0 on success, or an error code if there is a failure.

See also: SaigeGetInferenceResultNumOfSegmentedObjects, SaigeGetInferenceResultSegmentedObjects

SaigeOverlayDetectedObjects

SaigeOverlayDetectedObjects.

int SaigeOverlayDetectedObjects (
    const void * baseImage,
    const SaigeDetectedObject * objects,
    SaigeModelInfo * modelInfo,
    const int numOfDetectedObjects,
    const int width,
    const int height,
    const int channels,
    const int type,
    const bool withClassName,
    const bool isRGB,
    const double overlayAlpha,
    void * resultImage
) 

Draws the bounding boxes of detected objects on a base image and stores the result in an output image. This function allows for the visualization of detection results overlaid on an original image.

Parameters:

  • baseImage The base image data on which detected objects will be drawn.
  • objects The array of detected objects from inference.
  • modelInfo The model information, used for class names and colors; if null, the color red will be used.
  • numOfDetectedObjects The number of detected objects.
  • width The width of the base and result images.
  • height The height of the base and result images.
  • channels The number of channels in the base and result images.
  • type The type of the image. Refer to SaigeImageType for details.
  • withClassName If set to true, the class name of each detected object will also be displayed.
  • isRGB If set to true, indicates that the image data is in RGB order.
  • overlayAlpha The transparency value for visualizing detected objects; the range is 0 to 1, where values closer to 1 make the detected objects more transparent.
  • resultImage [out] The image data that stores the result with detected objects drawn on it.

Returns:

errorCode Returns 0 on success, or an error code if there is a failure.

See also: SaigeGetInferenceResultNumOfDetectedObjects, SaigeGetInferenceResultDetectedObjects

SaigeOverlayTextObjects

SaigeOverlayTextObjects.

int SaigeOverlayTextObjects (
    const void * baseImage,
    const SaigeTextObject * objects,
    const int numOfTextObjects,
    const int width,
    const int height,
    const int channels,
    const int type,
    const bool isRGB,
    const double overlayAlpha,
    const double textScale,
    void * resultImage
) 

Draws the OCR results, represented by SaigeTextObject, on a base image and stores the result in an output image. Currently, Korean text appears as '?', support for it is planned for future updates.

Parameters:

  • baseImage The base image data on which SaigeTextObject will be drawn.
  • objects The array of SaigeTextObject detected from inference.
  • numOfSaigeTextObject The number of SaigeTextObject.
  • width The width of the base and result images.
  • height The height of the base and result images.
  • channels The number of channels in the base and result images.
  • type The type of the image. Refer to SaigeImageType for details.
  • isRGB If set to true, indicates that the image data is in RGB order.
  • overlayAlpha The transparency value for visualizing SaigeTextObject; the range is 0 to 1, where values closer to 1 make the SaigeTextObject more transparent.
  • resultImage [out] The image data that stores the result with SaigeTextObject drawn on it.

Returns:

errorCode Returns 0 on success, or an error code if there is a failure.

See also: SaigeGetInferenceResultNumOfSaigeTextObject, SaigeGetInferenceResultSaigeTextObject

SaigeOverlayHeatmap

SaigeOverlayHeatmaps.

int SaigeOverlayHeatmap (
    const void * baseImage,
    const float * heatmap,
    const int width,
    const int height,
    const int channels,
    const int type,
    const bool isRGB,
    const double overlayAlpha,
    void * resultImage
) 

Draws a colorized heatmap on a base image and stores the result in an output image. This function helps visualize the heatmap data in relation to the original image.

Parameters:

  • baseImage The base image data on which the heatmap will be drawn.
  • heatmap The array of heatmap data obtained from the inspection results.
  • width The width of the base and result images.
  • height The height of the base and result images.
  • channels The number of channels in the base and result images.
  • type The type of the image. Refer to SaigeImageType for details.
  • isRGB If set to true, indicates that the image data is in RGB order.
  • overlayAlpha The transparency value for visualizing the heatmap; the range is 0 to 1, where values closer to 1 make the heatmap more transparent.
  • resultImage [out] The image data that stores the result with the heatmap drawn on it.

Returns:

errorCode Returns 0 on success, or an error code if there is a failure.

See also: SaigeGetInferenceResultHeatmap

SaigeShowImage

SaigeShowImage.

int SaigeShowImage (
    const void * image,
    const int width,
    const int height,
    const int channels,
    const int type,
    const bool isRGB,
    const bool invert,
    const double alpha,
    const int waitMS
) 

Displays an image in a separate window. This function is useful for visualizing images during development or debugging processes.

Parameters:

  • image The image data to be displayed.
  • width The width of the image.
  • height The height of the image.
  • channels The number of channels in the image.
  • type The data type of the image. Refer to SaigeImageType for setting options.
  • isRGB If set to true, indicates that the image data is in RGB order.
  • invert If set to true, the colors will be inverted during display.
  • alpha The value multiplied with the pixel values of the image data; this helps adjust the brightness of the displayed image.
  • waitMS The display duration in milliseconds; if set to 0, the display window must be closed manually.

Returns:

errorCode Returns 0 on success, or an error code if there is a failure.