| class info |
| com.huawei.hms.mlsdk.common.LensEngine |
| Represents a class with the camera initialization, frame obtaining, and logic control functions encapsulated. |
| Type | Name | Desc |
| int | BACK_LENS | Rear camera. |
| int | FRONT_LENS | Front camera. |
| Constant |
| public static final int BACK_LENS |
| Rear camera. |
| Constant Value: 0。 |
| Constant |
| public static final int FRONT_LENS |
| Front camera. |
| Constant Value: 1。 |
| Method |
| public synchronized void close() |
| Closes the camera and stops sending frames to the frame analyzer. |
| Method |
| public synchronized int doZoom(float scale) |
| Adjusts the focal length of the camera based on the scaling coefficient (digital zoom). |
Parameters
| Parameter name | Parameter desc |
| Scale | Scaling coefficient.If the scaling coefficient is greater than 1.0, the focal length is calculated as follows: Maximum focal length supported by the camera x 1/10 x Scaling coefficientIf the scaling coefficient is 1.0, the focal length does not change.If the scaling coefficient is less than 1.0, the focal length equals the current focal length multiplied by the scaling coefficient. |
Return
| Type | Desc |
| int | Focal length after adjustment. If the focal length after adjustment is greater than the maximum supported by the camera, the maximum supported by the camera is used. |
| Method |
| public Size getDisplayDimension() |
| Obtains the size of the preview image of a camera. |
Return
| Type | Desc |
| Size | Size of the preview image of a camera. |
| Method |
| public int getLensType() |
| Obtains the selected camera type. |
Return
| Type | Desc |
| int | Selected camera type.0: rear-facing camera1: front-facing camera |
| Method |
| public Camera getLens() |
| Obtains the camera instance. |
Return
| Type | Desc |
| Camera | Camera instance. |
| Method |
| public void photograph(LensEngine.ShutterListener shutterListener, LensEngine.PhotographListener photographListener) |
| Monitors photographing. |
Parameters
| Parameter name | Parameter desc |
| shutterListener | Callback function called upon shutter touch. |
| photographListener | Callback function called upon image data obtaining. |
| Method |
| public synchronized void release() |
| Releases resources occupied by LensEngine. |
Return
| Type | Desc |
| LensEngine | Camera engine. |
Throws
| Exception name | Exception desc |
| IOException | This exception is thrown if the LensEngine fails to start. |
| Method |
| public synchronized LensEngine run(android.view.SurfaceHolder surfaceHolder) throws IOException |
| Starts the LensEngine and uses SurfaceView as the frame preview panel. |
Parameters
| Parameter name | Parameter desc |
| surfaceHolder | Frame preview panel. |
Return
| Type | desc |
| LensEngine | Camera engine. |
Throws
| Exception name | Exception desc |
| IOException | This exception is thrown if the LensEngine fails to start. |
| Method |
| public synchronized LensEngine run(android.graphics.SurfaceTexture surfaceTexture) throws IOException |
| Starts the LensEngine and uses SurfaceTexture as the frame preview panel. |
Parameters
| Parameter name | Parameter desc |
| surfaceTexture | Frame preview panel. |
Return
| Type | desc |
| LensEngine | Camera engine. |
Throws
| Exception name | Exception desc |
| IOException | This exception is thrown if the LensEngine fails to start. |