目录

class info
com.huawei.hms.mlsdk.productvisionsearch.cloud.MLRemoteProductVisionSearchAnalyzer

Represents the product visual search analyzer, which detects product information from a supplied image. After the cloud API is called, the detection model runs on the cloud.  A product visual search analyzer can be created in either of the following ways:  

  1. // Method 1: Use default parameter settings.
  2.    MLRemoteProductVisionSearchAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteProductVisionSearchAnalyzer();  
  3. // Method 2: Use customized parameter settings.
  4.    MLRemoteProductVisionSearchAnalyzer analyzer =  MLAnalyzerFactory.getInstance().getRemoteProductVisionSearchAnalyzer(setting);

Sample Code

  1. // Method 1: Use default parameter settings.
  2.    MLRemoteProductVisionSearchAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteProductVisionSearchAnalyzer();
  3. // Method 2: Use customized parameter settings.
  4. // setLargestNumOfReturns: maximum number of detection results.
  5.    MLRemoteProductVisionSearchAnalyzerSetting settings = new MLRemoteProductVisionSearchAnalyzerSetting.Factory()
  6.    .setLargestNumOfReturns(1)
  7.    .create();
  8.    MLRemoteProductVisionSearchAnalyzer analyzer = MLAnalyzerFactory.getInstance().getRemoteProductVisionSearchAnalyzer(settings);
  9. // Construct MLFrame by using the bitmap.
  10.    MLFrame mlFrame = new MLFrame.Creator().setBitmap(bitmap).create();
  11. // Detect product information.
  12.    Task<List<MLProductVisionSearch>> task = analyzer.asyncAnalyseFrame(mlFrame);
  13. task.addOnSuccessListener(new OnSuccessListener<List<MLProductVisionSearch>>() {
  14.    public void onSuccess(List<MLProductVisionSearch> resultList) {
  15.        // Processing logic for success.
  16. }})
  17. .addOnFailureListener(new OnFailureListener() {
  18.    public void onFailure(Exception e) {
  19.        // Processing logic for failure.
  20. }});

Public Method Summary

Return typeMethod name
Task<List<MLProductVisionSearch>>asyncAnalyseFrame(MLFrame frame)
voidstop()
MLRemoteProductVisionSearchAnalyzercreate(MLApplication app, MLRemoteProductVisionSearchAnalyzerSetting setting)

Public Methods

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

Parameters

Parameter nameParameter desc
frameImage object.

Return

Typedesc
com.huawei.hmf.tasks.Task<List<MLProductVisionSearch>>Returns the asynchronous task object.
Method
public void stop()
Releases resources, including input and output streams.
Method
public static synchronized MLRemoteProductVisionSearchAnalyzer create(MLApplication app, MLRemoteProductVisionSearchAnalyzerSetting setting)
Creates a product visual search analyzer object.

Parameters

Parameter nameParameter desc
appMLApplication instance.
settingInstance of the product visual search configurator.

Return

Typedesc
MLRemoteProductVisionSearchAnalyzerReturns the product visual search analyzer object.