SaigeVision C/C++  1.4.7
SaigeVision API document for C/C++
SegmentationTestDLL.h File Reference

Header file for segmentation module. More...

#include "CommonHeaderDLL.h"

Go to the source code of this file.

Typedefs

typedef void * SegTestHandle
 Segmentation file handler. More...
 
typedef void * SegTestResult
 Segmentation inspection results handler. More...
 

Enumerations

enum  eSegTestOutputType { SR_ONE_CLASS_MATRIX_OUTPUT = 0, SR_MULTI_CLASS_MATRIX_OUTPUT = 1, SR_ONE_CLASS_CV_CONTOUR_OUTPUT = 2, SR_MULTI_CLASS_CV_CONTOUR_OUTPUT = 3 }
 Segmentation output type. More...
 

Functions

SegTestHandle SR_CreateSegTestHandle (const char *filePath)
 Create a SegTestHandle via multi byte char path. More...
 
SegTestHandle SR_CreateSegTestHandleByWideCharPath (const wchar_t *filePath)
 Create a SegTestHandle via wide char path. More...
 
SegTestResult SR_MakeSegTestResult ()
 Construct a SegTestResult. More...
 
eErrorType SR_LoadSegTestNetworkInGPU (SegTestHandle handle, int GPUNumber, int batchSize=1)
 Allocate required cpu & gpu memory. More...
 
eErrorType SR_GetSegTestAlgorithmType (SegTestHandle handle, eAlgorithmType *algoType)
 Get a algorithm type(ex, standard, deep) of a segmentation model.
 
