Skip to content

Inference

Inference.

Public Functions

Type Name
int SaigeInferFromImageFile (SaigeInferenceHandle handle, const char * imagePath, SaigeInferenceResult result)
Performs inference using the specified image file path.
int SaigeInferFromByteArray (SaigeInferenceHandle handle, const unsigned char * imageData, const int width, const int height, const unsigned int flags, SaigeInferenceResult result)
Performs inference on a single image data array. For 3-channel color images, RGB ordering is preferred for speed in real-time applications. If images are acquired in RGB, it is recommended to use RGB.
int SaigeInferFromByteArrayWithProductId (SaigeInferenceHandle handle, const unsigned char * imageData, const int width, const int height, const unsigned int flags, const char * productId, SaigeInferenceResult result)
Performs inference on a single image data array with an additional product identifier. This is similar to SaigeInferFromByteArray, with the addition of a product ID, which is a user-defined identifier for the inspection target.
int SaigeInferFromMultipleByteArray (SaigeInferenceHandle handle, const int numOfImages, const unsigned char ** imageData, const int width, const int height, const unsigned int flags, SaigeInferenceResult * results)
Performs batch inference on multiple images of the same size.

Macros

Type Name
define SAIGE_IMAGE_COLOR 0x01
Flag indicating color image data.
define SAIGE_IMAGE_16BIT 0x02
Flag indicating 16-bit per channel image data.
define SAIGE_IMAGE_ALPHA 0x04
Flag indicating data with an alpha channel.
define SAIGE_IMAGE_BGR 0x08
Flag indicating the color channel order is Blue, Green, Red.
define SAIGE_IMAGE_8BIT_GRAY 0x00
Macro indicating 8-bit grayscale image data. It is a single-channel array with a size of Width x Height.
define SAIGE_IMAGE_24BIT_RGB (SAIGE_IMAGE_COLOR)
Macro indicating 24-bit RGB color image data. It is an array of size Width x Height x Channels (3) with channels ordered as R, G, B.
define SAIGE_IMAGE_24BIT_BGR (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_BGR)
Macro indicating 24-bit BGR color image data. It is an array of size Width x Height x Channels (3) with channels ordered as B, G, R.
define SAIGE_IMAGE_32BIT_RGBA (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_ALPHA)
Macro indicating 32-bit RGBA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as R, G, B, A.
define SAIGE_IMAGE_32BIT_BGRA (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_ALPHA | SAIGE_IMAGE_BGR)
Macro indicating 32-bit BGRA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as B, G, R, A.
define SAIGE_IMAGE_16BIT_GRAY (SAIGE_IMAGE_16BIT)
Macro indicating 16-bit grayscale image data. It is a single-channel array of size Width x Height, with each pixel represented as an unsigned short.
define SAIGE_IMAGE_48BIT_RGB (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT)
Macro indicating 48-bit RGB color image data. It is an array of size Width x Height x Channels (3) with channels ordered as R, G, B, and each pixel represented as an unsigned short.
define SAIGE_IMAGE_48BIT_BGR (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT | SAIGE_IMAGE_BGR)
Macro indicating 48-bit BGR color image data. It is an array of size Width x Height x Channels (3) with channels ordered as B, G, R, and each pixel represented as an unsigned short.
define SAIGE_IMAGE_64BIT_RGBA (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT | SAIGE_IMAGE_ALPHA)
Macro indicating 64-bit RGBA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as R, G, B, A, and each pixel represented as an unsigned short.
define SAIGE_IMAGE_64BIT_BGRA (SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT | SAIGE_IMAGE_ALPHA | SAIGE_IMAGE_BGR)
Macro indicating 64-bit BGRA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as B, G, R, A, and each pixel represented as an unsigned short.

Public Functions Documentation

SaigeInferFromImageFile

Performs inference using the specified image file path.

int SaigeInferFromImageFile (
    SaigeInferenceHandle handle,
    const char * imagePath,
    SaigeInferenceResult result
) 

Parameters:

  • handle The inference handle to use for inference.
  • imagePath Path to the image file for inference. Supported extensions are jpg, jpeg, png, ppm, bmp, pgm, tif, tiff, and webp.
  • result The result handle to store the inference results.

Returns:

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

SaigeInferFromByteArray

Performs inference on a single image data array. For 3-channel color images, RGB ordering is preferred for speed in real-time applications. If images are acquired in RGB, it is recommended to use RGB.

int SaigeInferFromByteArray (
    SaigeInferenceHandle handle,
    const unsigned char * imageData,
    const int width,
    const int height,
    const unsigned int flags,
    SaigeInferenceResult result
) 

Parameters:

  • handle The inference handle to use.
  • imageData The image data to be used for inference.
  • width Width of the image data.
  • height Height of the image data.
  • flags Flags to set the color and bit depth of the image.
  • result The result handle to store inference results.

Returns:

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

See also: SAIGE_IMAGE_8BIT_GRAY, SAIGE_IMAGE_24BIT_RGB

