Unlock the Power of AI

1 million free tokens

88% Price Reduction

Activate Now

Features

Updated at: 2025-01-16 03:15

This topic provides examples on how to use Queen SDK for Android.

Usage notes

  • If you update Queen SDK from V1.X.X to V2.0.0 or later, take note of the following items:

    • The package name of the Java API is changed from com.taobao.android.libqueen to com.aliyun.android.libqueen.

    • You must re-submit a request on the Create Application and Bind License page to request a license key and license file, and specify Request_License_File in the title. After your request is received, Alibaba Cloud will send you the license key and file within two business days. If you want to create an application and apply for a license for Queen SDK, log on to the ApsaraVideo Live or ApsaraVideo VOD console. In the left-side navigation pane, choose SDK Management > My Licenses. Then, click Create Application and Bind License.

  • For more information about how to integrate Queen SDK for Android, see References.

  • For answers to frequently asked questions, see FAQ about Queen SDK.

About resource download

Important
  1. The built-in resource download service provided by Queen SDK is a temporary service whose accessibility and effectiveness cannot be guaranteed. It is used for demonstrations only and cannot be directly used in commercial applications.

  2. If you need to launch your business online and download resources in your business, use your own server to provide these resources. Alibaba Cloud does not provide resource download or help you manage such service.

Specify custom resource URLs

  1. Use the following code when queen_menu is used:

    // Set the download address of each resource. This is important. QueenMaterial is a static singleton, which must be set before menu components are initialized.
    // Set the MaterialType parameter. Valid values: MODEL, STICKER, LUT, MAKEUP, BACKGROUND, and FACE_EFFECTS.
    // materialUrl is the URL from which you can download the corresponding resource package. You must compress the resource package into a ZIP file and place the file in the root directory. The system automatically scans and loads the resources in the decompressed folder.
    QueenMaterial.getInstance().setMaterialUrl(MaterialType materialType, String materialUrl);
  2. Modify the following code to suit your business needs:

    // Step 1: Initialize an instance of a class that handles resource download.
    QueenMaterial.getInstance().init(context);
    
    // Step 2: Set the download address of each resource. This is important. Set it before requestMaterial, preferably immediately after init.
    // Set the MaterialType parameter. Valid values: MODEL, STICKER, LUT, MAKEUP, BACKGROUND, and FACE_EFFECTS.
    // materialUrl is the URL from which you can download the corresponding resource package. You must compress the resource package into a ZIP file and place the file in the root directory. The system automatically scans and loads the resources in the decompressed folder.
    QueenMaterial.getInstance().setMaterialUrl(MaterialType materialType, String materialUrl);
    
    
    // Step 3: Set a resource download listener. After the download is complete (onReady callback fired), you can use resources by resource type. The SDK will concatenate the local path. 
    QueenMaterial.getInstance().setCallback(new QueenMaterial.OnMaterialCallback() {
    
        @Override
        public void onReady(QueenMaterial.MaterialType materialType) {
            // The callback for the completion of resource download is invoked in a non-UI thread. In most cases, the loading box is closed and the business logic is triggered.
    
            // Configure the sticker settings.
            String stickerName = "1"; // The relative path of the sticker.
            String stickerPath = QueenMaterial.getInstance().getMaterialPath(QueenMaterial.MaterialType.STICKER) + File.separator + stickerName;
            // Add the sticker to the QueenEngine.
            engine.addMaterial(stickerResPath);
        }
    
        @Override
        public void onProgress(QueenMaterial.MaterialType materialType, int currentSize, int totalSize, float progress) {
            // The callback for the progress of resource download is invoked in a non-UI thread. In most cases, the download progress is updated.
        }
    
        @Override
        public void onError(QueenMaterial.MaterialType materialType) {
            // The callback for a resource download error is invoked in a non-UI thread. In most cases, the loading box is closed and a message is displayed, prompting you to check the network and disk space.
        }
    
    });
    
    // Step 4: Request the download. When you customize a menu widget, you must request the download.
    QueenMaterial.getInstance().requestMaterial(MaterialType materialType);

