| class info |
| com.huawei.hms.mlsdk.landmark.MLRemoteLandmarkAnalyzer |
Represents the landmark analyzer, which detects landmarks in a supplied image. After the cloud API is called, the detection model runs on the cloud. A landmark analyzer can be created in either of the following ways: Method 1: Use default parameter settings. MLRemoteLandmarkAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteLandmarkAnalyzer(); Method 2: Use customized parameter settings. MLRemoteLandmarkAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteLandmarkAnalyzer(setting); |
- // Method 1: Use default parameter settings.
- MLRemoteLandmarkAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteLandmarkAnalyzer();
- // Method 2: Use customized parameter settings.
- // setLargestNumOfReturns: Maximum number of detection results.
- // setPatternType: Mode used by the analyzer.
- // MLRemoteLandmarkAnalyzerSetting.STEADY_PATTERN: The value is 1, 1ndicating the stable mode.
- // MLRemoteLandmarkAnalyzerSetting.NEWEST_PATTERN: The value is 2, 2ndicating the latest mode.
- MLRemoteLandmarkAnalyzerSetting settings = new MLRemoteLandmarkAnalyzerSetting.Factory()
- .setLargestNumOfReturns(1)
- .setPatternType(MLRemoteLandmarkAnalyzerSetting.STEADY_PATTERN)
- .create();
- MLRemoteLandmarkAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteLandmarkAnalyzer(settings);
- // Construct MLFMLFrame using the bitmap.It is recommended that the image size be greater than or equal to 640 x 640.
- MLFrame mlFrame = new MLFrame.Creator().setBitmap(bitmap).create();
- // Landmark recognition.
- Task<List<MLRemoteLandmark>> task = analyzer.asyncAnalyseFrame(mlFrame);
- task.addOnSuccessListener(new OnSuccessListener<List<MLRemoteLandmark>>() {
- public void onSuccess(List<MLRemoteLandmark> landmarkResults) {
- // Processing logic for detection success.
- }
- }).addOnFailureListener(new OnFailureListener() {
- public void onFailure(Exception e) {
- // Processing logic for detection failure.
- }
- });
| Return type | Method name |
| com.huawei.hmf.tasks.Task<List<MLRemoteLandmark>> | asyncAnalyseFrame(MLFrame frame) |
| void | close()throws IOException |
| void | stop()throws IOException |
| MLRemoteLandmarkAnalyzer | create(MLApplication app, MLRemoteLandmarkAnalyzerSetting setting) |
| Method |
| public com.huawei.hmf.tasks.Task<List<MLRemoteLandmark>> asyncAnalyseFrame(MLFrame frame) |
| Detects landmarks in a supplied image. |
Parameters
| Parameter name | Parameter desc |
| frame | Image object. |
Return
| Type | desc |
| com.huawei.hmf.tasks.Task<List<MLRemoteLandmark>> | Returns the asynchronous task object. |
| Method |
| public void close() throws IOException |
| Releases resources, including input and output streams. |
Throws
| Exception name | Exception desc |
| IOException | Exception that occurs in the input and output streams during resource release. |
| Method |
| public void stop() throws IOException |
| Releases resources, including input and output streams. |
Throws
| Exception name | Exception desc |
| IOException | Exception that occurs in the input and output streams during resource release. |
| Method |
| public static synchronized MLRemoteLandmarkAnalyzer create(MLApplication app, MLRemoteLandmarkAnalyzerSetting setting) |
| Creates a landmark analyzer object. |
Parameters
| Parameter name | Parameter desc |
| app | MLApplication instance. |
| setting | Instance of the landmark analysis configurator. |
Return
| Type | desc |
| MLRemoteLandmarkAnalyzer | Returns the landmark analyzer object. |