8. Set Contents

Downloaded contents, face beautifications, and face fun bulge effects can be rendered on video frames. Such functionalities 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
};

8.1 An Item

Using setItemWithType:withItemFilePath:withItemID method in ARGContents Class, you can set an item.

There are several types of items that can be applied in ARGContents as shown below. Currently, the contents exist in https://argear.io only 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.

Objective-C
Swift
Objective-C
// Sample Code. An example of setting an ARG Item
/*
type ARGContentItemType
filePath Path of Downloaded Contents
itemID uuid of an Item
*/
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
[[argSession contents] setItemWithType:ARGContentItemTypeSticker withItemFilePath:targetPath withItemID:uuid];
Swift
// Sample Code. An example of setting an ARG Item
/*
type ARGContentItemType
filePath Path of Downloaded Contents
itemID uuid of an Item
*/
if let session = argSession, let contents = session.contents {
contents.setItemWith(.sticker, withItemFilePath: targetPath, withItemID: uuid)
}

8.2 Face Beautification

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 naturally 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>

ARGContentItemBeauty

Description

Value

ARGContentItemBeautyVline

0

Sharpening Jaw

(V-Line)

Float ( 0 ~ 100 )

Default 0.

100 to the sharpest jaw

ARGContentItemBeautyFaceSlim

1

Reducing Face Width

(Slimmer)

Float ( 0 ~ 100 )

Default 0.

100 to the slimmest face width

ARGContentItemBeautyJaw

2

Shortening Face Height

(Smaller Face)

Float ( 0 ~ 100 )

Default 0.

100 to the shortest face height

ARGContentItemBeautyChin

3

Increasing or Decreasing Chin Length

(Chin Length)

Float ( -100 ~ 100 )

Default 0

-100 to the shortest

100 to the longest

ARGContentItemBeautyEye

4

Increasing Eye Size

(Eye Height)

Float ( 0 ~ 100 )

Default 0.

100 to the biggest

ARGContentItemBeautyEyeGap

5

Increasing or Decreasing the Gap Between Eyes

(Gap between Eyes)

Float ( -100 ~ 100 )

Default 0

-100 to the shortest

100 to the highest

ARGContentItemBeautyNoseLine

6

Sharpening Nose Width

(Nose Width)

Float ( 0 ~ 100 )

Default 0.

100 to the slimmest

ARGContentItemBeautyNoseSize

7

Shortening Width of Nostrils

(Nostrils Width)

Float ( 0 ~ 100 )

Default 0.

100 to the smallest

ARGContentItemBeautyNoseLength

8

Increasing or Decreasing Nose Length

(Nose Length)

Float ( -100 ~ 100 )

Default 0

-100 to the shortest

100 to the longest

ARGContentItemBeautyMouthSize

9

Increasing or Decreasing Mouth Width

(Mouth Width)

Float ( -100 ~ 100 )

Default 0

-100 to the smallest

100 to the largest

ARGContentItemBeautyEyeBack

10

Increasing Back Side of Eyes

(Width of Back Side of Eyes)

Float ( 0 ~ 100 )

Default 0.

100 to the longest

ARGContentItemBeautyEyeCorner

11

Increasing or Decreasing Degree of Eyes

(Degree of Eyes)

Float ( -100 ~ 100 )

Default 0

-100 to the lowest

100 to the highest

ARGContentItemBeautyLipSize

12

Increasing or Decreasing Height Thickness of Lips

(Thickness of Lips)

Float ( -100 ~ 100 )

Default 0

-100 to the thinnest

100 to the thickest

ARGContentItemBeautySkinFace

13

Hiding Facial Blemish

(Facial Blemish Removal)

Float ( 0 ~ 100 )

Default 0.

100 to the cleanest

ARGContentItemBeautySkinDarkCircle 14

Hiding Dark Circles

(Dark Circles Removal)

Float ( 0 ~ 100 )

Default 0.

100 to the cleanest

ARGContentItemBeautySkinMouthWrinkle

15

Hiding Mouth Wrinkles

(Mouth Wrinkles Removal)

Float ( 0 ~ 100 )

Default 0.

100 to the cleanest

8.2.1 Enable Face Beautification

We show how to enable face beautification first.

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

Objective-C
Swift
Objective-C
// Sample Code. Enabling Face Beautification
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
[[argSession.contents] setBulge:ARGContentItemBulgeNONE];
[[argSession contents] setDefaultBeauty];
Swift
// Sample Code. Enabling Face Beautification
if let session = argSession, let contents = session.contents {
contents.setBulge(.NONE)
contents.setDefaultBeauty()
}

8.2.2 Face Beautification Effects Manipulation

By setting beauty values, you can change how much level of face beautification effects should be applied.

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

Objective-C
Swift
Objective-C
// 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];
beautyValue[ARGContentItemBeautyVline] = 10.f;
beautyValue[ARGContentItemBeautyFaceSlim] = 90.f;
beautyValue[ARGContentItemBeautyJaw] = 55.f;
beautyValue[ARGContentItemBeautyChin] = -50.f;
beautyValue[ARGContentItemBeautyEye] = 5.f;
beautyValue[ARGContentItemBeautyEyeGap] = -10.f;
beautyValue[ARGContentItemBeautyNoseLine] = 0.f;
beautyValue[ARGContentItemBeautyNoseSize] = 35.f;
beautyValue[ARGContentItemBeautyNoseLength] = 30.f;
beautyValue[ARGContentItemBeautyMouthSize] = -35.f;
beautyValue[ARGContentItemBeautyEyeBack] = 0.f;
beautyValue[ARGContentItemBeautyEyeCorner] = 0.f;
beautyValue[ARGContentItemBeautyLipSize] = 0.f;
beautyValue[ARGContentItemBeautySkinFace] = 50.f;
beautyValue[ARGContentItemBeautySkinDarkCircle] = 0.f;
beautyValue[ARGContentItemBeautySkinMouthWrinkle] = 0.f;
[[argSession contents] setBeautyValues:beautyValue];
Swift
// Sample Code. Manipulating Face Beautification Effects
if let session = argSession, let contents = session.contents {
// Set a Specific Face Beautification Effect Level
contents.setBeauty(.faceSlim, value: 0.7)
// Set 16 Face Beautification Effects at the Same Time
var beautyValue: [Float] = [
10.0,
90.0,
55.0,
-50.0,
5.0,
-10.0,
0.0,
35.0,
30.0,
-35.0,
0.0,
0.0,
0.0,
50.0,
0.0,
0.0
]
let beautyValuePointer: UnsafeMutablePointer<Float> = UnsafeMutablePointer(&beautyValue)
contents.setBeautyValues(beautyValuePointer)
}

8.3 Face Fun Bulge

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

A sample code of fun bulge is written below.

Objective-C
Swift
Objective-C
// Sample Code. Set Face Bulge Fun Type
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
[[argSession contents] setBulge:1];
Swift
// Sample Code. Set Face Bulge Fun Type
if let session = argSession, let contents = session.contents {
contents.setBulge(.FUN1)
}

8.4 Remove Contents

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

A sample code is written below.

Objective-C
Swift
Objective-C
// Sample Code. Removing Contents Example
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
[[argSession contents] clear:ARGContentItemTypeSticker];
Swift
// Sample Code. Removing Contents Example
if let session = argSession, let contents = session.contents {
contents.clear(.sticker)
}