Integrate the SDK for basic retouching

  1. Create a QueenEngine instance. Specify the texture and view parameters for initialization.

    QueenEngine engine;
    try {
        com.aliyun.android.libqueen.QueenConfig config = new com.aliyun.android.libqueen.QueenConfig();
        // A value of true specifies that the output is returned to the display area of Open Graphics Library (OpenGL). Default value: false.
        config.toScreen = false;
        // A value of true specifies that log debugging is enabled. Default value: false. We recommend that you enable log debugging only in the Debug package to prevent performance degradation.
        config.enableDebugLog = false;
        // A value of true specifies that an OpenGL context must be created for the QueenEngine instance. Default value: false.
        config.withContext = false;
        // A value of true specifies that a separate thread must be created. Default value: false.
        config.withNewGlThread = false;
        if (withContext || withNewGlThread) {
            // If you want to create an OpenGL context in a separate thread for the QueenEngine instance and share the OpenGL context of the current thread, configure the current OpenGL context.
            if (Build.VERSION.SDK_INT >= 21) {
              config.shareGlContext = EGL14.eglGetCurrentContext().getNativeHandle();
            } else {
              config.shareGlContext = EGL14.eglGetCurrentContext().getHandle();
            }
        }
        // Initialize the QueenEngine instance by passing the Android.content.Context object.
        // The second parameter is used to configure the created instance.
        engine = new QueenEngine(mContext, config);
    } catch (InitializationException e) {
        e.printStackTrace();
    }
    
    // Specify the input texture that is used for rendering during retouching.
    // The fourth parameter specifies whether the type of the input texture is OES.
    engine.setInputTexture(textureId, textureWidth, textureHeight, true);
    
    // Optional. Obtain the output texture of retouching, which can be used for other services. If you want to return the output texture in the same direction as the input texture, set the keepInputDirection parameter to true for the engine.autoGenOutTexture and engine.updateOutTexture methods.
    Texture2D outTexture = engine.autoGenOutTexture(true);
    
    // Set the size of the view.
    engine.setScreenViewport(0, 0, viewWidth, viewHeight);
    // Enable the log display and debugging mode. We recommend that you enable log debugging only in the Debug package to prevent performance degradation.
    engine.enableDebugLog();
  2. Specify the parameters for basic retouching.

    // Specify whether to enable skin whitening.
    engine.enableBeautyType(BeautyFilterType.kSkinWhiting, true);
    // Set the level of skin whitening. Valid values: 0 to 1.
    engine.setBeautyParam(
        BeautyParams.kBPSkinWhitening, 
        0.3f
    );
    /**
    * Specify whether to enable skin smoothing and image sharpening. 
    * The third parameter specifies the basic retouching mode. If you set this parameter to kBMSkinBuffing_Natural, retouching effects are more natural and more details are retained. If you set this parameter to kBMSkinBuffing_Strong, retouching effects are more exaggerated and more details are removed. 
    */
    engine.enableBeautyType(BeautyFilterType.kSkinBuffing, true, BeautyFilterMode.kBMSkinBuffing_Natural);
    // Set the level of skin smoothing. Valid values: 0 to 1.
    engine.setBeautyParam(BeautyParams.kBPSkinBuffing, 0.6f);
    // Set the level of image sharpening. Valid values: 0 to 1.
    engine.setBeautyParam(BeautyParams.kBPSkinSharpen, 0.2f);
  3. Perform rendering.

    // The transformation matrix of the OES texture. This value can be obtained by using the SurfaceTexture class.
    // The SurfaceTexture class is a core component for rendering that can render the texture.
    float[] transformMatrix = new float[16];
    // Use the SurfaceTexture class to update the transformation matrix.
    mSurfaceTexture.updateTexImage();
    mSurfaceTexture.getTransformMatrix(transformMatrix);
    
    // Render the texture to the current view. If certificate authentication fails or all effects are disabled, Queen SDK does not render the texture.
    int retCode = engine.renderTexture(transformMatrix);
    
    // For more information, see SDK references.
    // QUEEN_INVALID_LICENSE(-9) indicates that certificate authentication fails.
    // QUEEN_NO_EFFECT(-10) indicates that all effects are disabled.
    // In this case, you must manually render the texture. For more information, see the sample project that is provided in the "References" section of the "Integrate Queen SDK for Android" topic.
    if (retCode == -9 || retCode == -10) {
        mFrameGlDrawer.draw(transformMatrix, mOESTextureId, true);
    }
  4. Release the engine.

    // Release the engine.
    engine.release();

