C# API

Interface Functions

  1. setVisible

    void setVisible(Boolean flag);
    

    Set up the result visualization. If this function sets visualization to true, the SDK will automatically fuse the predicted result with the input data, and the result will be in Returned Results of Interface Function Inference. If you have high requirements on performance, please do not set it to true.

    Input parameter:

    • flag: The boolean flag for visualization. The value defaults to false.

    Returned value:

    None

  2. setConvertInseg

    void setConvertInseg(Boolean Convertflag);
    

    Set the processing of instance segmentation results. If true is input, the inference result of instance segmentation models will have information of the inscribed rectangles and the circumscribed rectangles, and the result will be in Returned Results of Interface Function Inference. If you have high requirements on performance, please do not set it to true.

    Input parameter:

    Convertflag: The Boolean flag for drawing the inscribed and circumscribed rectangles of the instance masks. The value defaults to false.

    Returned value:

    None

  3. LoadModel

    SDKStatus LoadModel(string packPath);
    

    Load the model exported by Mech-DLK. This interface is a synchronous interface and may be blocked. It is recommended to use thread calls.

    Input parameter:

    • packPath: dlkpack file path.

    Returned value:

  4. Predict

    InferPackResult Predict(Bitmap img);
    

    Perform inference.

    Input parameter:

    • img: bitmap image.

    Returned value:

    InferPackResult: Inference result. See Returned Results of Interface Function Inference for details.

Returned Values of Interface Function Call

Status code returned

Enumeration value

Note

STATUS_OK

1000

No interface call exception.

FILE_NOT_FOUND

1001

File not found.

VALUE_OUTOF_LEFTRANGE

1002

The parameter value exceeds the left limit. Example: If the parameter value range is [0.0, 1.0], it will be generated when the parameter value is less than 0.0.

VALUE_OUTOF_RIGHTRANGE

1003

The parameter value exceeds the right limit. Example: If the parameter value range is [0.0, 1.0], it will be generated when the parameter value is greater than 1.0.

MODELTYPE_ERROR

1004

Model type error.

MODEL_REGISTEXCEEDLIMIT_ERROR

1005

Number of registered models beyond the limit.

MODEL_CREATE_ERROR

1006

Model creation error.

MODEL_DESTROY_ERROR

1007

Model unregistration error.

MODEL_LOAD_ERROR

1008

Model loading error.

MODEL_INIT_ERROR

1009

Model initialization error.

MODEL_INFER_ERROR

1010

Model inference error.

GET_RESULT_ERROR

1011

Error getting model result .

IMGPATH_ERROR

1012

Invalid image file path.

IMGNULL_ERROR

1013

Empty image.

IMGCHANNEL_ERROR

1014

Image channel error.

IMGDEPTH_ERROR

1015

Image bit depth error.

IMGSIZE_ERROR

1016

Image size error.

INCONSISTENT_IMAGEDEPTH_ERROR

1017

Inconsistent bit depths of two images.

INCONSISTENT_IMAGESIZE_ERROR

1018

Inconsistent sizes of two images.

INCONSISTENT_IMAGETYPE_ERROR

1019

Inconsistent types of two images.

IMGROI_ERROR

1020

Incorrect image ROI parameters.

IMGROI_NULL_ERROR

1021

Empty image ROI parameters.

IMG_CONVERTTYPE_ERROR

1022

Incorrect conversion parameters for image color space transformation.

CONFIG_PARAM_ERROR

1023

Configuration parameter error.

UNKNOWN_ERROR

1024

Unknown error.

Returned Results of Interface Function Inference

Status code returned

Enumeration value

Note

status

SDKStatus

1000 means normal, other values mean errors. Please see Returned Values of Interface Function Call for details.

type

Type

Model type. 0: unknown model; 1: defect segmentation; 2: instance segmentation; 3: object detection; 4: image classification.

imageShow

Bitmap

Visualization image.

masks

Bitmap[ ]

Result masks.

labels

int[ ]

Inference result labels.

bboxes

float[ ]

Bounding box coordinates. Every 4 values (upper left X, upper left Y, lower right X, lower right Y) are for one box.

externalRect

float[ ]

Instance min circumscribed rectangle coordinates. Every 4 values (upper left X, upper left Y, lower right X, lower right Y) are for one rectangle.

internalRect

float[ ]

Instance max inscribed rectangle coordinates. Every 4 values (upper left X, upper left Y, lower right X, lower right Y) are for one rectangle.

confidence

float[ ]

Result confidences.