9. Set Contents

Downloaded contents, face beautifications, and face fun bulge effects can be rendered on video frames. These features can be applied or removed through ARGContents class in ARGSession. Types of Contents are defined in ARGContents.h as ARGContentItemType.

<Definition. ARGContentItemType>
typedef NS_ENUM (NSInteger, ARGContentItemType)  {
    ARGContentItemTypeSticker,
    ARGContentItemTypeFilter,
    ARGContentItemTypeBeauty,
    ARGContentItemTypeBulge,
    ARGContentItemTypeNum
};

9.1 Set Item (2D/3D Sticker, Filter, Background, ARContents, …)

Using the setItemWithType method in the ARGContents Class, you can set an item to be rendered with the the ARGContentItemType, downloaded file, and uuid.

There are several types of items that can be applied in ARGContents as shown below. Currently, the only the contents exist in https://argear.io can be used in ARGContents.

  • 2D Animation Sticker / Effects (BGM Support)

  • 2D Face Mask

  • Face Fun Bulge

  • Face Beautification

  • Camera Filter

  • 3D Animation Sticker

  • Realtime Segmentation

  • 3D Avatar (Blendshape 52)

The sample code below shows an example of how to set an item.

// Sample Code. An example of setting an ARG Item
/*
 type           ARGContentItemType
 filePath       Contents downloaded path
 itemID         uuid of an iteam
 completion     callback result
 */

ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];

[[argSession contents] setItemWithType:ARGContentItemTypeSticker withItemFilePath:targetPath withItemID:uuid];
 
[[argSession contents] setItemWithType:ARGContentItemTypeSticker
                                    withItemFilePath:targetPath
                                             withItemID:[item uuid]
                                           completion:^( BOOL success, NSString * _Nullable msg) {
        if (success) {
            // success
        } else {
            // fail
        }
}];

9.2 Apply Face Beautification Effect

There are 16 face beautification effects in ARGContents such as V-line, face slim, jaw, chin, eye, eye gap, nose line, nose side, nose length, mouth size, eye back, eye corner, lip size, face skin, dark circle, and lip wrinkle. By applying these effects, your customers can transform their faces easily.

Face beautification types are defined in ARGContentItemBeauty type in ARGContents.h. For the details of each parameter type, please refer to the table below.

<Table. Types of ARGContentItemBeauty Description>

9.2.1 Enable Face Beautification

The sample code below shows how to enable face beautification effects.

// Sample Code. Enabling Face Beautification

ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
 
[[argSession.contents] setBulge:ARGContentItemBulgeNONE];
[[argSession contents] setDefaultBeauty];

9.2.2 Face Beautification Effects Manipulation

By setting beauty values, you can change the amount face beautification effects are applied.

The sample code below shows how to manipulate one or multiple face beautification effects.

// Sample Code. Manipulating Face Beautification Effects

ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];

 
// Set a Specific Face Beautification Effect Level
[[argSession contents] setBeauty:ARGContentItemBeautyFaceSlim value:0.7f];
 
 
// Set 16 Face Beautification Effects at the Same Time
float beautyValue[BEAUTY_TYPE_NUM];
    
defaultValue[BEAUTY_TYPE_VLINE] = 10.f;
defaultValue[BEAUTY_TYPE_FACE_SLIM] = 90.f;
defaultValue[BEAUTY_TYPE_JAW] = 55.f;
defaultValue[BEAUTY_TYPE_CHIN] = -50.f;
defaultValue[BEAUTY_TYPE_EYE] = 5.f;
defaultValue[BEAUTY_TYPE_EYE_GAP] = -10.f;
defaultValue[BEAUTY_TYPE_NOSE_LINE] = 0.f;
defaultValue[BEAUTY_TYPE_NOSE_SIDE] = 35.f;
defaultValue[BEAUTY_TYPE_NOSE_LENGTH] = 30.f;
defaultValue[BEAUTY_TYPE_MOUTH_SIZE] = -35.f;
defaultValue[BEAUTY_TYPE_EYE_BACK] = 0.f;
defaultValue[BEAUTY_TYPE_EYE_CORNER] = 0.f;
defaultValue[BEAUTY_TYPE_LIP_SIZE ] = 0.f;
defaultValue[BEAUTY_TYPE_SKIN_FACE] = 50.f;
defaultValue[BEAUTY_TYPE_SKIN_DARK_CIRCLE ] = 0.f;
defaultValue[BEAUTY_TYPE_SKIN_MOUTH_WRINKLE ] = 0.f;
    
[[argSession contents] setBeautyValues:beautyValue];

9.3 Face Fun Bulge

The setBulge function in ARGContents class allows you to set 6 types of fun bulge effects.

Sample code of fun bulge is written below.

// Sample Code. Set Face Bulge Fun Type

ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];

 
[[argSession contents] setBulge:1];

9.4 Remove Contents

By calling clear method with the ARGContentItemType in ARContents Class, related contents can be removed.

Sample code is written below.

// Sample Code. Removing Contents Example

ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];

 
[[argSession contents] clear:ARGContentItemTypeSticker];

Last updated