Advanced features

If you use advanced features, such as advanced retouching, face shaping, body shaping, makeup, filters, and stickers, you must call the updateInputTextureBufferAndRunAlg method.

if (mUseTextureBuffer) { // Use the texture data to run the algorithm.
  engine.updateInputTextureBufferAndRunAlg(
      mCamera.inputAngle, mCamera.outAngle,
      mCamera.flipAxis, false);
} else {
  // Specify the parameters for the input frame image stream.
  engine.updateInputDataAndRunAlg(
    imageData, // The frame image stream.
    ImageFormat.NV21, // The format of the frame image stream.
    imageWidth, // The width of the frame images.
    imageHeight, // The height of the frame images.
    0, // This parameter is used to detect the image stride, which specifies the number of bytes in each row. Default value: 0. Unit: pixel.
    mCamera.inputAngle, // The rotation angle of the input frame images. For information about the formula, see the sample project that is provided in the "References" section of the "Integrate Queen SDK for Android" topic.
    mCamera.outAngle, // The rotation angle of the output frame images. For information about the formula, see the sample project that is provided in the "References" section of the "Integrate Queen SDK for Android" topic.
    mCamera.flipAxis // Specifies whether and how to rotate the output frame images. A value of 0 specifies that the output frame images are not rotated. A value of 1 specifies that the output frame images are rotated along the x-axis. A value of 2 specifies that the output frame images are rotated along the y-axis.
  );
}

Advanced retouching

// Specify whether to enable advanced retouching.
engine.enableBeautyType(BeautyFilterType.kFaceBuffing, true);
// Set the level of smile line removal. Valid values: [0,1].
engine.setBeautyParam(BeautyParams.kBPNasolabialFolds, 0.3f); 
// Set the level of eye-bag removal. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPPouch, 0.3f); 
// Set the level of teeth whitening. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPWhiteTeeth, 0.2f); 
// Set the level of lipstick effects. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPLipstick, 0.2f); 
// Set the level of blush effects. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPBlush, 0.2f);
// Set the level of eye brightening. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPBrightenEye, 1.0f);
// Set the level of rosy cheeks. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPBlush, 1.0f);
// Set the lipstick color. Valid values: -0.5 to 0.5. You must set the color, saturation, and brightness together. You can set this parameter to -0.125 for ochre, -0.1 for pink, 0.0 for vintage red, -0.2 for magenta, -0.08 for true red, 0.0 for orange red, -0.42 for purple, 0.125 for orange, and 0.25 for yellow.
engine.setBeautyParam(BeautyParams.kBPLipstickColorParam, 0.0f);
// Set the saturation of lipstick. Valid values: 0 to 1. You must set the color, saturation, and brightness together. You can set this parameter to 0.25 for ochre, 0.125 for pink, 1.0 for vintage red, 0.35 for magenta, 1.0 for true red, 0.35 for orange red, 0.35 for purple, 0.25 for orange, and 0.45 for yellow.
engine.setBeautyParam(BeautyParams.kBPLipstickGlossParam, 0.0f);
// Set the brightness of lipstick. Valid values: 0 to 1. You must set the color, saturation, and brightness together. You can set this parameter to 0.4 for ochre, 0.0 for pink, 0.2 for vintage red, 0.0 for magenta, 0.0 for true red, 0.0 for orange red, 0.0 for purple, 0.0 for orange, and 0.0 for yellow.
engine.setBeautyParam(BeautyParams.kBPLipstickBrightnessParam, 1.0f);
// Set the level of wrinkle removal. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPWrinkles, 0.2f);
// Set the level of skin brightening. Valid values: 0 to 1.
engine.setBeautyParam(BeautyParams.kBPBrightenFace, 0.2f);
// Enable the hue, saturation, and value (HSV) color model.
engine.enableBeautyType(BeautyFilterType.kHSV,true);
// Set the level of saturation. Valid values: [-1,1].
engine.setBeautyParam(BeautyParams.kBPHSV_SATURATION,0.2f);
// Set the level of contrast. Valid values: [-1,1].
engine.setBeautyParam(BeautyParams.kBPHSV_CONTRAST,0.2f);

