Skip to content

Inference Result

Inference result!

Classes

Type Name
struct SaigeRotatedBox
Structure containing information about a rotatable rectangle.
struct SaigeDetectedObject
Structure containing information about a detected area from Object Detection (DET).
struct SaigeEllipse
Structure containing information about an ellipse.
struct SaigeSegmentedObject
Structure containing information about a detected area from Segmentation (SEG) or Anomaly Detection (IAD).
struct SaigeTextObject
SaigeTextObject.

Public Functions

Type Name
int SaigeGetInferenceResultScore (SaigeInferenceResult result, float * scores, bool includeAddScore)
(CLS) Retrieves an array of scores per class.
int SaigeGetInferenceResultClass (SaigeInferenceResult result, int * classIndex)
(CLS) Retrieves the index of the class with the highest final score, including additional score.
int SaigeGetInferenceResultClassActivationMap (SaigeInferenceResult result, unsigned char ** classActivationMap)
(CLS) Retrieves the class activation map array.
int SaigeGetInferenceResultNumOfDetectedObjects (SaigeInferenceResult result, int * numOfObjects)
(DET) Retrieves the number of detected objects from Object Detection.
int SaigeGetInferenceResultDetectedObjects (SaigeInferenceResult result, SaigeDetectedObject * detectedObjects)
(DET) Retrieves an array of detected objects from Object Detection.
int SaigeGetInferenceResultNumOfSegmentedObjects (SaigeInferenceResult result, int * num)
Retrieves the number of segmented objects detected by Segmentation (SEG) or Anomaly Detection (IAD).
int SaigeGetInferenceResultSegmentedObjects (SaigeInferenceResult result, SaigeSegmentedObject * segObjects)
Retrieves an array of segmented objects detected by Segmentation (SEG) or Anomaly Detection (IAD).
int SaigeGetInferenceResultMask (SaigeInferenceResult result, unsigned char ** mask)
Retrieves a Mask array from Segmentation (SEG) or Anomaly Detection (IAD).
int SaigeGetInferenceResultScoremapSEG (SaigeInferenceResult result, unsigned char ** scoremap)
Retrieves the Scoremap array for Segmentation (SEG).
int SaigeGetInferenceResultIsOversized (SaigeInferenceResult result, bool * isOversized)
Checks if the input image size exceeded the inspection size set in SaigeHandleConfig.
int SaigeGetInferenceResultAnomalyScores (SaigeInferenceResult result, double * anomalyScore, double * minScore, double * maxScore)
Retrieves three types of scores for Anomaly Detection (IAD).
int SaigeGetInferenceResultIsNg (SaigeInferenceResult result, bool * isNg)
Retrieves the normal/abnormal classification result for the image in Anomaly Detection (IAD).
int SaigeGetInferenceResultScoremapIAD (SaigeInferenceResult result, float ** scoremap)
Retrieves the Scoremap array for Anomaly Detection (IAD).
int SaigeGetInferenceResultHeatmap (SaigeInferenceResult result, float ** heatmap)
SaigeGetInferenceResultHeatmap.
int SaigeGetInferenceResultNumOfTextObjects (SaigeInferenceResult result, int * num)
SaigeGetInferenceResultNumOfTextObjects.
int SaigeGetInferenceResultEnhancedImage (SaigeInferenceResult result, unsigned char ** image)
SaigeGetInferenceResultEnhancedImage.
int SaigeGetInferenceResultTextObjects (SaigeInferenceResult result, SaigeTextObject * textObjects)
SaigeGetInferenceResultTextObjects.
int SaigeGetInferenceResultInspectionTime (SaigeInferenceResult result, long long * imreadTime, long long * inferenceTime, long long * postProcessingTime)
SaigeGetInferenceResultInspectionTime.
int SaigeGetInferenceResultProductId (SaigeInferenceResult result, const char ** productId, unsigned int * length)
SaigeGetInferenceResultProductId.

Public Functions Documentation

SaigeGetInferenceResultScore

(CLS) Retrieves an array of scores per class.

int SaigeGetInferenceResultScore (
    SaigeInferenceResult result,
    float * scores,
    bool includeAddScore
) 

Parameters:

  • result The result handle containing inference results.
  • scores [out] Array containing scores for each class.
  • includeAddScore If set to true, retrieves scores including additional scores. if false, retrieves original scores only.

Returns:

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

SaigeGetInferenceResultClass

(CLS) Retrieves the index of the class with the highest final score, including additional score.

