目录

class info
com.huawei.hms.mlsdk.common.LensEngine.Creator
Represents a LensEngine creator used to create an instance of LensEngine.

Public Constructor Summary

Constructor name
Creator(android.content.Context context, MLAnalyzer<?> analyzer)
Creates an instance of LensEngine.
Creator(android.content.Context context, MLAnalyzer<?> analyzer, LensRequest lensRequest)
Creates an instance of LensEngine.
Creator(android.content.Context context, MLAnalyzer<?> analyzer, LensRequest lensRequest, MLLensSelector lensSelector)
Creates an instance of LensEngine.

Public Method Summary

Return typeMethod name
LensEngine.CreatorapplyDisplayDimension(int width, int height)
LensEngine.CreatorapplyFps(float fps)
LensEnginecreate()
LensEngine.CreatorenableAutomaticFocus(boolean autoFocusEnabled)
LensEngine.CreatorsetFlashMode(String flashMode)
LensEngine.CreatorsetFocusMode(String focusMode)
LensEngine.CreatorsetLensType(int type)

Public Constructors

Method
public Creator(android.content.Context context, MLAnalyzer<?> analyzer)
Creates an instance of LensEngine.

Parameters

Parameter nameParameter desc
contextContext
analyzerAnalyzer, for example, MLCompositeAnalyzer, which extends the MLAnalyzerclass.
Method
public Creator(android.content.Context context, MLAnalyzer<?> analyzer, LensRequest lensRequest)
Creates an instance of LensEngine.

Parameters

Parameter nameParameter desc
contextContext
analyzerAnalyzer, for example, MLCompositeAnalyzer, which extends the MLAnalyzerclass.
lensRequestInstance of LensRequest, including camera selection parameters such as the camera type (front or rear)
as well as the frame rate and preview image size that need to be supported by the camera.
During startup, the LensEngine selects a camera based on the parameters
and then initializes parameters (for example, whether to enable automatic focus
and the flash mode) of the selected camera.
Method
public Creator(android.content.Context context, MLAnalyzer<?> analyzer, LensRequest lensRequest, MLLensSelector lensSelector)
Creates an instance of LensEngine.

Parameters

Parameter nameParameter desc
contextContext
analyzerAnalyzer, for example, MLCompositeAnalyzer, which extends the MLAnalyzerclass.
lensRequest

Instance of LensRequest,including camera selection parameters such as the camera type (front or rear)

as well as the frame rate and preview image size that need to be supported by the camera.

During startup, the LensEngine selects a camera based on the parameters
and then initializes parameters (for example, whether to enable automatic focus
and the flash mode) of the selected camera.
lensSelectorCustom camera selection policy,
for example, a frame rate, preview image size, or camera type matching policy.

Public Methods

Method
public LensEngine.Creator applyDisplayDimension(int width, int height)
Sets the size of the preview image of a camera. Different image sizes are recommended when different algorithms are used for image processing. In addition, processing large images consumes more memory and CPU resources. It is recommended that the size of the preview image be 1920 x 1920 or smaller.

Parameters

Parameter nameParameter desc
widthWidth of a preview image, in pixels.
heightHeight of a preview image, in pixels.


Return

Typedesc
LensEngine.CreatorAn instance of LensEngine.Creator.
Method
public LensEngine.Creator applyFps(float fps)
Sets the preview frame rate (fps) of a camera. The preview frame rate of a camera depends on the firmware capability of the camera.

Parameters

Parameter nameParameter desc
fpsPreview frame rate.


Return

Typedesc
LensEngine.CreatorAn instance of LensEngine.Creator.
Method
public LensEngine create()
Creates an instance of LensEngine.

Return

Typedesc
LensEngineAn instance of LensEngine.
Method
public LensEngine.Creator enableAutomaticFocus(boolean autoFocusEnabled)
Enables or disables the automatic focus function for a camera.

Parameters

Parameter nameParameter desc
autoFocusEnabledIndicates whether to enable the automatic focus function.
The options are as follows:
true: enables the automatic focus function
false: disables the automatic focus function


Return

Typedesc
LensEngine.CreatorAn instance of LensEngine.Creator.
Method
public LensEngine.Creator setFlashMode(String flashMode)
Sets the flash mode for a camera.

Parameters

Parameter nameParameter desc
flashModeFlash mode of a camera. The options are as follows:
Camera.FLASH_MODE_AUTO(“auto”): automatically determines whether to turn on the flash
Camera.FLASH_MODE_ON(“on”): turns on the flash
Camera.FLASH_MODE_OFF(“off”): turns off the flash


Return

Typedesc
LensEngine.CreatorAn instance of LensEngine.Creator.
Method
public LensEngine.Creator setFocusMode(String focusMode)
Sets the focus mode for a camera.

Parameters

Parameter nameParameter desc
focusModeFocus mode of a camera. The options are as follows:
Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE(“continuous-picture”): continuous image focus mode
Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO(“continuous-video”): continuous video focus mode


Return

Typedesc
LensEngine.CreatorAn instance of LensEngine.Creator.
Method
public LensEngine.Creator setLensType(int type)
Sets the camera type.

Parameters

Parameter nameParameter desc
typeCamera type. The options are as follows:
BACK_LENS(0): rear camera
FRONT_LENS(1): front camera


Return

Typedesc
LensEngine.CreatorAn instance of LensEngine.Creator.