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>
1
typedef NS_ENUM (NSInteger, ARGContentItemType) {
2
ARGContentItemTypeSticker,
3
ARGContentItemTypeFilter,
4
ARGContentItemTypeBeauty,
5
ARGContentItemTypeBulge,
6
ARGContentItemTypeNum
7
};
Copied!

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.
Objective-C
Swift
1
// Sample Code. An example of setting an ARG Item
2
/*
3
type ARGContentItemType
4
filePath Contents downloaded path
5
itemID uuid of an iteam
6
completion callback result
7
*/
8
9
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
10
11
[[argSession contents] setItemWithType:ARGContentItemTypeSticker withItemFilePath:targetPath withItemID:uuid];
12
13
[[argSession contents] setItemWithType:ARGContentItemTypeSticker
14
withItemFilePath:targetPath
15
withItemID:[item uuid]
16
completion:^( BOOL success, NSString * _Nullable msg) {
17
if (success) {
18
// success
19
} else {
20
// fail
21
}
22
}];
23
Copied!
1
// Sample Code. An example of setting an ARG Item
2
3
/*
4
type ARGContentItemType
5
filePath Contents downloaded path
6
itemID uuid of an item
7
completion callback result
8
*/
9
10
if let session = argSession, let contents = session.contents {
11
contents.setItemWith(.sticker, withItemFilePath: targetPath, withItemID: uuid) { (success, msg) in
12
if (success) {
13
// success
14
} else {
15
// fail
16
}
17
}
18
}
19
Copied!

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

9.2.1 Enable Face Beautification

The sample code below shows how to enable face beautification effects.
Objective-C
Swift
1
// Sample Code. Enabling Face Beautification
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
4
5
[[argSession.contents] setBulge:ARGContentItemBulgeNONE];
6
[[argSession contents] setDefaultBeauty];
Copied!
1
// Sample Code. Enabling Face Beautification
2
3
if let session = argSession, let contents = session.contents {
4
contents.setBulge(.NONE)
5
contents.setDefaultBeauty()
6
}
Copied!

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.
Objective-C
Swift
1
// Sample Code. Manipulating Face Beautification Effects
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
4
5
6
// Set a Specific Face Beautification Effect Level
7
[[argSession contents] setBeauty:ARGContentItemBeautyFaceSlim value:0.7f];
8
9
10
// Set 16 Face Beautification Effects at the Same Time
11
float beautyValue[BEAUTY_TYPE_NUM];
12
13
defaultValue[BEAUTY_TYPE_VLINE] = 10.f;
14
defaultValue[BEAUTY_TYPE_FACE_SLIM] = 90.f;
15
defaultValue[BEAUTY_TYPE_JAW] = 55.f;
16
defaultValue[BEAUTY_TYPE_CHIN] = -50.f;
17
defaultValue[BEAUTY_TYPE_EYE] = 5.f;
18
defaultValue[BEAUTY_TYPE_EYE_GAP] = -10.f;
19
defaultValue[BEAUTY_TYPE_NOSE_LINE] = 0.f;
20
defaultValue[BEAUTY_TYPE_NOSE_SIDE] = 35.f;
21
defaultValue[BEAUTY_TYPE_NOSE_LENGTH] = 30.f;
22
defaultValue[BEAUTY_TYPE_MOUTH_SIZE] = -35.f;
23
defaultValue[BEAUTY_TYPE_EYE_BACK] = 0.f;
24
defaultValue[BEAUTY_TYPE_EYE_CORNER] = 0.f;
25
defaultValue[BEAUTY_TYPE_LIP_SIZE ] = 0.f;
26
defaultValue[BEAUTY_TYPE_SKIN_FACE] = 50.f;
27
defaultValue[BEAUTY_TYPE_SKIN_DARK_CIRCLE ] = 0.f;
28
defaultValue[BEAUTY_TYPE_SKIN_MOUTH_WRINKLE ] = 0.f;
29
30
[[argSession contents] setBeautyValues:beautyValue];
Copied!
1
// Sample Code. Manipulating Face Beautification Effects
2
3
if let session = argSession, let contents = session.contents {
4
5
// Set a Specific Face Beautification Effect Level
6
contents.setBeauty(.faceSlim, value: 0.7)
7
8
// Set 16 Face Beautification Effects at the Same Time
9
var beautyValue: [Float] = [
10
10.0,
11
90.0,
12
55.0,
13
-50.0,
14
5.0,
15
-10.0,
16
0.0,
17
35.0,
18
30.0,
19
-35.0,
20
0.0,
21
0.0,
22
0.0,
23
50.0,
24
0.0,
25
0.0
26
]
27
28
let beautyValuePointer: UnsafeMutablePointer<Float> = UnsafeMutablePointer(&beautyValue)
29
contents.setBeautyValues(beautyValuePointer)
30
}
Copied!

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.
Objective-C
Swift
1
// Sample Code. Set Face Bulge Fun Type
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
4
5
6
[[argSession contents] setBulge:1];
Copied!
1
// Sample Code. Set Face Bulge Fun Type
2
3
if let session = argSession, let contents = session.contents {
4
contents.setBulge(.FUN1)
5
}
Copied!

9.4 Remove Contents

By calling clear method with the ARGContentItemType in ARContents Class, related contents can be removed.
Sample code is written below.
Objective-C
Swift
1
// Sample Code. Removing Contents Example
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
4
5
6
[[argSession contents] clear:ARGContentItemTypeSticker];
Copied!
1
// Sample Code. Removing Contents Example
2
3
if let session = argSession, let contents = session.contents {
4
contents.clear(.sticker)
5
}
Copied!
Last modified 1yr ago