SaigeInferFromByteArrayWithProductId

Performs inference on a single image data array with an additional product identifier. This is similar to SaigeInferFromByteArray, with the addition of a product ID, which is a user-defined identifier for the inspection target.

int SaigeInferFromByteArrayWithProductId (
    SaigeInferenceHandle handle,
    const unsigned char * imageData,
    const int width,
    const int height,
    const unsigned int flags,
    const char * productId,
    SaigeInferenceResult result
) 

Parameters:

  • handle The inference handle to use.
  • imageData The image data to be used for inference.
  • width Width of the image data.
  • height Height of the image data.
  • flags Flags to set the color and bit depth of the image.
  • productId The product ID for the item to be inferred.
  • result The result handle to store inference results.

Returns:

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

See also: SAIGE_IMAGE_8BIT_GRAY, SAIGE_IMAGE_24BIT_RGB

SaigeInferFromMultipleByteArray

Performs batch inference on multiple images of the same size.

int SaigeInferFromMultipleByteArray (
    SaigeInferenceHandle handle,
    const int numOfImages,
    const unsigned char ** imageData,
    const int width,
    const int height,
    const unsigned int flags,
    SaigeInferenceResult * results
) 

Parameters:

  • handle The inference handle to use.
  • numOfImages Number of images in the data.
  • imageData Array of image data for inference.
  • width Width of the image data.
  • height Height of the image data.
  • flags Flags to set the color and bit depth of the image.
  • results Array of result handles to store inference results.

Returns:

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

See also: SAIGE_IMAGE_24BIT_RGB, SaigeHandleConfig::batchSize

Macro Definition Documentation

SAIGE_IMAGE_COLOR

Flag indicating color image data.

#define SAIGE_IMAGE_COLOR 0x01

SAIGE_IMAGE_16BIT

Flag indicating 16-bit per channel image data.

#define SAIGE_IMAGE_16BIT 0x02

SAIGE_IMAGE_ALPHA

Flag indicating data with an alpha channel.

#define SAIGE_IMAGE_ALPHA 0x04

SAIGE_IMAGE_BGR

Flag indicating the color channel order is Blue, Green, Red.

#define SAIGE_IMAGE_BGR 0x08

SAIGE_IMAGE_8BIT_GRAY

Macro indicating 8-bit grayscale image data. It is a single-channel array with a size of Width x Height.

#define SAIGE_IMAGE_8BIT_GRAY 0x00

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_24BIT_RGB

Macro indicating 24-bit RGB color image data. It is an array of size Width x Height x Channels (3) with channels ordered as R, G, B.

#define SAIGE_IMAGE_24BIT_RGB ( SAIGE_IMAGE_COLOR )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_24BIT_BGR

Macro indicating 24-bit BGR color image data. It is an array of size Width x Height x Channels (3) with channels ordered as B, G, R.

#define SAIGE_IMAGE_24BIT_BGR ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_BGR )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_32BIT_RGBA

Macro indicating 32-bit RGBA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as R, G, B, A.

#define SAIGE_IMAGE_32BIT_RGBA ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_ALPHA )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_32BIT_BGRA

Macro indicating 32-bit BGRA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as B, G, R, A.

#define SAIGE_IMAGE_32BIT_BGRA ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_ALPHA | SAIGE_IMAGE_BGR )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_16BIT_GRAY

Macro indicating 16-bit grayscale image data. It is a single-channel array of size Width x Height, with each pixel represented as an unsigned short.

#define SAIGE_IMAGE_16BIT_GRAY ( SAIGE_IMAGE_16BIT )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_48BIT_RGB

Macro indicating 48-bit RGB color image data. It is an array of size Width x Height x Channels (3) with channels ordered as R, G, B, and each pixel represented as an unsigned short.

#define SAIGE_IMAGE_48BIT_RGB ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_48BIT_BGR

Macro indicating 48-bit BGR color image data. It is an array of size Width x Height x Channels (3) with channels ordered as B, G, R, and each pixel represented as an unsigned short.

#define SAIGE_IMAGE_48BIT_BGR ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT | SAIGE_IMAGE_BGR )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_64BIT_RGBA

Macro indicating 64-bit RGBA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as R, G, B, A, and each pixel represented as an unsigned short.

#define SAIGE_IMAGE_64BIT_RGBA ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT | SAIGE_IMAGE_ALPHA )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray

SAIGE_IMAGE_64BIT_BGRA

Macro indicating 64-bit BGRA color image data. It is an array of size Width x Height x Channels (4) with channels ordered as B, G, R, A, and each pixel represented as an unsigned short.

#define SAIGE_IMAGE_64BIT_BGRA ( SAIGE_IMAGE_COLOR | SAIGE_IMAGE_16BIT | SAIGE_IMAGE_ALPHA | SAIGE_IMAGE_BGR )

See also: SaigeInferFromByteArray, SaigeInferFromMultipleByteArray