Face effects

// Configure the pixelation effect.
engine.enableBeautyType(BeautyFilterType.kBTEffectMosaicing,true);
engine.setBeautyParam(BeautyParams.kBPEffects_Mosaicing,0.45f);

Face shaping

/**
 * Specify whether to enable face shaping. The second parameter specifies whether to enable face shaping. The third parameter specifies whether to enable debugging.
 * The fourth parameter specifies the face shaping mode. Valid values: kBMFaceShape_Baseline, kBMFaceShape_Main, kBMFaceShape_High, and kBMFaceShape_Max, with the deformation level increased in sequence.
 */
engine.enableBeautyType(BeautyFilterType.kFaceShape, true, false, BeautyFilterMode.kBMFaceShape_Main);
/**
 * Face shaping: cheekbones
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeCutCheek, 0.0f);
/**
 * Face shaping: cheekbone narrowing
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeCutFace, 0.0f);
/**
 * Face shaping: face slimming
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeThinFace, 0.0f);
/**
 * Face shaping: face length
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeLongFace, 0.0f);
/**
 * Face shaping: chin shortening
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeLowerJaw, 0.0f);
/**
 * Face shaping: chin lengthening
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeHigherJaw, 0.0f);
/**
 * Face shaping: chin slimming
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeThinJaw, 0.0f);
/**
 * Face shaping: jaw slimming
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeThinMandible, 0.0f);
/**
 * Face shaping: big eyes
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeBigEye, 0.0f);
/**
 * Face shaping: canthus shaping 1
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeEyeAngle1, 0.0f);
/**
 * Face shaping: eye distance
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeCanthus, 0.0f);
/**
 * Face shaping: eye distance increase
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeCanthus1, 0.0f);
/**
 * Face shaping: canthus shaping 2
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeEyeAngle2, 0.0f);
/**
 * Face shaping: eye height
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeEyeTDAngle, 0.0f);
/**
 * Face shaping: nose slimming
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeThinNose, 0.0f);
/**
 * Face shaping: nasal alar slimming
 * Valid values: 0 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeNosewing, 0.0f);
/**
 * Face shaping: nose length
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeNasalHeight, 0.0f);
/**
 * Face shaping: length of the nose tip
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeNoseTipHeight, 0.0f);
/**
 * Face shaping: lip width
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeMouthWidth, 0.0f);
/**
 * Face shaping: lip size
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeMouthSize, 0.0f);
/**
 * Face shaping: lip height
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeMouthHigh, 0.0f);
/**
 * Face shaping: philtrum
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typePhiltrum, 0.0f);
/**
 * Face shaping: hairline
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeHairLine, 0.0f);
/**
 * Face shaping: smiling
 * Valid values: -1 to 1.
 */
engine.updateFaceShape(FaceShapeType.typeSmile, 0.0f);

Body shaping

/**
* Specify whether to enable body shaping. The second parameter specifies whether to enable body shaping. The third parameter specifies whether to enable debugging. */
engine.enableBeautyType(BeautyFilterType.kBodyShape, true, false);
/**
* Body shaping: whole body
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kFullBody, 1.0f);
/**
* Body shaping: small head
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kSmallHead, 1.0f);
/**
* Body shaping: thin legs
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kThinLeg, 1.0f);
/**
* Body shaping: long legs
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kLongLeg, 1.0f);
/**
* Body shaping: neck
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kLongNeck, 1.0f);
/**
* Body shaping: slim waist
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kThinWaist, 1.0f);
/**
* Body shaping: breast enlarging
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kEnhanceBreast, 1.0f);
/**
* Body shaping: arms
* Valid values: -1 to 1.
*/
engine.updateBodyShape(BodyShapeType.kThinArm, 1.0f);

Makeup