eErrorType SR_PrintSegTestParametersWithoutBG (SegTestHandle handle)
 Print a model parameters (Segmentation's class information, inspection options...)
 
eErrorType SR_GetSegTestNumberOfClassesWithoutBG (SegTestHandle handle, int *numberOfClasses)
 Get the number of classes. More...
 
eErrorType SR_GetSegTestMaxStrLenOfClassName (SegTestHandle handle, int *len)
 Get a maximum length of class name. More...
 
eErrorType SR_GetSegTestOneClassNameWithWideCharByIdxWithoutBG (SegTestHandle handle, const int classIdx, wchar_t *className)
 Get a wide char name of certain class by given index. More...
 
eErrorType SR_GetSegTestOneClassNameWithMultiByteCharByIdxWithoutBG (SegTestHandle handle, const int classIdx, char *className)
 Get a multi byte char name of certain class by given index. More...
 
eErrorType SR_GetSegTestOneClassColorByIdxWithoutBG (SegTestHandle handle, const int classIdx, int *classColor)
 Get a color of certain class by given index. More...
 
eErrorType SR_GetSegTestMinScoreThresholdWithoutBG (SegTestHandle handle, int *scoreThreshold)
 Get Segmentation's score threshold for each class. More...
 
eErrorType SR_SetSegTestMinScoreThresholdWithoutBG (SegTestHandle handle, int numOfClasses, int *scoreThreshold, bool writeOnModelFile=true)
 Set Segmentation's score threshold for each class. More...
 
eErrorType SR_GetSegTestMinPixelSizeThresholdWithoutBG (SegTestHandle handle, int *areaThreshold)
 Get Segmentation's area threshold for each class. More...
 
eErrorType SR_SetSegTestMinPixelSizeThresholdWithoutBG (SegTestHandle handle, int numOfClasses, int *areaThreshold, bool writeOnModelFile=true)
 Set Segmentation's area threshold for each class. More...
 
eErrorType SR_GetSegTestModeOfFilteringByPixelSize (SegTestHandle handle, eModeOfPixelSizeFilter *modeOfFiltering)
 Get the mode of filtering by Segmentation's area threshold. More...
 
eErrorType SR_SetSegTestModeOfFilteringByPixelSize (SegTestHandle handle, eModeOfPixelSizeFilter modeOfFiltering, bool writeOnModelFile=true)
 Set the mode of filtering by Segmentation's area threshold. More...
 
eErrorType SR_SetSegTestMaxGPUMemorySizeInByte (SegTestHandle handle, unsigned long long maxGPUMemorySizeInByte)
 Set the maximum size of gpu memory to use for inspections in byte. More...
 
eErrorType SR_SetSegTestMaxInspectionSize (SegTestHandle handle, int maxInspectionHeight, int maxInspectionWidth, bool writeOnModelFile=true)
 Set Segmentation's max inspection size. More...
 
eErrorType SR_GetSegTestMaxInspectionSize (SegTestHandle handle, int *maxInspectionHeight, int *maxInspectionWidth)
 Get Segmentation's max inspection size. More...
 
eErrorType SR_GetSegTestForwardTimeLimit (SegTestHandle handle, float *forwardTimeLimit)
 Get the Forward time limit. More...
 
eErrorType SR_GetSegTestIsToUseForwardTimeLimit (SegTestHandle handle, bool *bIsToUseForwardTimeLimit)
 Get the boolean whether the current model is using time limit or not. More...
 
eErrorType SR_GetSegTestForwardTimeLimitVariables (SegTestHandle handle, float *forwardTimeLimit, bool *bIsToUseForwardTimeLimit)
 Get the Forward time limit variables. More...
 
eErrorType SR_SetSegTestForwardTimeLimit (SegTestHandle handle, float forwardTimeLimit, bool writeOnModelFile=true)
 Set the Forward time limit. More...
 
eErrorType SR_SetSegTestIsToUseForwardTimeLimit (SegTestHandle handle, bool bIsToUseForwardTimeLimit, bool writeOnModelFile=true)
 Set the boolean whether the current model is using time limit or not. More...
 
eErrorType SR_SetSegTestForwardTimeLimitVariables (SegTestHandle handle, float forwardTimeLimit, bool bIsToUseForwardTimeLimit, bool writeOnModelFile=true)
 Set the Forward time limit variables. More...
 
eErrorType SR_GetSegTestCropParamsUsedForExportingResults (SegTestHandle handle, int *cropHeight, int *cropWidth, eModeOfCropLargeObjects *mode, float *margin)
 Get cropping parameters (crop height & width, mode, margin) used for exporting segmented objects. More...
 
eErrorType SR_SetSegTestIsToStoreCroppedImage (SegTestHandle handle, bool isToStoreCroppedImage, int defaultCropSize, eModeOfCropLargeObjects modeOfCropLargeObjects=SR_CROP_BY_OBJECTSIZE_N_RESIZE_TO_CROPSIZE, float margin=0.05, bool writeOnModelFile=true)
 Set the parameters of Segmentation's crop object. More...
 
eErrorType SR_GetSegTestIsToStoreCroppedImage (SegTestHandle handle, bool *isToStoreCroppedImage, int *defaultCropSize, eModeOfCropLargeObjects *modeOfCropLargeObjects, float *margin)
 Get the parameters of Segmentation's crop object. More...
 
eErrorType SR_SetSegTestIsToCalcObjectScores (SegTestHandle handle, bool isToCalcObjectScores, bool writeOnModelFile=true)
 Set the boolean indicating whether calculate SR_SegmentedObject::scores or not. More...
 
eErrorType SR_GetSegTestIsToCalcObjectScores (SegTestHandle handle, bool *isToCalcObjectScores)
 Get the boolean indicating whether calculate SR_SegmentedObject::scores or not. More...
 
eErrorType SR_SetSegTestIsToCalcAverageColor (SegTestHandle handle, bool isToCalcAverageColors, bool writeOnModelFile=true)
 Set the boolean indicating whether calculate SR_SegmentedObject::averageColor or not. More...
 
eErrorType SR_GetSegTestIsToCalcAverageColor (SegTestHandle handle, bool *isToCalcAverageColors)
 Get the boolean indicating whether calculate SR_SegmentedObject::averageColor or not. More...
 
eErrorType SR_GetSegTestNumberOfPages (SegTestHandle handle, int *numberOfPages)
 Get the number of pages. More...
 
eErrorType SR_GetSegTestMaxStrLenOfPageName (SegTestHandle handle, int *len)
 Get a maximum length of page name. More...
 
eErrorType SR_GetSegTestOnePageNameWithWideChar (SegTestHandle handle, const int pageIdx, wchar_t *pageName)
 Get a wide char name of certain page by given index. More...
 
eErrorType SR_GetSegTestOnePageNameWithMultiByteChar (SegTestHandle handle, const int pageIdx, char *pageName)
 Get a multi byte char name of certain page by given index. More...
 
eErrorType SR_ApplySegTestFromImageFile (SegTestHandle handle, const char *imagePath, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to image by file path. More...
 
eErrorType SR_ApplySegTestFromImageFileByWideCharPath (SegTestHandle handle, const wchar_t *imagePath, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to image by file path. More...
 
eErrorType SR_ApplySegTestFrom8bitCharGrayArray (SegTestHandle handle, const unsigned char *imageData, const int height, const int width, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to 1-channel image by 8-bit data. More...
 
eErrorType SR_ApplySegTestFrom8bitCharColorArray (SegTestHandle handle, const unsigned char *imageData, const int height, const int width, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to 3-channels(BGR) image by 8-bit data. More...
 
eErrorType SR_ApplySegTestFromUnsignedIntColorArray (SegTestHandle handle, const unsigned int *imageData, const int height, const int width, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to 4-channels(BGRA) image by 8-bit data. More...
 
eErrorType SR_ApplySegTestFrom16bitCharGrayArray (SegTestHandle handle, const unsigned char *imageData, const int height, const int width, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to 1-channel image by 16-bit data. More...
 
eErrorType SR_ApplySegTestFrom16bitCharColorArray (SegTestHandle handle, const unsigned char *imageData, const int height, const int width, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to 3-channels(BGR) image by 16-bit data. More...
 
eErrorType SR_ApplySegTestFrom16bitUnsignedIntColorArray (SegTestHandle handle, const unsigned int *imageData, const int height, const int width, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to 4-channels(BGRA) image by 16-bit data. More...
 
eErrorType SR_ApplySegTestFromMultiple8bitCharGrayArrays (SegTestHandle handle, int numberOfImages, unsigned char **imageData, int *heights, int *widths, SegTestResult *segTestResults, int flag)
 Apply segmentation algorithm to 1-channel images by 8-bit data (Batch inspection mode). More...
 
eErrorType SR_ApplySegTestFromMultiple8bitCharColorArrays (SegTestHandle handle, int numberOfImages, unsigned char **imageData, int *heights, int *widths, SegTestResult *segTestResults, int flag)
 Apply segmentation algorithm to 3-channels(BGR) images by 8-bit data (Batch inspection mode). More...
 
eErrorType SR_ApplySegTestFromMultipleUnsignedIntColorArrays (SegTestHandle handle, int numberOfImages, unsigned int **imageData, int *heights, int *widths, SegTestResult *segTestResults, int flag)
 Apply segmentation algorithm to 4-channels(BGRA) images by 8-bit data (Batch inspection mode). More...
 
eErrorType SR_ApplySegTestFromMultiPage8bitCharArrays (SegTestHandle handle, int numOfPages, unsigned char **imageData, int height, int width, int *channels, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to multi-page image by 8-bit data (multi-page). More...
 
eErrorType SR_ApplySegTestFromMultiPageImageFileByWideCharPath (SegTestHandle handle, int numOfPages, const wchar_t **imagePaths, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to multi-page image by file path (multi-page). More...
 
eErrorType SR_ApplySegTestFromMultiPageImageFileByMultiByteCharPath (SegTestHandle handle, int numOfPages, const char **imagePaths, SegTestResult segTestResult, int flag)
 Apply segmentation algorithm to multi-page image by file path (multi-page). More...
 
eErrorType SR_ApplySegTestFromDetectedBoxes (SegTestHandle handle, int numberOfBoxes, SR_DetectedBox *detectedBoxes, SegTestResult *segTestResults, int flag)
 Apply segmentation algorithm to SR_DetectedBox::croppedImage. More...
 
eErrorType SR_GetSegTestOutputMatrixSizeInfo (SegTestResult segTestResult, int *scoreMatrixChannel, int *scoreMatrixSize)
 Get the size of Score matrix. More...
 
eErrorType SR_GetSegTestOutputMatrix (SegTestResult segTestResult, int scoreMatrixSize, unsigned char *scoreMatrixData)
 Get Score matrix. More...
 
eErrorType SR_GetSegTestROI (SegTestResult segTestResult, int *xROI, int *yROI, int *wROI, int *hROI)
 Get ROI. More...
 
eErrorType SR_GetSegTestNumberOfSegmentedObjects (SegTestResult segTestResult, int *numberOfSegmentedObjects)
 Get the number of SR_SegmentedObject. More...
 
eErrorType SR_GetSegTestSegmentedObjects (SegTestResult segTestResult, SR_SegmentedObject *segmentedObjects)
 Get SR_SegmentedObject s. More...
 
eErrorType SR_GetSegTestNumberOfDeletedObjects (SegTestResult segTestResult, int *numberOfDeletedObjects)
 Get the number of deleted SR_SegmentedObject s by filter process Segmentation's area threshold. More...
 
eErrorType SR_GetSegTestDeletedObjects (SegTestResult segTestResult, SR_SegmentedObject *deletedObjects)
 Get deleted SR_SegmentedObject s by filter process Segmentation's area threshold. More...
 
eErrorType SR_GetSegTestResultOriginalImageSize (SegTestResult segTestResult, int *width, int *height)
 Get the size of inspected image. More...
 
eErrorType SR_GetSegTestInspectionTime (SegTestResult segTestResult, long *inspectionTimeInLong)
 Get the inspection time. More...
 
eErrorType SR_GetSegTestInspectionTimeInDouble (SegTestResult segTestResult, double *inspectionTimeInDouble)
 Get the inspection time. More...
 
eErrorType SR_GetSegTestLoadImageTime (SegTestResult segTestResult, long *imageLoadingTimeInLong)
 Get the image loading time. More...
 
eErrorType SR_GetSegTestLoadImageTimeInDouble (SegTestResult segTestResult, double *imageLoadingTimeInDouble)
 Get the image loading time. More...
 
eErrorType SR_DestroySegTestHandle (SegTestHandle handle)
 Destruct a SegTestHandle.
 
eErrorType SR_DeleteSegTestResult (SegTestResult segTestResult)
 Destruct a SegTestResult.
 
eErrorType SR_SetSegTestOptionsAsDefault (SegTestHandle handle)
 Reset inspection options(Forward time limit, Segmentation's score threshold etc) as default values. More...
 
eErrorType SR_WriteSegTestOptionsOnModelFile (SegTestHandle handle)
 Write inspection options(Forward time limit, Segmentation's score threshold etc) on the model file.
 

Detailed Description

Header file for segmentation module.

Enumeration Type Documentation

◆ eSegTestOutputType

Segmentation output type.

ONE_CLASS: algorithm judges only whether each pixel is a normal or a defect, not there classes. The shape of score matrix is height x width.
MULTI_CLASS: algorithm judges whether it is a background or a defect, and which defect it is. The shape of score matrix is (# of classes) x height x width.
MATRIX_OUTPUT: algorithm calculates only pixel-wise score matrix, not segmentec objects (SR_SegmentedObject).
CV_CONTOUR_OUTPUT: algorithm calculates not only pixel-wise score matrix, but also segmented objects (SR_SegmentedObject).
HEATMAP_OUTPUT: algorithm calculates heatmap(raw score matrix) which is not filtered by score thresholds yet.

Enumerator
SR_ONE_CLASS_MATRIX_OUTPUT 

ONE_CLASS + MATRIX_OUTPUT.

SR_MULTI_CLASS_MATRIX_OUTPUT 

MULTI_CLASS + MATRIX_OUTPUT.

SR_ONE_CLASS_CV_CONTOUR_OUTPUT 

ONE_CLASS + CV_CONTOUR_OUTPUT.

SR_MULTI_CLASS_CV_CONTOUR_OUTPUT 

MULTI_CLASS + CV_CONTOUR_OUTPUT.
Default setting. Users can get the same result as SaigeVision training program.

Function Documentation

◆ SR_GetSegTestCropParamsUsedForExportingResults()

eErrorType SR_GetSegTestCropParamsUsedForExportingResults ( SegTestHandle  handle,
int *  cropHeight,
int *  cropWidth,
eModeOfCropLargeObjects *  mode,
float *  margin 
)

Get cropping parameters (crop height & width, mode, margin) used for exporting segmented objects.

If user have never exported segmented objects, crop height & width is the same with 'Crop size' used for training.
Is is recommended to use SR_GetSegTestIsToStoreCroppedImage instead.

◆ SR_SetSegTestMaxGPUMemorySizeInByte()

eErrorType SR_SetSegTestMaxGPUMemorySizeInByte ( SegTestHandle  handle,
unsigned long long  maxGPUMemorySizeInByte 
)

Set the maximum size of gpu memory to use for inspections in byte.

Parameters
handlesegmentation file handler
maxGPUMemorySizeInBytemaximum GPU memory size in bytes to use for this handler
Warning
Must be called before SR_LoadSegTestNetworkInGPU.

◆ SR_SetSegTestOptionsAsDefault()

eErrorType SR_SetSegTestOptionsAsDefault ( SegTestHandle  handle)

Reset inspection options(Forward time limit, Segmentation's score threshold etc) as default values.