We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

Documents from this version have been archived, and will not continue to be maintained. Please use the latest version.

HMS Core ReferencesML Kitmlsdk.landmarkMLRemoteLandmarkAnalyzer

MLRemoteLandmarkAnalyzer

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);

Sample Code

  1. // Method 1: Use default parameter settings.
  2. MLRemoteLandmarkAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteLandmarkAnalyzer();
  3. // Method 2: Use customized parameter settings.
  4. // setLargestNumOfReturns: Maximum number of detection results.
  5. // setPatternType: Mode used by the analyzer.
  6. // MLRemoteLandmarkAnalyzerSetting.STEADY_PATTERN: The value is 1, 1ndicating the stable mode.
  7. // MLRemoteLandmarkAnalyzerSetting.NEWEST_PATTERN: The value is 2, 2ndicating the latest mode.
  8. MLRemoteLandmarkAnalyzerSetting settings = new MLRemoteLandmarkAnalyzerSetting.Factory()
  9.   .setLargestNumOfReturns(1)
  10.   .setPatternType(MLRemoteLandmarkAnalyzerSetting.STEADY_PATTERN)
  11.   .create();
  12. MLRemoteLandmarkAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteLandmarkAnalyzer(settings);
  13. // Construct MLFMLFrame using the bitmap.It is recommended that the image size be greater than or equal to 640 x 640.
  14. MLFrame mlFrame = new MLFrame.Creator().setBitmap(bitmap).create();
  15. // Landmark recognition.
  16. Task<List<MLRemoteLandmark>> task = analyzer.asyncAnalyseFrame(mlFrame);
  17. task.addOnSuccessListener(new OnSuccessListener<List<MLRemoteLandmark>>() {
  18.   public void onSuccess(List<MLRemoteLandmark> landmarkResults) {
  19.      // Processing logic for detection success.
  20.   }
  21. }).addOnFailureListener(new OnFailureListener() {
  22.   public void onFailure(Exception e) {
  23.      // Processing logic for detection failure.
  24.   }
  25. });

Public Method Summary

Return typeMethod name
com.huawei.hmf.tasks.Task<List<MLRemoteLandmark>>asyncAnalyseFrame(MLFrame frame)
voidclose()throws IOException
voidstop()throws IOException
MLRemoteLandmarkAnalyzercreate(MLApplication app, MLRemoteLandmarkAnalyzerSetting setting)

Public Methods

Method
public com.huawei.hmf.tasks.Task<List<MLRemoteLandmark>> asyncAnalyseFrame(MLFrame frame)
Detects landmarks in a supplied image.

Parameters

Parameter nameParameter desc
frameImage object.

Return

Typedesc
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 nameException desc
IOExceptionException 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 nameException desc
IOExceptionException 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 nameParameter desc
appMLApplication instance.
settingInstance of the landmark analysis configurator.

Return

Typedesc
MLRemoteLandmarkAnalyzerReturns the landmark analyzer object.
This page may contain third-party content. For details, click here.
Search in References
Enter a keyword.