Enable makeup

// The second parameter specifies whether to enable makeup. The third parameter specifies whether to enable debugging.
// The fourth parameter specifies the makeup mode. This parameter takes effect only on eyebrows. If you set this parameter to BeautyFilterMode.kBMFaceMakeup_High, the deformation level of eyebrows is high. If you set this parameter to BeautyFilterMode.kBMFaceMakeup_Baseline, the deformation level of eyebrows is low.
engine.enableBeautyType(BeautyFilterType.kMakeup, true, false, BeautyFilterMode.kBMFaceMakeup_Baseline);

// Specify the parameters for makeup materials.
// The first parameter specifies the makeup type.
// The second parameter specifies the paths of makeup materials. You can specify a path relative to the assets folder, such as /makeup/peach makeup.png, or an absolute path on which you have access permissions.
// The third parameter specifies how the makeup materials are applied to faces. The fourth parameter is reserved.
engine.setMakeupImage(MakeupType.kMakeupBlush,
           new String[]{""},  
           BlendType.kBlendCurve, 15);
/**
* A value of kMakeupWhole specifies the full face makeup type. You can use a single makeup material to apply makeup to the entire face but cannot adjust the details of each part of the face. 
* If your SDK version is later than V1.4.0, we recommend that you use mixed makeup. Mixed makeup allows you to adjust the details of each part of the face. The following types of mixed makeup are provided:
* 1. Tipsy makeup:
*   For eye shadow, the path is makeup/eyeshadow/naichazong.2.31.png and the transparency is 0.7. 
*   For eyelashes, the path is makeup/eyelash/yesheng.2.31.png and the transparency is 0.5. 
*   For blush, the path is makeup/blush/weixun.2.31.png and the transparency is 0.8. 
*   For eyeliner, the path is makeup/eyeliner_292929/wenrou.2.31.png and the transparency is 0.5. 
*   For lipstick, the path is makeup/mouth_wumian/standout.2.31.png and the transparency is 0.5. 
*   For highlight, the path is makeup/highlight/highlight.2.12.png and the transparency is 0.4.
* 2. Freckle makeup:
*   For eye shadow, the path is makeup/eyeshadow/taohuafen.2.31.png and the transparency is 0.7. 
*   For eyelashes, the path is makeup/eyelash/yesheng.2.31.png and the transparency is 0.5. 
*   For blush, the path is makeup/blush/cool.2.31.png and the transparency is 0.8. 
*   For eyeliner, the path is makeup/eyeliner_292929/guima.2.31.png and the transparency is 0.5. 
*   For lipstick, the path is makeup/mouth_yaochun/nanguase.2.31.png and the transparency is 0.5. 
*   For highlight, the path is makeup/highlight/highlight.2.12.png and the transparency is 0.4.
* 3. Lively makeup:
*   For eye shadow, the path is makeup/eyeshadow/tianchengse.2.31.png and the transparency is 0.7. 
*   For eyelashes, the path is makeup/eyelash/lingdong.2.31.png and the transparency is 0.5. 
*   For blush, the path is makeup/blush/luori.2.31.png and the transparency is 0.8. 
*   For eyeliner, the path is makeup/eyeliner_292929/qizhi.2.31.png and the transparency is 0.5. 
*   For lipstick, the path is makeup/mouth_yaochun/nanguase.2.31.png and the transparency is 0.5. 
*   For highlight, the path is makeup/highlight/highlight.2.12.png and the transparency is 0.4.
* 4. Nightclub makeup:
*   For eye shadow, the path is makeup/eyeshadow/yeqiangwei.2.31.png and the transparency is 0.7. 
*   For eyelashes, the path is makeup/eyelash/zhixing.2.31.png and the transparency is 0.5. 
*   For blush, the path is makeup/blush/shaonv.2.31.png and the transparency is 0.8. 
*   For eyeliner, the path is makeup/eyeliner_292929/wenrou.2.31.png and the transparency is 0.5. 
*   For lipstick, the path is makeup/mouth_zirun/zhenggongse.2.31.png and the transparency is 0.5. 
*   For highlight, the path is makeup/highlight/highlight.2.12.png and the transparency is 0.4.
**/

