Local Compute Avatar SDK  2.0.9
To generate Head 2.0 avatars
Main Page

Description

Local Compute Avatar SDK is a native libraries (C++) that allows to generate avatar locally on a client device. This version support Head 2.0 avatars. Internet connection is used only to log the number of avatars to the Avatar SDK cloud for billing purposes. It tries to connect to our server each time before the avatar calculation. Avatar generation fails if the connection can't be established.

Latest version is 2.0.9: Download for Windows, Download for Android, Download for IOS

Older Releases
Avatar SDK Website
Computation Parameters Description
Support email: suppo.nosp@m.rt@a.nosp@m.vatar.nosp@m.sdk..nosp@m.com

Generated Content

The library requres an input image is in the JPEG or PNG format. The output result consists of the following components:

  • Avatar's head mesh in the binary PLY or OBJ format. Windows version also supports FBX output.
  • Avatar's head texture in the JPEG format.
  • A set of blendshapes in the BIN format. The BIN file format specifies the consequent vertices for the head mesh as a floating-point values (X, Y, Z).
  • Haircuts mesh files in the binary PLY or OBJ format and the haircuts textures in the PNG format.
  • model.json file with some meta data predicted for the avatar such as: gender, race, eye color, skin color, etc.

The library works in two modes:

  • All output data is written to the local storage for future access.
  • Nothing is written to the disk, but the generated data can be access from memory by using corresponding methods. See methods description in the avatar_sdk.hpp header.

Known Issues

The License Server might be unreachable from China due to firewall restrictions.
We recommend trying version 2.0.9.2 for Windows that uses another URL to connect to the server.
If you need the same solution for other platforms, please contact us suppo.nosp@m.rt@a.nosp@m.vatar.nosp@m.sdk..nosp@m.com.

System Requirements

  • Supported platforms: Windows 64-bit, Android (arm64-v8a, armeabi-v7a), iOS 10+
  • CPU with AVX instruction set support for Window version
  • 2Gb+ of free RAM to generate Head 2.0 avatars

Package Structure

The Local Compute Avatar SDK is distributed as a ZIP archive with the following content:

  • avatar_sdk_resources directory contains binary resources required for avatar computation. These resources should be placed on the device filesystem and will be referenced from the Avatar SDK's methods.
  • docs directory with documentation.
  • include directory contains C++ headers files and souce code with samples.
  • libs directory with the dynamic libraries for all platforms.
  • samples directory with project samples for all platforms.
  • test_photo contains sample photo.

Licensing

The special license file (res_I7IFyeGGMPc=.bytes) should be placed to the avatar_sdk_resources directory along with the other resources. You can get this license file on your account page.

Code usage

The comprehensive code examples can be found in the avatar_sdk_sample.cpp source file located in the "include" directory. Also you can look at the platfrom-dependent project samples in the "samples" directory.

Library Initialization

First of all you should initialize the Avatar SDK by passing the path to the resources location. When your app execution ends or you have generated all avatars, the SDK should be released.

// binary resources should be stored somewhere on the local storage
std::string resourcesPath = "path/to/resources/dir"
// Initialize Avatar SDK
int code = initAvatarSdk("Avatar SDK Sample", resourcesPath.c_str());
....
// Release Avatar SDK. Should be called after all avatars are generated.

Avatar Generation

To generate an avatar you should specify the subtype ("head/mobile" or "bust/mobile"), path to the source image and an output directory.

// Prints avatar calculation progress
void printProgress(float progress)
{
printf("Avatar is being calculated: %f\n", progress);
}
void generateAvatar(std::string inputImagePath, std::string outputDirPath)
{
//Configure parameters
AvatarSdkParams params;
params.pipelineSubtype = AvatarSdkPipelineSubtype::HEAD_MOBILE;
params.inputImagePath = (char*)inputImagePath.c_str();
params.outputDirPath = (char*)outputDirPath.c_str();
// Generate avatar
code = generateAvatar(params, printProgress);
if (code != 0)
printf("Error occured during avatar generation!\n");
else
printf("Avatar was generated!\n");
}

Parameters Configuration

AvatarSdkParams structure is used to configure parameters. The mandatory paramaters: pipeline subtype, source image and output directory.
Beyound them there are other options that allows to specify blendshapes, haircuts, generated metadata (AvatarSdkModelInfo field) and various modifications (AvatarModifications field).
See the avatar_sdk_structures.hpp to get info about all available parameters.

// Prints avatar calculation progress
void printProgress(float progress)
{
printf("Avatar is being calculated: %f\n", progress);
}
int generateAvatarWithParameters(AvatarSdkPipelineSubtype subtype, std::string inputImagePath, std::string outputDirPath)
{
//Set parameters
AvatarSdkParams avatarParams;
avatarParams.pipelineSubtype = subtype;
avatarParams.inputImagePath = (char*)inputImagePath.c_str();
avatarParams.outputDirPath = (char*)outputDirPath.c_str();
avatarParams.outputMeshFormat = AvatarSdkMeshFormat::AVATAR_SDK_MESH_FORMAT_OBJ;
if (subtype == AvatarSdkPipelineSubtype::HEAD_MOBILE)
avatarParams.lodNumber = 7;
//configure data that should be generated for this avatar
avatarParams.modelInfo = new AvatarSdkModelInfo();
avatarParams.modelInfo->gender = true;
avatarParams.modelInfo->eyeScleraColor = true;
avatarParams.modelInfo->eyeIrisColor = true;
avatarParams.modelInfo->skinColor = true;
avatarParams.modelInfo->age = true;
avatarParams.modelInfo->hairColor = true;
avatarParams.modelInfo->race = true;
avatarParams.modelInfo->predictHaircut = true;
if (subtype == AvatarSdkPipelineSubtype::HEAD_MOBILE)
avatarParams.modelInfo->facialLandmarks68 = true;
//avatar modifications
avatarParams.avatarModifications = new AvatarModifications();
if (subtype == AvatarSdkPipelineSubtype::BUST_MOBILE)
avatarParams.avatarModifications->curvedBottom = true;
avatarParams.avatarModifications->removeSmile = true;
avatarParams.avatarModifications->removeGlasses = true;
avatarParams.avatarModifications->enhanceLighting = true;
avatarParams.avatarModifications->setEyeIrisColor(0, 255, 0);
avatarParams.avatarModifications->setEyeScleraColor(0, 0, 255);
avatarParams.avatarModifications->setHairColor(0, 187, 255);
// generate all available blendshapes
unsigned int haircutsStrSize = 0;
const char* availableHaircuts = getAvailableHaircuts(subtype, haircutsStrSize);
avatarParams.addHaircuts(availableHaircuts, haircutsStrSize);
// generate all available haircuts
unsigned int blendshapesStrSize = 0;
const char* availableBlendshapes = getAvailableBlendshapes(subtype, blendshapesStrSize);
avatarParams.addBlendshapes(availableBlendshapes, blendshapesStrSize);
code = generateAvatar(avatarParams, printProgress);
if (code == 0)
{
printf("Avatar was generated!\n");
}
else
{
printf("Unable to generate avatar. Error code: %d", code);
}
delete avatarParams.modelInfo;
delete avatarParams.avatarModifications;
return code;
}