Mech-DLK SDK C API 2.0.2
C API reference documentation for secondary development with Mech-DLK
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Pages
Functions
dl_packInfer.h File Reference
#include "common/Export.h"
#include "dl_definition.h"
#include "dl_result.h"

Go to the source code of this file.

Functions

MMIND_DL_SDK_EXPORT StatusCode createImage (const char *imagePath, MMindImage *image)
 Create an image from its path.
 
MMIND_DL_SDK_EXPORT void releaseImage (const MMindImage *image)
 Release the memory of the image.
 
MMIND_DL_SDK_EXPORT StatusCode showImage (const MMindImage *image, const char *windowName)
 Visualize an image.
 
MMIND_DL_SDK_EXPORT StatusCode saveImage (const MMindImage *image, const char *path)
 Save the image to a specified directory.
 
MMIND_DL_SDK_EXPORT StatusCode createPackInferEngine (Engine *engine, const char *packPath, const BackendType backend, const unsigned int deviceId)
 Create an engine for model package inference.
 
MMIND_DL_SDK_EXPORT void releasePackInferEngine (const Engine *engine)
 Release the memory of the model package inference engine.
 
MMIND_DL_SDK_EXPORT StatusCode setBatchSizeAndFloatPrecision (const Engine *engine, const unsigned int batchSize, const FloatPrecisionType floatPrecision, const unsigned int moduleIdx)
 Set the batch size and floating-point precision of the inference engine.
 
MMIND_DL_SDK_EXPORT StatusCode infer (const Engine *engine, const MMindImage *images, const unsigned int imageNum)
 Make image inference using the model package inference engine.
 
MMIND_DL_SDK_EXPORT StatusCode getDefectSegmentataionResult (const Engine *engine, const unsigned int moduleIdx, DefectAndEdgeResult **results, unsigned int *resultNum)
 Get the defect segmentation result.
 
MMIND_DL_SDK_EXPORT void releaseDefectSegmentationResult (DefectAndEdgeResult **results, unsigned int resultNum)
 Release the memory of the defect segmentation result.
 
MMIND_DL_SDK_EXPORT StatusCode getObjectAndInstanceResult (const Engine *engine, const unsigned int moduleIdx, ObjectAndInsResult **results, unsigned int *resultNum)
 Get the object detection or instance segmentation result.
 
MMIND_DL_SDK_EXPORT void releaseObjectAndInstanceResult (ObjectAndInsResult **results, unsigned int resultNum)
 Release the memory of the object detection or instance segmentation result.  *.
 
MMIND_DL_SDK_EXPORT StatusCode getClassificationResult (const Engine *engine, const unsigned int moduleIdx, ClassificationResult **results, unsigned int *resultNum)
 Get the classification result.
 
MMIND_DL_SDK_EXPORT void releaseClassificationResult (ClassificationResult **results, unsigned int resultNum)
 Release the memory of the classification result.
 
MMIND_DL_SDK_EXPORT StatusCode getFastPositioningResult (const Engine *engine, const unsigned int moduleIdx, FastPositioningResult **results, unsigned int *resultNum)
 Get the fast positioning result.
 
MMIND_DL_SDK_EXPORT void releaseFastPositioningResult (FastPositioningResult **results, unsigned int resultNum)
 Release the memory of the fast positioning result.
 
MMIND_DL_SDK_EXPORT StatusCode moduleResultVisualization (const Engine *engine, const MMindImage *images, const unsigned int moduleIdx, const unsigned int imageNum)
 Draw the model results of the specified index onto the images.
 
MMIND_DL_SDK_EXPORT StatusCode resultVisualization (const Engine *engine, const MMindImage *images, const unsigned int imageNum)
 Draw all the model results onto the images.
 

Function Documentation

◆ createImage()

MMIND_DL_SDK_EXPORT StatusCode createImage ( const char *  imagePath,
MMindImage image 
)

Create an image from its path.

Parameters
[in]imagePathImage storage path.
[out]imageSee MMindImage for details.
Returns
See StatusCode for details.
Note
When using the createImage to create an image and make the inference of the image, do not forget to call releaseImage to release the memory and thus avoid memory leaks.

◆ createPackInferEngine()