// Set the transparency for the makeup material.
// The second parameter specifies the transparency of the material. The third parameter is reserved.
engine.setMakeupAlpha(MakeupType.kMakeupBlush, 0.6f, 0.3f);

Disable makeup

engine.setMakeupImage(MakeupType.kMakeupBlush, new String[], BlendType.kBlendNormal, 15);

Enable the aegyo-sal effect

// The second parameter specifies whether to enable the aegyo-sal effect. The third parameter specifies whether to enable debugging.
engine.enableBeautyType(BeautyFilterType.kMakeup, true, false);

engine.setMakeupImage(MakeupType.kMakeupWocan,
                      new String[]{""},   // Only built-in materials for the aegyo-sal effect are used.  
                      BlendType.kBlendCurve, 15);

engine.setMakeupAlpha(MakeupType.kMakeupWocan, 0.6f, 0.3f);

Disable the aegyo-sal effect

engine.setMakeupImage(MakeupType.kMakeupWocan, new String[], BlendType.kBlendCurve, 15);

Hair color

engine.enableBeautyType(BeautyFilterType.kHairColor, true);
/**
 * Hair colors are represented by red, green, and blue (RGB) values, which are floating-point numbers.
 * Sample colors:
 *   Blue: [0.3137f, 0.3137f, 0.6275f]
 *   Purple: [0.6078f, 0.3529f, 0.6275f]
 *   Sky blue: [0.3333f, 0.5492f, 0.5491f]
 *   Yellow: [0.6471f, 0.5294f, 0.3529f]
 *   Green: [0.3725f, 0.5882f, 0.3137f]
 *   Brown: [0.3922f, 0.3333f, 0.3137f]
 *   Red: [0.5098f, 0.2745f, 0.2745f]
 */
engine.setHairColor(
  getQueenParam().hairRecord.colorRed,
  getQueenParam().hairRecord.colorGreen,
  getQueenParam().hairRecord.colorBlue);

Filters

// Specify whether to enable filters.
engine.enableBeautyType(BeautyFilterType.kLUT, true);
// Specify the filter that you want to use. You can specify a path relative to the assets folder, such as /lookups/lookup_1.png, or an absolute path on which you have access permissions.
engine.setFilter(lutResPath); 
// Set the level of the filter.
engine.setBeautyParam(BeautyParams.kBPLUT, 1.0f); 

Stickers

// Remove a sticker from the specified path.
engine.removeMaterial(oldStickerResPath);
// Add a sticker to the specified path. After a sticker is added, you cannot add it again.
// The path of the sticker can be a path relative to the assets folder, such as /sticker/baiyang, or an absolute path on which you have access permissions.
engine.addMaterial(stickerResPath);

Chroma key

/**
 * Specify the parameters for chroma key.
 * @param backgroundPath The path of the background image that you want to replace. If the value is "", chroma key is disabled.
 * @param blueScreenEnabled Specifies whether to use the blue screen. A value of true specifies that the blue screen is used. A value of false specifies that the green screen is used.
 * @param threshold Valid values: 20 to 60. Default value: 30. We recommend that you use the default value.    
 */
engine.setGreenScreen(String backgroundPath, boolean blueScreenEnabled, float threshold);

Background replacement

// Before you enable background replacement, you can specify the performance mode based on your business requirements. The supported performance modes include Auto Mode, Best Quality Mode, Balance Mode, and Best Performance Mode. If you do not specify this parameter, Auto Mode is used by default.
engine.setSegmentPerformanceMode(SegmentPerformanceMode.Auto);
// Remove a background image from the specified path.
engine.removeMaterial(oldBackgroundResPath);
// Add a background image to the specified path. After a background image is added, you cannot add it again.
// The path of the background image can be a path relative to the assets folder, such as /static/xiaomanyao, or an absolute path on which you have access permissions.
engine.addMaterial(backgroundResPath);
// In addition to background replacement, you can also enable background bokeh.
engine.enableBeautyType(BeautyFilterType.kBTBackgroundProcess, true);
// After you enable background bokeh, the background is blurred by default. You can use the following method to set a transparent background. This is suitable for scenarios in which the output is used as a foreground and the background is synthesized.
engine.setSegmentBackgroundProcessType(BackgroundProcessType.kBackgroundTransparent);

