4. ARGSession
ARGSession maintains the status of your application and manages the life cycle of your application according to the status. It also contains rendered frames.
<ARGear/ARGear.h> should be imported beforehand.
ARGSessionDelegate protocol required.

4.1 Init & Create

When creating ARGSession, you can pass ARGConfig and ARGInferenceFeature parameters. ARGConfig contains API URL, API key, secret key, and auth key and it must be sent to ARGSession.
You must pass ARGInferenceFeature parameter to ARGSession and the selected feature will be obtained. The configured feature information can be obtained from ARGFrame.
Below is the sample code to create ARGSession.
Objective-C
Swift
1
// Sample Code. ARGSession Creation Example
2
3
ARGConfig *argConfig = [[ARGConfig alloc] initWithApiURL:API_HOST apiKey:API_KEY secretKey:API_SECRET_KEY authKey:API_AUTH_KEY];
4
5
NSError * error;
6
_argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
7
_argSession.delegate = self;
Copied!
1
// Sample Code. ARGSession Creation Example
2
3
do {
4
let config = ARGConfig(
5
apiURL: API_HOST,
6
apiKey: API_KEY,
7
secretKey: API_SECRET_KEY,
8
authKey: API_AUTH_KEY
9
)
10
argSession = try ARGSession(argConfig: config, feature: [.faceMeshTracking])
11
argSession?.delegate = self
12
} catch let error as NSError {
13
} catch let exception as NSException {
14
}
Copied!
Unless ARGConfig is properly set during ARGSession creation, the ARGear SDK will not be initiated. Therefore, you must create an account in https://argear.io, set the created API Key information in ARGConfig, and create ARGSession with the ARGConfig to use ARGear SDK.

4.2 Run

Create ARGSession with or without an option, ARGInferenceOption. For the details of ARGInferenceOption, please refer to ARGInferenceOption.
Sample code is written below.
Objective-C
Swift
1
// Sample Code. ARGSession Run Example
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig feature:ARGInferenceFeatureFaceMeshTracking error:&error];
4
5
[argSession run];
Copied!
1
// Sample Code. ARGSession Run Example
2
3
argSession = try ARGSession(argConfig: config, feature: [.faceLowTracking])
4
5
argSession?.run()
Copied!

4.3 Pause

To pause the current ARGSession, call pause function inside ARGSession.
Sample code is written below.
Objective-C
Swift
1
// Sample Code. ARGSession Pause Example
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
4
5
[argSession pause];
Copied!
1
// Sample Code. ARGSession Pause Example
2
3
argSession?.pause()
Copied!

4.4 Destroy

To destroy the current ARGSession, use the destroy function.
Sample code is written as follows.
Objective-C
Swift
1
// Sample Code. ARGSession Destroy Example
2
3
ARGSession *argSession = [[ARGSession alloc] initWithARGConfig:argConfig error:&error];
4
5
[argSession destroy];
Copied!
1
// Sample Code. ARGSession Destroy Example
2
3
argSession?.destroy()
Copied!
Last modified 10mo ago