MMIND_DL_SDK_EXPORT StatusCode createPackInferEngine ( Engine engine,
const char *  packPath,
const BackendType  backend,
const unsigned int  deviceId 
)

Create an engine for model package inference.

Parameters
[out]engineIdentifier of the created engine. See Engine for details.
[in]packPathThe path to the model package exported from Mech-DLK.
[in]backendSee BackendType for details.
[in]deviceIdThe index of the specified GPU during model inference.
Returns
See StatusCode for details.
Note
When the backend is set to CPU, the setting of deviceId is invalid; when the backend is set to GpuOptimization, it takes 1-5 minutes to optimize the model.

◆ getClassificationResult()

MMIND_DL_SDK_EXPORT StatusCode getClassificationResult ( const Engine engine,
const unsigned int  moduleIdx,
ClassificationResult **  results,
unsigned int *  resultNum 
)

Get the classification result.

Parameters
[in]engineSee Engine for details.
[in]moduleIdxSpecified model index in the model package.
[out]resultsSee ClassificationResult for details.
[out]resultNumThe number of inference results.
Returns
See StatusCode for details.

◆ getDefectSegmentataionResult()

MMIND_DL_SDK_EXPORT StatusCode getDefectSegmentataionResult ( const Engine engine,
const unsigned int  moduleIdx,
DefectAndEdgeResult **  results,
unsigned int *  resultNum 
)

Get the defect segmentation result.

Parameters
[in]engineSee Engine for details.
[in]moduleIdxSpecified model index in the model package.
[out]resultsSee DefectAndEdgeResult for details.
[out]resultNumThe number of inference results.
Returns
See StatusCode for details.

◆ getFastPositioningResult()

MMIND_DL_SDK_EXPORT StatusCode getFastPositioningResult ( const Engine engine,
const unsigned int  moduleIdx,
FastPositioningResult **  results,
unsigned int *  resultNum 
)

Get the fast positioning result.

Parameters
[in]engineSee Engine for details.
[in]moduleIdxSpecified model index in the model package.
[out]resultsSee FastPositioningResult for details.
[out]resultNumThe number of inference results.
Returns
See StatusCode for details.

◆ getObjectAndInstanceResult()

MMIND_DL_SDK_EXPORT StatusCode getObjectAndInstanceResult ( const Engine engine,
const unsigned int  moduleIdx,
ObjectAndInsResult **  results,
unsigned int *  resultNum 
)

Get the object detection or instance segmentation result.

Parameters
[in]engineSee Engine for details.
[in]moduleIdxSpecified model index in the model package.
[out]resultsSee ObjectAndInsResult for details.
[out]resultNumThe number of inference results.
Returns
See StatusCode for details.

◆ infer()

MMIND_DL_SDK_EXPORT StatusCode infer ( const Engine engine,
const MMindImage images,
const unsigned int  imageNum 
)

Make image inference using the model package inference engine.

Parameters
[in]engineSee Engine for details.
[in]imageSee MMindImage for details.
[in]imageNumThe number of images that need to be inferred.
Returns
See StatusCode for details.
Note
imageNum must be less than or equal to the number of elements in the images array. Otherwise, the program may crash due to the out-of-bounds array index.

◆ moduleResultVisualization()

MMIND_DL_SDK_EXPORT StatusCode moduleResultVisualization ( const Engine engine,
const MMindImage images,
const unsigned int  moduleIdx,
const unsigned int  imageNum 
)

Draw the model results of the specified index onto the images.

Parameters
[in]engineSee Engine for details.
[in]MMindImageSee MMindImage for details.
[in]moduleIdxSpecified model index in the model package.
[in]imageNumThe number of images that need to be drawn.
Note
imageNum must be less than or equal to the number of elements in the images array. Otherwise, the program may crash due to the out-of-bounds array index.
Returns
See StatusCode for details.

◆ releaseClassificationResult()

MMIND_DL_SDK_EXPORT void releaseClassificationResult ( ClassificationResult **  results,
unsigned int  resultNum 
)

Release the memory of the classification result.

Parameters
[in]resultsSee ClassificationResult for details.
[in]resultNumThe number of inference results.
Note
When using the getClassificationResult to get the classification result, and the result is processed, do not forget to call releaseClassificationResult to release the memory and thus avoid memory leaks.

