目录

class info
com.huawei.hms.mlsdk.imgseg.MLImageSegmentationAnalyzer
Image segmentation analyzer, which is used to obtain the image segmentation information (MLImageSegmentation) in images.

Public Method Summary

Return typeMethod name
android.util.SparseArray<mlsdk.imgseg.MLImageSegmentation>analyseFrame(MLFrame frame)
com.huawei.hmf.tasks.TaskasyncAnalyseFrame(MLFrame frame)
mlsdk.imgseg.MLImageSegmentationAnalyzercreate(MLApplication app, mlsdk.imgseg.MLImageSegmentationSetting setting)
voidstop()throws IOException

Public Methods

Method
public android.util.SparseArray<mlsdk.imgseg.MLImageSegmentation> analyseFrame(MLFrame frame)
Implements image segmentation in synchronous mode.

Parameters

Parameter nameParameter desc
frameImage to be detected.

Return

Typedesc
android.util.SparseArray<mlsdk.imgseg.MLImageSegmentation>Returns the image segmentation result.
Method
public com.huawei.hmf.tasks.TaskasyncAnalyseFrame(MLFrame frame)
Implements image segmentation in asynchronous mode.

Parameters

Parameter nameParameter desc
frameImage to be detected.

Return

Typedesc
com.huawei.hmf.tasks.TaskReturns the asynchronous image segmentation object that encapsulates the detection result. For details about the object, please refer to the sample code.

Sample Code

  1. // Create an image segmentation analyzer that uses the default configuration.
  2. MLImageSegmentationAnalyzer analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer();
  3. // Create MLFrame uMLFramee bitmap.It is recommended that the image size be greater than or equal to 224 x 224.
  4. MLFrame frame = MLFrame.fromBitmap(bitmap);
  5. Task
  6. task = analyzer.asyncAnalyseFrame(frame);
  7. task.addOnSuccessListener(new OnSuccessListener<MLImageSegmentation> () {
  8.    public void onSuccess(MLImageSegmentation imagesegmentation) {
  9.        // Process the detection result.
  10.    }
  11. }).addOnFailureListener(new OnFailureListener() {
  12.    public void onFailure(Exception e) {
  13.        // Detection failure.
  14.    }
  15. });
Method
public static synchronized mlsdk.imgseg.MLImageSegmentationAnalyzer create(MLApplication app, mlsdk.imgseg.MLImageSegmentationSetting setting)
Constructs an image segmentation analyzer.

Parameters

Parameter nameParameter desc
appapplication
settingImage segmentation analyzer configuration.

Return

Typedesc
mlsdk.imgseg.MLImageSegmentationAnalyzerReturns the image segmentation analyzer of the specified fine detection setting.
Method
public void stop() throws IOException
Releases resources, including input and output streams and loaded model files..

Throws

Exception nameException desc
IOExceptionI/O exception in input and output streams.