AR writing

/**
 * The first parameter specifies whether to enable augmented reality (AR) writing.
 * The second parameter specifies the mode. A value of 1 specifies the writing mode. A value of 2 specifies the drawing mode.
 */
engine.setArWriting(true, getQueenParam().sArWritingRecord.mode);

Intelligent dynamic optimization

// Enable intelligent dynamic optimization.
engine.enableBeautyType(BeautyFilterType.kBTAutoFilter, true);
// Disable intelligent dynamic optimization.
engine.enableBeautyType(BeautyFilterType.kBTAutoFilter, false);

Gesture recognition

Register and deregister the algorithm callback.

/** Register the algorithm callback. **/
// Use the handle of the QueenEngine instance to create an algorithm instance. After you register the algorithm callback, the algorithm is run.
// The third parameter specifies the algorithm type. For more information, see the details about the AlgType class.
// The following sample code provides an example on a gesture recognition algorithm:
Algorithm algorithm = new Algorithm(engine.getEngineHandler(), "", com.taobao.android.libqueen.models.AlgType.kAAiGestureDetect);
algorithm.registerAlgCallBack(new Algorithm.OnAlgDetectListener() {
  @Override
  public int onAlgDetectFinish(int algId, Object algResult) {
    if (algResult instanceof com.taobao.android.libqueen.algorithm.GestureData) {
      // GestureData contains data about static gestures and dynamic gestures.
      com.taobao.android.libqueen.algorithm.GestureData gestureData = (com.taobao.android.libqueen.algorithm.GestureData) algResult;
    }
    return 0;
  }
});

/** Deregister the algorithm callback. **/
// If the QueenEngine instance associated with the algorithm is not destroyed, you must manually deregister the algorithm callback. If the QueenEngine instance is destroyed, the algorithm instance automatically becomes invalid. 
algorithm.unRegisterAlgCallBack();

Movement detection

Register and deregister the algorithm callback.

/** Register the algorithm callback. **/
// Use the handle of the QueenEngine instance to create an algorithm instance. After you register the algorithm callback, the algorithm is run.
// The third parameter specifies the algorithm type. For more information, see the details about the AlgType class.
// The following sample code provides an example on a movement detection algorithm:
Algorithm algorithm = new Algorithm(engine.getEngineHandler(), "", com.taobao.android.libqueen.models.AlgType.kQueenAIBodySportDetect);
algorithm.registerAlgCallBack(new Algorithm.OnAlgDetectListener() {
  @Override
  public int onAlgDetectFinish(int algId, Object algResult) {
    if (algResult instanceof BodyDetectData) {
          BodyDetectData resultData = (BodyDetectData)algResult;
          int sportType = resultData.getBodySportType();
          if (sportType <= 0) {
            // Configure posture recognition.
            int poseType = resultData.getBodyPoseType();
            sb.append("[Posture recognition]:").append(getBodyPoseName(poseType));
          } else {
            // Count the number of specific movements.
            int sportCount = resultData.getBodySportCount();
            sb.append("[Movement]:").append(getBodySportPoseName(sportType)).append("\r\n")
              .append("[Count]:").append(sportCount);
          }
        }
    return 0;
  }
});

/** Deregister the algorithm callback. **/
// If the QueenEngine instance associated with the algorithm is not destroyed, you must manually deregister the algorithm callback. If the QueenEngine instance is destroyed, the algorithm instance automatically becomes invalid. 
algorithm.unRegisterAlgCallBack();
  • On this page (1, T)
  • Usage notes
  • About resource download
  • Specify custom resource URLs
  • Integrate the SDK for basic retouching
  • Advanced features
  • Advanced retouching
  • Face effects
  • Face shaping
  • Body shaping
  • Makeup
  • Hair color
  • Filters
  • Stickers
  • Chroma key
  • Background replacement
  • AR writing
  • Intelligent dynamic optimization
  • Gesture recognition
  • Movement detection
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare