com.aliyun.svideosdk.multirecorder

## Interface AliyunICameraCapture

- All Superinterfaces:
    AliyunIBaseCapture

      public interface AliyunICameraCapture
      extends AliyunIBaseCapture

  An interface for camera capturing. Added in v3.22.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `addImage(EffectImage effectImage)` Adds a image.
    `int` | `addPaster(EffectPaster effectPaster)` Adds a face sticker.
    `int` | `addPaster(EffectPaster effectPaster, float sx, float sy, float sw, float sh, float rotation, boolean flip)` Adds a sticker.
    `int` | `applyAnimationFilter(EffectFilter effectFilter)` Applies an animated filter.
    `int` | `applyFilter(EffectFilter effectFilter)` Applies a filter.
    `int` | `getBeautyLevel()` Gets the beauty level.
    `int` | `getCameraCount()` Gets the number of cameras.
    `float` | `getCurrentExposureCompensationRatio()` Gets the current exposure level.
    `java.util.List<Camera.Size>` | `getSupportedPictureSize()` Gets the picture sizes supported by the camera.
    `java.util.SortedSet<Size>` | `getSupportedPictureSizes()`
    `void` | `needFaceTrackInternal(boolean need)` Sets whether to enable facial recognition.
    `void` | `removeAnimationFilter(EffectFilter effectFilter)` Removes an animated filter.
    `void` | `removeFilter()` Remove the filter.
    `void` | `removeImage(EffectImage effectImage)` Removes a image.
    `void` | `removePaster(EffectPaster effectPaster)` Removes a sticker.
    `int` | `resizePreviewSize(int width, int height)` Sets the size of the surface view.
    `void` | `setAutoPreviewAfterTakePhoto(boolean autoPreviewAfterTakePhoto)` Sets whether to start preview after taking a picture.
    `void` | `setBeautyLevel(int level)` Sets the beauty level.
    `void` | `setBeautyStatus(boolean on)` Enables or disables beauty mode.
    `void` | `setCamera(CameraType camera)` Sets the camera during preview.
    `void` | `setCameraCaptureDataMode(int captureDataMode)` Sets the data capture method during preview.
    `void` | `setCameraParam(CameraParam cameraParam)` Sets camera parameters during preview.
    `void` | `setDisplayView(SurfaceView displayView)` Sets the `SurfaceView` during preview.
    `int` | `setEffectView(float xRatio, float yRatio, float widthRatio, float heightRatio, EffectBase effectBase)` Sets sticker parameters, such as the position and size of the sticker.
    `int` | `setExposureCompensationRatio(float value)` Sets the exposure level.
    `void` | `setFaceDetectRotation(int rotation)` Sets the rotation angle of the gyro sensor when performing facial recognition.
    `int` | `setFaces(float[][] faces)` Sets the coordinate points to define faces.
    `void` | `setFaceTrackInternalMaxFaceCount(int maxFaceCount)` Sets the maximum number of faces that can be recognized at the same time.
    `int` | `setFaceTrackInternalModelPath(java.lang.String path)` Sets the path to facial recognition models.
    `void` | `setFocus(float xRatio, float yRatio)` Sets the focus point.
    `void` | `setFocus(Point point)` Deprecated.
    `void` | `setFocusMode(int mode)` Sets the focus mode.
    `boolean` | `setLight(FlashType flashType)` Sets the flash mode.
    `void` | `setOnChoosePictureSizeCallBack(OnChoosePictureSizeCallback callback)` Sets the callback that outputs the image resolution.
    `void` | `setOnFaceDetectInfoListener(OnFaceDetectInfoListener listener)` Sets the callback that outputs facial recognition data.
    `void` | `setOnFrameCallback(OnFrameCallback callback)` Sets the callback that outputs frame data.
    `void` | `setOnTextureIdCallback(OnTextureIdCallback callback)` Sets the callback that outputs the texture on every frame.
    `void` | `setOutputFlip(boolean flip)` Use this method to flip the camera recording output.
    `int` | `setPictureSize(int width, int height)` Sets the picture size.
    `void` | `setRecordRotation(int rotation)` Sets the rotation angle of the gyro sensor during recording.
    `void` | `setRotation(int rotation)` Sets the rotation angle of the gyro sensor.
    `void` | `setShutterSound(boolean bNeedShutterSound)` Sets whether to turn on the shutter sound.
    `int` | `setZoom(float rate)` Sets the zoom level.
    `void` | `snapshot(boolean needBitmap, OnPictureCallback pictureCallback)` Camera preview snapshot, include effects.
    `int` | `startPreviewAfterTakePicture()` Use this method to start preview after taking a picture.
    `int` | `switchCamera()` Switches cameras.
    `FlashType` | `switchLight()` Switches flash modes.
    `void` | `takePhoto(boolean needBitmap, OnPictureCallback pictureCallback)` Takes a picture by system camera, no effects.
    `int` | `updateAnimationFilter(EffectFilter effectFilter)` update an animated filter.

    - ### Methods inherited from interface com.aliyun.svideosdk.multirecorder.AliyunIBaseCapture

      `captureId, removeBorder, setBorderParam, setProperty, updateLayout`

