Queen SDK is a smart retouching SDK developed by the video cloud team of Alibaba. This SDK provides a wide range of features including image retouching, face retouching, chroma key, stickers, makeup, gesture recognition, body shaping, hairdressing, and augmented reality (AR) writing. You can use these features in live streaming, video conferencing, and short video production scenarios. This topic describes how to integrate Queen SDK for Android to help you implement retouching features.
Prerequisites
A development environment is set up. The following table describes the requirements for the development environment.
Item | Description |
Android | Android 4.3 or later. |
Java | Java 1.7 or later. |
API LEVEL | Android API level 18 or later. |
Android Studio | Android Studio 2.3 or later. To download Android Studio, visit Android Studio. |
Integration guide
(Recommended) Integrate the SDK by using Maven dependencies
Add the Alibaba Cloud Maven repository to the build.gradle file of your project.
allprojects { repositories { google() jcenter() maven { url "https://maven.aliyun.com/repository/releases" } } }
Add Queen SDK dependencies to the build.gradle file of your application.
// The Queen SDK package. implementation "com.aliyun.maliang.android:queen:6.8.1-official-pro" // Optional. The menu component of Queen SDK. implementation "com.aliyun.maliang.android:queen_menu:6.8.1-official-pro-tiny" // Download the menu resources. implementation "com.aliyun.maliang.android:queen_menu:6.8.1-official-pro" // Package the menu resources on your on-premises machine.
The libraries of retouching features and the libraries of Alibaba Cloud SDKs such as Alibaba Cloud Real-Time Communication (RTC) SDK may contain duplicate files. As a result, your application may fail to be packaged. In this case, add the packagingOptions parameter to the build.gradle file of your project to avoid file conflicts, as shown in the following code. If no duplicate files exist, you do not need to add this parameter.
android {
...
compileSdkVersion ...
...
packagingOptions {
pickFirst '**/libMNN.so' // If duplicate libMNN.so files exist, add this line of code.
pickFirst '**/libMNN_CL.so' // If duplicate libMNN_CL.so files exist, add this line of code.
pickFirst '**/libc++_shared.so' // If duplicate libc++_shared.so files exist, add this line of code.
}
...
}
Manually integrate the SDK
Download and decompress the Queen SDK package.
Copy the .aar files extracted from the SDK package to the libs folder of your project.
Add the dependencies on the AAR package by using Gradle.
dependencies { implementation fileTree(include: ['*.aar'], dir: 'libs') }
Add the following dependencies to the code:
dependencies { implementation files('libs/alivc-livepusher-lib-release.aar') }
Click Sync Now to compile the project.
Configure permissions
You must configure the application permissions in the AndroidManifest.xml file in advance. To integrate Queen SQK for Android, the following permissions are required:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
Permissions need to be requested at runtime in Android 6.0 or later. The following sample code shows how to configure the permissions:
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
// You have obtained the permission.
//...
} else {
// You do not have this permission. Apply for it.
// PERMISSION_REQUEST_CODE specifies the code of the application for the permission. You can set the code to an arbitrary number.
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, PERMISSION_REQUEST_CODE);
}
Configure the license
Make sure that you have obtained a license for Queen SDK in advance. For more information, see Obtain a license of Queen SDK. After you obtain a license, perform the following operations to configure the license key and license file in your project:
If you integrate Queen SDK of ApsaraVideo Live and the short video SDK of ApsaraVideo VOD at the same time, the two SDKs use the same license key and license file. You need to configure the license only once. Take note that the latest license file must be used.
If the SDK that you purchase is updated or needs to be renewed, you must also update the license. Perform the following steps to update the license:
Obtain the latest license. For more information, see Obtain a license of Queen SDK.
After you obtain the latest license, configure the license again.
Import the license to the assets folder of your project, and then add two meta-data
entries under the application
node in the AndroidManifest.xml
file. The following sample code provides an example:
com.aliyun.alivc_license.licensekey
is the metadata entry that specifies the license key.
<application
android:icon="@drawable/icon"
android:label="@string/app_name" >
<meta-data
android:name="com.aliyun.alivc_license.licensekey"
android:value="Your LicenseKey"/> // Enter the license key that you obtain.
<meta-data
android:name="com.aliyun.alivc_license.licensefile"
android:value="Your LicenseFile Path"/> // Enter the path of the license file relative to the assets folder. Example: alivc_license/AliVideoCert.crt.
...
</application>
References
Item | References |
Sample project | The sample project contains the complete code for SDK integration and the assets folder contains all the image resources of the demo. |
Quick start | The quick start package improves the efficiency of integrating Queen SDK. The quick start package provides a detailed description of the integration and also provides guidance to help you troubleshoot common issues. |
Code for integration with SDKs from common vendors |