| class info |
| com.huawei.hms.mlsdk.imgseg.MLImageSegmentationAnalyzer |
| Image segmentation analyzer, which is used to obtain the image segmentation information (MLImageSegmentation) in images. |
| Return type | Method name |
| android.util.SparseArray<mlsdk.imgseg.MLImageSegmentation> | analyseFrame(MLFrame frame) |
| com.huawei.hmf.tasks.Task | asyncAnalyseFrame(MLFrame frame) |
| mlsdk.imgseg.MLImageSegmentationAnalyzer | create(MLApplication app, mlsdk.imgseg.MLImageSegmentationSetting setting) |
| void | stop()throws IOException |
| Method |
| public android.util.SparseArray<mlsdk.imgseg.MLImageSegmentation> analyseFrame(MLFrame frame) |
| Implements image segmentation in synchronous mode. |
Parameters
| Parameter name | Parameter desc |
| frame | Image to be detected. |
Return
| Type | desc |
| 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 name | Parameter desc |
| frame | Image to be detected. |
Return
| Type | desc |
| com.huawei.hmf.tasks.Task | Returns the asynchronous image segmentation object that encapsulates the detection result. For details about the object, please refer to the sample code. |
Sample Code
- // Create an image segmentation analyzer that uses the default configuration.
- MLImageSegmentationAnalyzer analyzer = MLAnalyzerFactory.getInstance().getImageSegmentationAnalyzer();
- // Create MLFrame uMLFramee bitmap.It is recommended that the image size be greater than or equal to 224 x 224.
- MLFrame frame = MLFrame.fromBitmap(bitmap);
- Task
- task = analyzer.asyncAnalyseFrame(frame);
- task.addOnSuccessListener(new OnSuccessListener<MLImageSegmentation> () {
- public void onSuccess(MLImageSegmentation imagesegmentation) {
- // Process the detection result.
- }
- }).addOnFailureListener(new OnFailureListener() {
- public void onFailure(Exception e) {
- // Detection failure.
- }
- });
| Method |
| public static synchronized mlsdk.imgseg.MLImageSegmentationAnalyzer create(MLApplication app, mlsdk.imgseg.MLImageSegmentationSetting setting) |
| Constructs an image segmentation analyzer. |
Parameters
| Parameter name | Parameter desc |
| app | application |
| setting | Image segmentation analyzer configuration. |
Return
| Type | desc |
| mlsdk.imgseg.MLImageSegmentationAnalyzer | Returns 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 name | Exception desc |
| IOException | I/O exception in input and output streams. |