- - ### Method Detail

    - #### setCamera

          void setCamera(CameraType camera)

      Sets the camera during preview. This setting only takes effect when the preview is started for the first time. Use `switchCamera()` to switch cameras.
      Parameters:
        `camera` -
      See Also:
        `CameraType.BACK`, `CameraType.FRONT`

    - #### setDisplayView

          void setDisplayView(SurfaceView displayView)

      Sets the `SurfaceView` during preview.
      Parameters:
        `displayView` -

    - #### setCameraCaptureDataMode

          void setCameraCaptureDataMode(int captureDataMode)

      Sets the data capture method during preview.
      Parameters:
        `captureDataMode` -
      See Also:
        `CameraCaptureDataMode`

    - #### addPaster

          int addPaster(EffectPaster effectPaster)

      Adds a face sticker. Face stickers are different from other stickers in that `setRotation(int)` must be invoked to add face stickers. For details about calculating the rotation parameter, see the demo. Use this method to add face stickers only. To add other stickers, call `addPaster(EffectPaster, float, float, float, float, float, boolean)`.
      Parameters:
        `effectPaster` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.
      See Also:
        `EffectPaster`

    - #### addPaster

          int addPaster(EffectPaster effectPaster,
                        float sx,
                        float sy,
                        float sw,
                        float sh,
                        float rotation,
                        boolean flip)

      Adds a sticker. `setEffectView(float, float, float, float, EffectBase)` and this method can be used to add multiple effects.
      Parameters:
        `effectPaster` -
        `sx` - The x coordinate of the sticker relative to the video resolution.
        `sy` - The x coordinate of the sticker relative to the video resolution.
        `sw` - The width of the sticker relative to the video resolution.
        `sh` - The height of the sticker relative to the video resolution.
        `rotation` - The rotation angle of the sticker.
        `flip` - Whether to flip the sticker.
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.
      See Also:
        `setEffectView(float, float, float, float, EffectBase)`

    - #### removePaster

          void removePaster(EffectPaster effectPaster)

      Removes a sticker.
      Parameters:
        `effectPaster` -

    - #### addImage

          int addImage(EffectImage effectImage)

      Adds a image. To add a text image, use bitmap tools to convert texts into images. Use `setEffectView(float, float, float, float, EffectBase)` to adjust the position of the image.
      Parameters:
        `effectImage` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### removeImage

          void removeImage(EffectImage effectImage)

      Removes a image.
      Parameters:
        `effectImage` -

    - #### applyFilter

          int applyFilter(EffectFilter effectFilter)

      Applies a filter.
      Parameters:
        `effectFilter` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### removeFilter

          void removeFilter()

      Remove the filter.

    - #### applyAnimationFilter

          int applyAnimationFilter(EffectFilter effectFilter)

      Applies an animated filter. Call `EffectFilter.Builder` to create the filter object.
      Parameters:
        `effectFilter` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### updateAnimationFilter

          int updateAnimationFilter(EffectFilter effectFilter)

      update an animated filter. Call `EffectFilter.Builder` to create the filter object.
      Parameters:
        `effectFilter` -
      Returns:
        0 if the invocation is successful or an error code if the invocation fails.

    - #### removeAnimationFilter

          void removeAnimationFilter(EffectFilter effectFilter)

      Removes an animated filter.
      Parameters:
        `effectFilter` -

    - #### getCameraCount

          int getCameraCount()

      Gets the number of cameras.
      Returns:
        The number of cameras.

    - #### setCameraParam

          void setCameraParam(CameraParam cameraParam)

      Sets camera parameters during preview.
      Parameters:
        `cameraParam` -
      See Also:
        `CameraParam`

    - #### switchCamera

          int switchCamera()

      Switches cameras.
      Returns:
        The id of the camera that is currently in use.

    - #### switchLight

          FlashType switchLight()

      Switches flash modes.
      Returns:
        The current flash mode.
      See Also:
        `FlashType.AUTO`, `FlashType.OFF`, `FlashType.ON`

    - #### setLight

          boolean setLight(FlashType flashType)

      Sets the flash mode.
      Parameters:
        `flashType` -
      Returns:
        true if the invocation is successful or false if the invocation fails.

    - #### setZoom

          int setZoom(float rate)

      Sets the zoom level.
      Parameters:
        `rate` -

    - #### setExposureCompensationRatio

          int setExposureCompensationRatio(float value)

      Sets the exposure level.
      Parameters:
        `value` -

    - #### setFocusMode

          void setFocusMode(int mode)

      Sets the focus mode.
      Parameters:
        `mode` -
      See Also:
        `CameraParam.FOCUS_MODE_CONTINUE`, `CameraParam.FOCUS_MODE_AUTO`

    - #### setFocus

          @Deprecated
          void setFocus(Point point)

      Deprecated.
      Deprecated. Replaced by `setFocus(float xRatio, float yRatio)` Sets the focus point.
      Parameters:
        `point` -

    - #### setFocus

          void setFocus(float xRatio,
                        float yRatio)

      Sets the focus point. This setting only takes effect when the input parameter of `setFocusMode(int)` is set to `CameraParam.FOCUS_MODE_AUTO`.
      Parameters:
        `xRatio` - The x coordinate of the focus point relative to the surface view.
        `yRatio` - The y coordinate of the focus point relative to the surface view.

    - #### getBeautyLevel

          int getBeautyLevel()

      Gets the beauty level.
      Returns:
        The current beauty level.

    - #### setBeautyLevel

          void setBeautyLevel(int level)

      Sets the beauty level.
      Parameters:
        `level` - Valid values: [0, 100]. A value of 0 indicates disable beauty mode.

    - #### setBeautyStatus

          void setBeautyStatus(boolean on)

      Enables or disables beauty mode.
      Parameters:
        `on` - A value of true indicates enable beauty mode. A value of false indicates disable beauty mode.

    - #### setEffectView

          int setEffectView(float xRatio,
                            float yRatio,
                            float widthRatio,
                            float heightRatio,
                            EffectBase effectBase)

      Sets sticker parameters, such as the position and size of the sticker. The size of the sticker must be proportional to the video resolution.
      Parameters:
        `xRatio` - The x coordinate of the sticker relative to the video resolution.
        `yRatio` - The y coordinate of the sticker relative to the video resolution.
        `widthRatio` - The width of the sticker relative to the video resolution.
        `heightRatio` - The height of the sticker relative to the video resolution.
        `effectBase` - The sticker.

    - #### setOnFrameCallback

          void setOnFrameCallback(OnFrameCallback callback)

      Sets the callback that outputs frame data.
      Parameters:
        `callback` -
      See Also:
        `OnFrameCallback`

    - #### setOnChoosePictureSizeCallBack

          void setOnChoosePictureSizeCallBack(OnChoosePictureSizeCallback callback)

      Sets the callback that outputs the image resolution.
      Parameters:
        `callback` -

    - #### setFaces

          int setFaces(float[][] faces)

      Sets the coordinate points to define faces. Each element of the 2D array indicates the six features of a face.
      Parameters:
        `faces` - Represented by a 2D array of size N*6. point[i][0] => LEFT_EYE_X point[i][1] => LEFT_EYE_Y point[i][2] => RIGHT_EYE_X point[i][3] => RIGHT_EYE_Y point[i][4] => MOUTH_X point[i][5] => MOUTH_Y The above example defines the six features of face i.
      Returns:

    - #### setRotation

          void setRotation(int rotation)

      Sets the rotation angle of the gyro sensor. If the original angle is not one of the following values: 0, 90, 180, and 270, use the following method to determine the rotation angle.

               private int getSensorRotation() {
               int orientation = orientationDetector.getOrientation();
               int rotation = 90;
               if (orientation >= 45 && orientation < 135) {
               rotation = 180;
               }
               if (orientation >= 135 && orientation < 225) {
               rotation = 270;
               }
               if (orientation >= 225 && orientation < 315) {
               rotation = 0;
               }
               if (mCameraType == CameraType.FRONT) {
               if (rotation != 0) {
               rotation = 360 - rotation;
               }
               }
               return rotation;
               }

      Parameters:
        `rotation` - Do not use this method to control the angle when performing facial recognition or recording.
      See Also:
        `setFaceDetectRotation(int)`, `setRecordRotation(int)`

    - #### setFaceDetectRotation

          void setFaceDetectRotation(int rotation)

      Sets the rotation angle of the gyro sensor when performing facial recognition. Do not use this method together with setRotation.
      See Also:
        `setRecordRotation(int)`, `setRotation(int)`

    - #### setRecordRotation

          void setRecordRotation(int rotation)

      Sets the rotation angle of the gyro sensor during recording. Do not use this method together with setRotation. Use the following method to determine the rotation angle. if (rotation == 90 || rotation == 270) { rotation = (rotation + 90) % 360; if (mAliyunCamera.getCameraInfo().facing == CameraInfo.CAMERA_FACING_BACK) { rotation += 180; rotation %= 360; } } else if (rotation == 0 || rotation == 180) { rotation = (rotation + 270) % 360; }
      See Also:
        `setRotation(int)`, `setFaceDetectRotation(int)`

    - #### setOnTextureIdCallback

          void setOnTextureIdCallback(OnTextureIdCallback callback)

      Sets the callback that outputs the texture on every frame.
      Parameters:
        `callback` -
      See Also:
        `OnTextureIdCallback`

    - #### setOnFaceDetectInfoListener

          void setOnFaceDetectInfoListener(OnFaceDetectInfoListener listener)

      Sets the callback that outputs facial recognition data. `OnFaceDetectInfoListener.onFaceInfoChange(FaceDetectInfo)` is invoked when changes in facial recognition data are detected.
      Parameters:
        `listener` -

    - #### getCurrentExposureCompensationRatio

          float getCurrentExposureCompensationRatio()

      Gets the current exposure level.
      Returns:
        The current exposure level.

    - #### takePhoto

          void takePhoto(boolean needBitmap,
                         OnPictureCallback pictureCallback)

      Takes a picture by system camera, no effects. This is an asynchronous method, call `OnPictureCallback#onPicture(byte[])` to return byte array data, call `OnPictureCallback.onPicture(Bitmap)` to return the bitmap if need.
      Parameters:
        `needBitmap` - Whether to generate a bitmap image.
        `pictureCallback` - Callback to return data

    - #### snapshot

          void snapshot(boolean needBitmap,
                        OnPictureCallback pictureCallback)

      Camera preview snapshot, include effects. This is an asynchronous method, call `OnPictureCallback#onPicture(byte[])` to return byte array data, call `OnPictureCallback.onPicture(Bitmap)` to return the bitmap if need.
      Parameters:
        `needBitmap` - Whether to generate a bitmap image.
        `pictureCallback` - Callback to return data

    - #### needFaceTrackInternal

          void needFaceTrackInternal(boolean need)

      Sets whether to enable facial recognition.
      Parameters:
        `need` -

    - #### setFaceTrackInternalModelPath

          int setFaceTrackInternalModelPath(java.lang.String path)

      Sets the path to facial recognition models. The path to facial recognition models is required as the input parameter.
      Parameters:
        `path` -
      Returns:
        `AliyunErrorCode.OK` if the invocation is successful. `AliyunErrorCode.ERROR_INVALID_ARGUMENTS` if the invocation fails, the path is invalid, or the model files are damaged.

    - #### setFaceTrackInternalMaxFaceCount

          void setFaceTrackInternalMaxFaceCount(int maxFaceCount)

      Sets the maximum number of faces that can be recognized at the same time. Maximum value: 3.
      Parameters:
        `maxFaceCount` -

    - #### setShutterSound

          void setShutterSound(boolean bNeedShutterSound)

      Sets whether to turn on the shutter sound.
      Parameters:
        `bNeedShutterSound` - true indicates turn on the shutter sound. false indicates turn off the shutter sound. Default value: true.

    - #### setAutoPreviewAfterTakePhoto

          void setAutoPreviewAfterTakePhoto(boolean autoPreviewAfterTakePhoto)

      Sets whether to start preview after taking a picture.
      Parameters:
        `autoPreviewAfterTakePhoto` - true indicates start preview. false indicates load the newly taken picture on the screen. Default value: true.
      See Also:
        `takePhoto(boolean, OnPictureCallback)`

    - #### getSupportedPictureSize

          java.util.List<Camera.Size> getSupportedPictureSize()

      Gets the picture sizes supported by the camera.
      Returns:
        The picture sizes represented as a list.

    - #### getSupportedPictureSizes

          java.util.SortedSet<Size> getSupportedPictureSizes()

    - #### setPictureSize

          int setPictureSize(int width,
                             int height)

      Sets the picture size.
      Parameters:
        `width` -
        `height` -
      Returns:
        A status code that indicates whether the invocation is successful.

    - #### startPreviewAfterTakePicture

          int startPreviewAfterTakePicture()

      Use this method to start preview after taking a picture. To set whether to start preview after taking a picture `setAutoPreviewAfterTakePhoto(boolean)`

    - #### resizePreviewSize

          int resizePreviewSize(int width,
                                int height)

      Sets the size of the surface view.
      Parameters:
        `width` - The width of the surface view.
        `height` - The height of the surface view.
      Returns:

    - #### setOutputFlip

          void setOutputFlip(boolean flip)

      Use this method to flip the camera recording output.
      Parameters:
        `flip` - is need flip