HTEffect 3D Avatar
The HTEffect 3D Avatar extension enables you to quickly and seamlessly integrate 3D portrait special effects capabilities into your app. It encapsulates the Hongtu HTAvatar core API. You call API functions by setting the appropriate extension parameters.
This page shows you how to integrate the HTEffect 3D Avatar extension into your app.
Understand the tech
You use methods provided by Video SDK to pass in appropriate key and value parameters to the extension. The key parameter corresponds exactly to the Hongtu API name, and the value wraps some or all of the API parameters in JSON format.
Prerequisites
The development environment requirements are as follows:
- Android Studio 4.1 or higher.
- Android SDK API Level 24 or higher.
- A mobile device that runs Android 4.1 or higher.
- Implemented SDK quickstart for Video Calling.
Project Setup
To implement HTEffect 3D Avatar features in your app, open the SDK quickstart for Video Calling project you created previously, and take the following steps:
-
Download the HTEffect 3D Avatar Android package.
-
Copy all the
.aarfiles from the package to the/app/libsfolder of your Android project. -
Contact Agora to obtain the HTEffect 3D Avatar resource package. Save the required model and prop files to the
/app/src/main/assetsfolder of your project. -
Open the
app/build.gradlefile, and underdependencies, add the following: -
Import the classes you need:
-
Add in the xml layout file corresponding to the Java file that uses the 3D effects:
-
In the Java file that uses 3D effects, add:
Integrate the extension
Take the following steps:
-
Enable the plugin
When initializing the
RtcEngine, callenableExtensionto enable the plug-in. -
Initialize the plugin
To initialize the plug-in, call
setExtensionPropertyand pass in the correspondingkeyandvalue. -
Set up a 3D effect
To implement a 3D effect, call
setExtensionPropertyand pass in the correspondingkeyandvalue. The specific sequence is as follows:-
Pass in the key to
htARRenderEnableto enable AR special effects. -
Pass in a key to
htARSetModelto set the AR model. For example:
You can combine multiple calls according to the needs of your scene. Please note that HTEffect 3D Avatar does not support landscape adaptation.
For the complete
keyandvaluedescriptions, refer to the Method key overview. -
Reference
This section contains content that completes the information in this page, or points you to documentation that explains other aspects to this product.
Sample project
To run the complete sample project available on Github, take the following steps:
-
Clone the sample code repository:
-
Download the Android plug-in package for HTEffect 3D Avatar. Save all
.aarfiles to theagora-htavatar-extension-demo/Android/app/libsfolder. -
Contact Agora to obtain a certificate file and the HTEffect 3D Avatar resource package.
-
Save the required model and prop files from the resource package to the
agora-htavatar-extension-demo/Android/app/src/main/assetsfolder. -
Open the project folder
agora-htavatar-extension-demo/Androidin Android Studio and sync project with Gradle files. -
Open the file
agora-htavatar-extension-demo/Android/app/src/main/java/io/agora/rte/extension/hteffectar/example/Constants.java:Replace
<YOUR_APP_ID>with your Agora app ID. You don't need to specifymTokenandmLicenseNamevalues when running the demo. -
Open the file
agora-htavatar-extension-demo/Android/app/src/main/java/io/agora/rte/extension/hteffectar/example/HtKey.java:Replace
<YOUR_HT_SDK_KEY>with the test key provided by Agora -
Connect a physical Android device and run the project.
-
Click
htARSetModeltobutton to set the 3D AR prop effect.
API reference
Interface description
When calling the setExtensionProperty (Android) or setExtensionPropertyWithVendor (iOS) method of Video SDK, the following keys and their corresponding functions are supported:
Initialization
| Key | Description |
|---|---|
| htARInitOffline | Initialization, offline authentication. |
Destroy
| Key | Description |
|---|---|
| htARReleaseBufferRenderer | Resource release function. |
Functional interface
| Key | Description |
|---|---|
| htARRenderEnable | Turn on/off the AR special effects function. |
| htARSetModel | Switch AR model function. |
| htARMirror | Set whether the image has a mirror function |
| htARImageFormat | Set image format function |
| htARRotation | Set image rotation angle function |
| htARMaxFaces | Set the maximum number of supported faces function |
| htARCopyResource | Copy the resource path to the sandbox function |
Value description of method keys
htARInitOffline
value contains the following parameters:
| value parameter | description |
|---|---|
license | String type, AR offline authentication key. |
htARReleaseBufferRenderer
value contains the following parameters:
| value parameter | description |
|---|---|
enable | BOOL type, whether to confirm the release of resources. |
htARRenderEnable
value contains the following parameters:
| value parameter | description |
|---|---|
enable | BOOL type, whether to enable the AR function. |
htARSetModel
value contains the following parameters:
| value parameter | description |
|---|---|
name | String type, the name of the model. |
htARMirror
value contains the following parameters:
| value parameter | description |
|---|---|
isMirror | BOOL type, whether to set the mirror display of prop special effects, the default is true |
htARImageFormat
value contains the following parameters:
| value parameter | description |
|---|---|
imageFormat | Int type, enumeration value of image format. For details on the specific value, see HTEARImageFormat. |
htARRotation
value contains the following parameters:
| value parameter | description |
|---|---|
rotation | Int type, enumeration value of image rotation angle. For details on the specific value, see HTEAROrientation. |
htARMaxFaces
value contains the following parameters:
| value parameter | description |
|---|---|
maxFaces | Int type, the maximum number of faces that can be supported. The value is [1, 5] |
htARCopyResource
value contains the following parameters:
| value parameter | description |
|---|---|
path | String type, the path that needs to be copied to the sandbox. |