itSeez3D Avatar SDK  1.0.0
SDK for AI-powered 3D avatars creation
OFFLINE AVATAR SDK

Description

itSeez3D Offline Avatar SDK allows to generate a 3D avatar from a single photo. The 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.
  • 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.

The following properties can be predicted for the avatar:

  • Gender and its confidence
  • Eye Sclera Color
  • Iris Color
  • Haircut name
  • Skin color
  • Age (child or not child) and its confidence
  • Color of lips
  • Color of hair
  • Facial landmarks

These predicted data are stored in the model.json file in the output directory.

Offline Avatar SDK Package Content

itSeez3d Offlline Avatar SDK is distributed in a ZIP archive with the following content:

  • "bin" directory contains Avatar SDK's libraries for various platforms
  • "include" directory with the header files
  • "resources" contains binary resources required for the Avatar generation. These resources should be placed on the device filesystem and will be referenced from the Avatar SDK's methods.

Sample methods to generate avatar

#include <avatar_sdk.hpp>
// Prints avatar calculation progress
void printProgress(float progress)
{
printf("Avatar is being calculated: %f %\n", progress);
}
// inputImagePath - path to the photo in the JPEG or PNG format.
// outputDirPath - path to the directory with the output data
// resourcesPath - path to the binary resources
void generateAvatarInStorage(std::string inputImagePath, std::string outputDirPath, std::string resourcesPath)
{
// Initialize Avatar SDK
int code = initAvatarSdk("Avatar SDK Sample", resourcesPath.c_str());
if (code != 0)
return;
{
printf("There is no available pipeline \n");
return;
}
// Get the available resources
char resourcesJsonBuffer[4096];
code = getBaseResourcesJson(pipelineType, resourcesJsonBuffer, 4096);
if (code != 0)
printf("Unable to get resources!\n");
//Configure parameters
params.pipelineType = pipelineType;
params.inputImagePath = (char*)inputImagePath.c_str();
params.outputDirPath = (char*)outputDirPath.c_str();
params.resourcesJson = &resourcesJsonBuffer[0];
// Generate avatar
code = generateAvatar(params, printProgress);
if (code != 0)
printf("Error occured during avatar generation!\n");
else
printf("Avatar was generated!\n");
// Release Avatar SDK. Should be called after all avatars are generated.
}
// inputImagePath - path to the photo in the JPEG or PNG format.
// resourcesPath - path to the binary resources
void generateAvatarInMemory(std::string inputImagePath, std::string resourcesPath)
{
// Initialize Avatar SDK
int code = initAvatarSdk("Avatar SDK Sample", resourcesPath.c_str());
if (code != 0)
return;
{
printf("There is no available pipeline \n");
return;
}
//Configure parameters
params.pipelineType = pipelineType;
params.inputImagePath = (char*)inputImagePath.c_str();
params.outputDirPath = NULL; // Set to NULL to store generated avatar in memory
params.additionalTextures = 0;
// Generate avatar
code = generateAvatar(params, printProgress);
if (code == 0)
{
printf("Avatar was generated!\n");
int verticesCount = 0;
const float* vertices = getAvatarVertices(verticesCount);
int facesCount = 0;
const int* faces = getAvatarFaces(facesCount);
const double* uvMapping = getAvatarUVMapping(facesCount);
int textureWidth, textureHeight;
const unsigned char* texture = getAvatarTexture(textureWidth, textureHeight);
}
else
printf("Error occured during avatar generation!\n");
// Release Avatar SDK. Should be called after all avatars are generated.
}
// Prints resources list's content
void printResources(AvatarSdkResourcesList &resourcesList)
{
for (int i = 0; i < resourcesList.length; i++)
{
printf("%d - %s : %s \n", i, resourcesList.resources[i].name, resourcesList.resources[i].path);
}
}
// inputImagePath - path to the photo in the JPEG or PNG format.
// outputDirPath - path to the directory with the output data
// resourcesPath - path to the binary resources
void generateAvatarWithParameters(std::string inputImagePath, std::string outputDirPath, std::string resourcesPath)
{
//Initialize Avatar SDK with any application name
int code = initAvatarSdk("Avatar SDK Sample", resourcesPath.c_str());
if (code != 0)
{
printf("Unable to initialize Avatar SDK! \n");
return;
}
{
printf("There is no available pipeline \n");
return;
}
// Get the available resources
char resourcesJsonBuffer[4096];
code = getBaseResourcesJson(pipelineType, resourcesJsonBuffer, 4096);
if (code != 0)
{
printf("Unable to get resources! \n");
return;
}
//Set parameters
AvatarSdkParams avatarParams;
avatarParams.pipelineType = pipelineType;
avatarParams.inputImagePath = (char*)inputImagePath.c_str();
avatarParams.outputDirPath = (char*)outputDirPath.c_str();
avatarParams.resourcesJson = &resourcesJsonBuffer[0];
//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->predictHaircut = true;
avatarParams.modelInfo->skinColor = true;
avatarParams.modelInfo->age = true;
avatarParams.modelInfo->facialLandmarks68 = true;
avatarParams.modelInfo->lipsColor = true;
avatarParams.modelInfo->hairColor = true;
{
avatarParams.avatarModifications->Face.caricatureAmount = 3.0;
avatarParams.avatarModifications->Face.lipsColor = AvatarSdkColorRgb{ 0,255,0 };
}
else if (pipelineType == AVATAR_SDK_PIPELINE_HEAD)
{
avatarParams.avatarModifications->Head.curvedBottom = true;
}
unsigned int numberOfHaircurs = 0;
auto allOfAvailableHaircuts = getAvailableHaircutsList(numberOfHaircurs);
if (numberOfHaircurs)
{
printf("Here are all of available haircuts: \n");
for (int i = 0; i < numberOfHaircurs; i++)
{
printf("Haircut %d : %s \n", i, allOfAvailableHaircuts[i]);
}
}
unsigned int numberOfBlendshapes = 0;
auto allOfAvailableBlendshapes = getAvailableBlendshapesList(pipelineType, numberOfBlendshapes);
if (numberOfBlendshapes)
{
printf("Here are all of available blendshapes: \n");
for (int i = 0; i < numberOfBlendshapes; i++)
{
printf("Blendshape set %d : %s \n", i, allOfAvailableBlendshapes[i]);
}
}
avatarParams.additionalTextures->lipsMask = true;
avatarParams.addBlendshapes(allOfAvailableBlendshapes, numberOfBlendshapes);
avatarParams.addHaircuts(allOfAvailableHaircuts, numberOfHaircurs);
code = generateAvatar(avatarParams, printProgress);
if (code != 0)
{
printf("Unable to generate avatar. Error code: %d", code);
return;
}
else
{
printf("Avatar was generated!\n");
code = getAvatarModelInfo(avatarParams.outputDirPath, entry);
if (!code)
{
if (entry.age == AgePredicted::CHILD)
{
printf("Age: Child \n");
}
else if (entry.age == AgePredicted::NOT_CHILD)
{
printf("Age: Not child \n");
}
printf("Age confidence: %f \n", entry.ageConfidence);
if (entry.skinColor)
{
printf("Skin color (RGB): %d %d %d \n", entry.skinColor->red, entry.skinColor->green, entry.skinColor->blue);
}
if (entry.haircutName)
{
printf("Haircut name: %s \n", entry.haircutName);
}
AvatarSdkResourcesList modelAdditionalTextures = getAvatarAdditionalTextures(avatarParams.outputDirPath, pipelineType);
printf("Model's haircuts: \n");
printResources(modelHaircuts);
printf("Model's textures: \n");
printResources(modelAdditionalTextures);
printf("Model's blendshapes: \n");
printResources(modelBlendshapes);
}
else {
printf("Error occured getting of model info!\n");
}
}
delete avatarParams.modelInfo;
delete avatarParams.avatarModifications;
delete avatarParams.additionalTextures;
// Release Avatar SDK. Should be called after all avatars are generated.
}

System Requirements

  • Supported platforms: Windows 7,8,10 (64-bit), MacOSX, iOS 10, 11, Android 5+
  • 250mb free hard disk space
  • minimum 1GB RAM available for the application