◆ releaseDefectSegmentationResult()

MMIND_DL_SDK_EXPORT void releaseDefectSegmentationResult ( DefectAndEdgeResult **  results,
unsigned int  resultNum 
)

Release the memory of the defect segmentation result.

Parameters
[in]resultsSee DefectAndEdgeResult for details.
[in]resultNumThe number of inference results.
Note
When using the getDefectSegmentataionResult to get the defect segmentation result, and the result is processed, do not forget to call releaseDefectSegmentationResult to release the memory and thus avoid memory leaks.

◆ releaseFastPositioningResult()

MMIND_DL_SDK_EXPORT void releaseFastPositioningResult ( FastPositioningResult **  results,
unsigned int  resultNum 
)

Release the memory of the fast positioning result.

Parameters
[in]resultsSee FastPositioningResult for details.
[in]resultNumThe number of inference results.  *
Note
When using the getFastPositioningResult to get the fast positioning result, and  * the result is processed, do not forget to call releaseFastPositioningResult to release the memory and thus avoid memory leaks.

◆ releaseImage()

MMIND_DL_SDK_EXPORT void releaseImage ( const MMindImage image)

Release the memory of the image.

Parameters
[in]imageSee MMindImage for details.
Note
When using the createImage to create an image and make the inference of the image, do not forget to call releaseImage to release the memory and thus avoid memory leaks.

◆ releaseObjectAndInstanceResult()

MMIND_DL_SDK_EXPORT void releaseObjectAndInstanceResult ( ObjectAndInsResult **  results,
unsigned int  resultNum 
)

Release the memory of the object detection or instance segmentation result.  *.

 *

Parameters
[in]resultsSee DefectAndEdgeResult for details.
[in]resultNumThe number of inference results.  *
Note
When using the getObjectAndInstanceResult to get the object detection or  * instance segmentation result, and the result is processed, do not forget to call  * releaseObjectAndInstanceResult to release the memory and thus avoid memory leaks.  

◆ releasePackInferEngine()

MMIND_DL_SDK_EXPORT void releasePackInferEngine ( const Engine engine)

Release the memory of the model package inference engine.

Parameters
[in]engineSee Engine for details.
Note
When using the createPackInferEngine to create a model package inference engine and make the inference of the image, do not forget to call releasePackInferEngine to release the memory and thus avoid memory leaks.

◆ resultVisualization()

MMIND_DL_SDK_EXPORT StatusCode resultVisualization ( const Engine engine,
const MMindImage images,
const unsigned int  imageNum 
)

Draw all the model results onto the images.

Parameters
[in]engineSee Engine for details.
[in]MMindImageSee MMindImage for details.
[in]imageNumThe number of images that need to be drawn.
Note
imageNum must be less than or equal to the number of elements in the images array. Otherwise, the program may crash due to the out-of-bounds array index.
Returns
See StatusCode for details.

◆ saveImage()

MMIND_DL_SDK_EXPORT StatusCode saveImage ( const MMindImage image,
const char *  path 
)

Save the image to a specified directory.

Parameters
[in]imageSee MMindImage for details.
[in]pathThe path to save the image.
Returns
See StatusCode for details.

◆ setBatchSizeAndFloatPrecision()

MMIND_DL_SDK_EXPORT StatusCode setBatchSizeAndFloatPrecision ( const Engine engine,
const unsigned int  batchSize,
const FloatPrecisionType  floatPrecision,
const unsigned int  moduleIdx 
)

Set the batch size and floating-point precision of the inference engine.

Parameters
[in]engineSee Engine for details.
[in]batchSizeThe batch size of the model package.
[in]floatPrecisionSee FloatPrecisionType for details.
[in]moduleIdxSpecified model index in the model package.
Returns
See StatusCode for details.
Note
The floatPrecision only takes effect when BackendType is set to GpuOptimization; for the model package of instance segmentation, batchSize can only be 1.

◆ showImage()

MMIND_DL_SDK_EXPORT StatusCode showImage ( const MMindImage image,
const char *  windowName 
)

Visualize an image.

Parameters
[in]imageSee MMindImage for details.
[in]windowNameThe window name for visualizing an image.
Returns
See StatusCode for details.
Note
The size of the image display window equals that of the image.