int SaigeGetInferenceResultClass (
    SaigeInferenceResult result,
    int * classIndex
) 

Parameters:

  • result The result handle containing inference results.
  • classIndex [out] Index of the class with the highest score.

Returns:

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

SaigeGetInferenceResultClassActivationMap

(CLS) Retrieves the class activation map array.

int SaigeGetInferenceResultClassActivationMap (
    SaigeInferenceResult result,
    unsigned char ** classActivationMap
) 

  • The class activation map is a heatmap that shows which image areas contributed most to a specific classification.
  • Pixel values range from 0 to 255, with higher values indicating a greater contribution to the classification result.
  • Shape is (original image height H, original image width W).
  • Internally, this is represented as a 1D array using row-major order. The value at row i, column j is located at data[W*i + j].

Parameters:

  • result The result handle containing inference results.
  • classActivationMap [out] Array containing the class activation map.

Returns:

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

SaigeGetInferenceResultNumOfDetectedObjects

(DET) Retrieves the number of detected objects from Object Detection.

int SaigeGetInferenceResultNumOfDetectedObjects (
    SaigeInferenceResult result,
    int * numOfObjects
) 

Parameters:

  • result The result handle containing inference results.
  • numOfObjects [out] The number of detected objects.

Returns:

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

SaigeGetInferenceResultDetectedObjects

(DET) Retrieves an array of detected objects from Object Detection.

int SaigeGetInferenceResultDetectedObjects (
    SaigeInferenceResult result,
    SaigeDetectedObject * detectedObjects
) 

Parameters:

  • result The result handle containing inference results.
  • detectedObjects [out] Array of detected objects.

Returns:

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

SaigeGetInferenceResultNumOfSegmentedObjects

Retrieves the number of segmented objects detected by Segmentation (SEG) or Anomaly Detection (IAD).

int SaigeGetInferenceResultNumOfSegmentedObjects (
    SaigeInferenceResult result,
    int * num
) 

Parameters:

  • result The result handle containing inference results.
  • num [out] The number of detected segmented objects.

Returns:

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

SaigeGetInferenceResultSegmentedObjects

Retrieves an array of segmented objects detected by Segmentation (SEG) or Anomaly Detection (IAD).

int SaigeGetInferenceResultSegmentedObjects (
    SaigeInferenceResult result,
    SaigeSegmentedObject * segObjects
) 

Parameters:

  • result The result handle containing inference results.
  • segObjects [out] Array of detected segmented objects.

Returns:

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

SaigeGetInferenceResultMask

Retrieves a Mask array from Segmentation (SEG) or Anomaly Detection (IAD).

int SaigeGetInferenceResultMask (
    SaigeInferenceResult result,
    unsigned char ** mask
) 

  • (IAD) Pixels classified as normal are 0, while those classified as abnormal are 1.
  • (SEG) Pixels classified as OK class are 0, while those classified under other classes are represented by their class index.
  • The array shape is (image height H, image width W).
  • This is a single pointer 1D array with row-major order. For row i and column j, the value is data[W*i + j].

Parameters:

  • result The result handle containing inference results.
  • mask [out] The Mask array.

Returns:

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

SaigeGetInferenceResultScoremapSEG

Retrieves the Scoremap array for Segmentation (SEG).

int SaigeGetInferenceResultScoremapSEG (
    SaigeInferenceResult result,
    unsigned char ** scoremap
) 

  • Scoremap for SEG, which differs from that of IAD.
  • Shape is (number of classes including OK, image height H, image width W).
  • If pixel (i, j) is predicted as class c, then (c, i, j) contains the score as an integer in the range 0–255.
  • This is a single pointer 1D array with row-major order, where the value for class c, row i, column j is data[W*H*c + W*i + j].

Parameters:

  • result The result handle containing inference results.
  • scoremap [out] The Scoremap array.

Returns:

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

SaigeGetInferenceResultIsOversized

Checks if the input image size exceeded the inspection size set in SaigeHandleConfig.

int SaigeGetInferenceResultIsOversized (
    SaigeInferenceResult result,
    bool * isOversized
) 

Parameters:

  • result The result handle containing inference results.
  • isOversized [out] true if the input image size exceeded the inspection size, otherwise false.

Returns:

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

SaigeGetInferenceResultAnomalyScores

Retrieves three types of scores for Anomaly Detection (IAD).

int SaigeGetInferenceResultAnomalyScores (
    SaigeInferenceResult result,
    double * anomalyScore,
    double * minScore,
    double * maxScore
) 

Parameters:

  • result The result handle containing inference results.
  • anomalyScore [out] The representative anomaly score of the image.
  • minScore [out] The minimum pixel-level score in the image.
  • maxScore [out] The maximum pixel-level score in the image.

Returns:

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

SaigeGetInferenceResultIsNg

Retrieves the normal/abnormal classification result for the image in Anomaly Detection (IAD).

int SaigeGetInferenceResultIsNg (
    SaigeInferenceResult result,
    bool * isNg
) 

Parameters:

  • result The result handle containing inference results.
  • isNg [out] true if the image is classified as abnormal, false if normal.

Returns:

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

SaigeGetInferenceResultScoremapIAD

Retrieves the Scoremap array for Anomaly Detection (IAD).

int SaigeGetInferenceResultScoremapIAD (
    SaigeInferenceResult result,
    float ** scoremap
) 

  • Scoremap specific to IAD, different from SEG’s scoremap.
  • Each pixel's score is represented as a non-negative floating-point number.
  • The array shape is (image height H, image width W).
  • This is a single pointer 1D array with row-major order, where the value for row i and column j is data[W*i + j].

Parameters:

  • result The result handle containing inference results.
  • scoremap [out] The Scoremap array.

Returns:

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

SaigeGetInferenceResultHeatmap

SaigeGetInferenceResultHeatmap.

int SaigeGetInferenceResultHeatmap (
    SaigeInferenceResult result,
    float ** heatmap
) 

  • Returns a Heatmap array that is normalized between heatmapColorRangeMin and heatmapColorRangeMax. Each pixel value is represented as a floating-point number within the range 0 to 1.
  • The shape is (image height H, image width W).
  • Implemented as a single pointer 1D array in row-major order. Thus, the value at row i and column j is data[W*i + j].

Parameters:

  • result The result handle containing inference results.
  • heatmap [out] The Heatmap array.

Returns:

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

SaigeGetInferenceResultNumOfTextObjects

SaigeGetInferenceResultNumOfTextObjects.

int SaigeGetInferenceResultNumOfTextObjects (
    SaigeInferenceResult result,
    int * num
) 

Retrieves the number of detected text areas in the image analyzed by OCR.

Parameters:

  • result The handle containing inference results.
  • num [out] The number of detected text areas.

Returns:

errorCode Returns 0 on successful execution, or an error code if an error occurs.

SaigeGetInferenceResultEnhancedImage

SaigeGetInferenceResultEnhancedImage.

int SaigeGetInferenceResultEnhancedImage (
    SaigeInferenceResult result,
    unsigned char ** image
) 

Retrieves the enhanced quality image for Image Enhancement (IEN) results.

Parameters:

  • result The handle containing inference results.
  • image [out] The pointer to store the enhanced image data.

Returns:

errorCode Returns 0 on successful execution, or an error code if an error occurs.

SaigeGetInferenceResultTextObjects

SaigeGetInferenceResultTextObjects.

int SaigeGetInferenceResultTextObjects (
    SaigeInferenceResult result,
    SaigeTextObject * textObjects
) 

Retrieves an array of detected text areas (SaigeTextObject) from OCR inference results.

Parameters:

Returns:

errorCode Returns 0 on successful execution, or an error code if an error occurs.

SaigeGetInferenceResultInspectionTime

SaigeGetInferenceResultInspectionTime.

int SaigeGetInferenceResultInspectionTime (
    SaigeInferenceResult result,
    long long * imreadTime,
    long long * inferenceTime,
    long long * postProcessingTime
) 

Retrieves the time spent on various stages of the inference API execution, measured in milliseconds.

Parameters:

  • result The handle containing inference results.
  • imreadTime [out] Time spent reading the image.
  • inferenceTime [out] Time spent on image preprocessing and deep learning inference.
  • postProcessingTime [out] Time spent on post-processing.

Returns:

errorCode Returns 0 on successful execution, or an error code if an error occurs.

See also: SaigeInferenceOption::calcTime

SaigeGetInferenceResultProductId

SaigeGetInferenceResultProductId.

int SaigeGetInferenceResultProductId (
    SaigeInferenceResult result,
    const char ** productId,
    unsigned int * length
) 

Retrieves the Product ID used or generated during inference execution.

Parameters:

  • result The handle containing inference results.
  • productId [out] Pointer to the Product ID string.
  • length [out] Length of the Product ID string.

Returns:

errorCode Returns 0 on successful execution, or an error code if an error occurs.

See also: SaigeInferFromByteArrayWithProductId