14. API Reference
This section provides detailed description of ARGear classes.
Last updated
This section provides detailed description of ARGear classes.
Last updated
ARGSession class stores statuses of an application and provides corresponding functions based on the statuses.
ARGAuth provides validity check and signed download URL creation functions.
ARGFrame contains both the fed frames from the camera and the rendered ARGear Contents. ARGFrame can be obtained as a result of calling the drawFrame function in ARGSession.
ARGFace contains face tracking and detection related information.
ARGSegmentation contains the result of segmentation.
Apply ARGear contents, beauty, or bulge effects.
ARGMedia provides photo capture and video recording functions.
Method
Description
ARGSession(Context context, ARGConfig config)
Create ARGSession according to ARGConfig.
ARGSession(Context context, ARGConfig config, Set<ARGInferenceConfig.Feature> inference)
Create ARGSession according to ARGConfig and ARGInferenceConfig.Feature.
auth
Return ARGAuth object.
contents
Return ARGContents object.
setCameraConfig
Set camera configuration information.
applyAdditionalFaceInfo
Send additional information for face detection.
feedRawData
Update Preview Frame data from camera.
feedTextureId
Feed texture ID of camera
drawFrame
Render fed frames from camera along with ARGear contents.
resume
Start or resume ARGSession.
pause
Pause ARGSession.
destroy
Destroy ARGSession.
setFeatureInference
Set or update ARGInferenceConfig.Feature.
setDebugInference
Enable or disable ARGInferenceConfig.Debug.
public ARGSession(Context context, ARGConfig config)
Create ARGSession according to ARGConfig.
ARGConfig contains configuration information for ARGSession and must be provided to create ARGSession.
Corresponding information must be set to the variables below.
- public String apiUrl;
- public String apiKey;
- public String secretKey;
- public String authKey;
Parameters
Context context : Application Context
ARGConfig config : Configuration Information for ARGSession
Returns
An Instance of ARGSession
public ARGSession(Context context, ARGConfig config, Set<ARGInferenceConfig.Feature> inference)
Use ARGConfig and ARGInferenceConfig.Feature to create ARGSession.
ARGConfig contains configuration information for ARGSession and must be provided to create ARGSession.
Corresponding information must be set to the variables below.
public String apiUrl;
public String apiKey;
public String secretKey;
public String authKey;
ARGInferenceConfig.Feature is a required parameter and can be obtained from ARGFrame.
Types of feature inferences are declared as follows.
public enum Feature {
FACE_LOW_TRACKING, // Machine Learning based TRACKING
FACE_HIGH_TRACKING, // Deep Learning based TRACKING (Low polygon)
FACE_MESH_TRACKING, // Deep Learning based TRACKING (High polygon)
// FACE_BLEND_SHAPES,
SEGMENTATION_HALF,
// SEGMENTATION_FULL,
// HAND_TRACKING,
// HAND_LANDMARK_2D,
// HAND_LANDMARK_3D,
// BODY_TRACKING,
// BODY_POSE_2D,
// BODY_POSE_3D
}
Parameters
Context context : Application Context
ARGConfig config : Configuration Information for ARGSession
Set<ARGInferenceConfig.Feature> inference : Type of Feature Inference
Returns
An Instance of ARGSession
public ARGAuth auth()
Return An Instance of ARGAuth. (Reference : 12.2 ARGAuth)
Returns
An Instance of ARGAuth
public ARGContents contents()
Return An Instance of ARGContents (Reference : 12.6 ARGContents)
Returns
An Instance of ARGContents
public void setCameraConfig(ARGCameraConfig config)
Set Camera Configuration Information.
ARGCameraConfig declares variables as written below.
public int previewWidth;
public int previewHeight;
public float verticalFov;
public float horizontalFov;
public int orientation;
public boolean isFrontFacing;
public float fps;
Parameters
ARGCameraConfig config : An Instance of Camera Configuration
public void applyAdditionalFaceInfo(List faceVerticesList, List poseMatrixList, float [] projectionMatrix, float [] viewMatrix
Send additional information for face detection.
Parameters
faceVerticesList : face vertices
poseMatrixList : pose matrix
projectionMatrix : projection matrix
viewMatrix : view matrix
public void feedRawData(byte[] data)
For Camera API 1
Update Preview Frame Data from Camera Device.
Parameters
byte[] data : Raw Frame Data from Camera
public void feedRawData(Image data)
For Camera API 2
Update Preview Frame Data from Camera Device.
Parameters
Image data : Image Data from Camera
public void feedTexture(int textureId, Size textureSize)
Feed texture ID of a camera
Parameters
textureId : texture ID of a camera
textureSize : texture size
public ARGFrame drawFrame(GL10 gl, ARGFrame.Ratio ratio, int viewWidth, int viewHeight)
Render fed frames from camera along with ARGear contents.
The function must be called in gl thread environment.
Possible screen ratios are described below.
public enum Ratio {
RATIO_FULL(3),
RATIO_4_3(2),
RATIO_1_1(1);
public final int code;
Ratio(int code) {
this.code = code;
}
}
Parameters
GL10 gl : gl interface
ARGFrame.Ratio ratio : Screen Ratio
int viewWidth : Width of View
int viewHeight : Height of View
public void resume()
Start or Resume ARGSession.
public void pause()
Pause ARGSession.
public void destroy()
Destroy ARGSession.
public void setFeatureInference(Set<ARGInferenceConfig.Feature> config)
Set or update ARGInferenceConfig.Feature.
From ARGFrame, configured information can be retrieved.
Types of feature inferences are declared as follows.
public enum Feature {
FACE_LOW_TRACKING, // Machine Learning based TRACKING
FACE_HIGH_TRACKING, // Deep Learning based TRACKING (Low polygon)
// FACE_MESH_TRACKING, // Deep Learning based TRACKING (High polygon)
// FACE_BLEND_SHAPES,
SEGMENTATION_HALF,
// SEGMENTATION_FULL,
// HAND_TRACKING,
// HAND_LANDMARK_2D,
// HAND_LANDMARK_3D,
// BODY_TRACKING,
// BODY_POSE_2D,
// BODY_POSE_3D
}
Parameters
Set<ARGInferenceConfig.Feature> config : feature inference configuration values
public void setDebugInference(Set<ARGInferenceConfig.Debug> config)
Enable or Disable ARGInferenceConfig.Debug.
Types of feature inferences are declared as below.
public enum Debug {
NONE(0),
FACE_RECT_HW(1 << 0),
FACE_RECT_SW(1 << 3),
FACE_LANDMARK(1 << 4),
FACE_LANDMARK_EXTEND(1 << 5),
FACE_AXIES(1 << 6);
public final int code;
Debug(int code) { this.code = code; }
}
Parameters
Set<ARGInferenceConfig.Debug> config : debug inference set values
Method
Description
isValid
Check whether Authentication is valid.
requestSignedUrl
Convert download URL into signed download URL.
public boolean isValid()
Return boolean value to check whether Authentication is valid or not.
If Authentication is invalid, ARGear will not work.
Returns
true : valid
fale : invalid
public void requestSignedUrl(final String url, final String itemTitle, final String itemType, final ARGAuth.Callback callback)
Convert download url into signed download url. After signed url request is sent, the result can be obtained by running ARGAuth.Callback function.
ARGAuth.Callback is defined as below.
public interface Callback {
void onSuccess(String url);
void onError(Throwable e);
}
When ARGAuth.Callback succeeds, it passes signed download url to OnSuccess method as its parameter. When it does not, it passes SignedUrlGenerationException or NetworkException to OnError method as its parameters.
Parameters
String url : download url
String itemTitle : title of an item
final String itemType : type of an item
ARGAuth.Callback callback : result of callback
Method
Description
getTextureId
Return rendered texture id from ARGear.
getRawData
Return rendered result from ARGear in byte array type.
getItemTriggerFlag
Return trigger flag value of ARGear Contents in ARGear.
getFaces
Return the list of ARGFace objects.
segmentation
Return ARGSegmentation object.
public int getTextureId()
Return rendered texture id in ARGear.
Returns
texture id
public ByteBuffer getRawData(int degree, boolean flipX, boolean flipY)
Return rendered result from ARGear in byte array type.
This method should be called in gl thread environment.
Returns
degree : rotation degree (0, 90, 180, 360)
flipX : flip in X axis
flipY : flip in Y axis
texture id
public int getItemTriggerFlag()
Return trigger flag values of ARGear Contents in ARGear.
When a type of trigger flag action is performed by a user, it triggers a corresponding event.
Returns
TRIGGER_MOUTH_FLAG = (1 << 0) : Trigger an event on mouth opening action
TRIGGER_HEAD_FLAG = (1 << 1) : Trigger an event on left to right head movement action
TRIGGER_DELAY_FLAG = (1 << 2) : Trigger an event after designated delayed time
TRIGGER_BLINK_EYES_FLAG = (1 << 3) : Trigger an event on blink action
public @Nullable List<ARGFace> getFaces()
Return a list of ARGFace objects. (Reference : 12.4 ARGFace)
Returns
A list of object in ARGFace
public @Nullable ARGSegmentation segmentation()
Return ARGSegmentation object. (Reference : 12.5 Segmentation)
Returns
ARGSegmentation object
Method
Description
getLandmark
Return 68 point 2d landmark.
getExtendLandmark
Return 83 point 2d landmark.
getRotationMatrix
Return rotation matrix.
getTranslationVector
Return translation vector.
getTriggerInfo
Return trigger.
isValid
Return a boolean value by whether face is detected or not.
public float [] getLandmark()
Return 68 point 2d landmark.
The shape of landmark array is 68 * 2. It contains 68 x and y coordinates in the order of [0] : x1, [1] : y1, [2] : x2, [3] : y2, …, [66] : x68, [67] : y68.
Returns
float[68 *2] : 68 point 2d landmark array
public float [] getExtendLandmark()
Return 83 point 2d landmark.
The shape of landmark array is 83 * 2. It contains 83 x and y coordinates in the order of [0] : x1, [1] : y1, [2] : x2, [3] : y2, …, [82] : x83, [82] : y83.
Returns
float[83 *2] : 83 point 2d landmark array
public double [] getRotationMatrix()
Return a rotation matrix.
Returns
double[9] : 3x3 Rotation Matrix
|[0],[1],[2]|
|[3],[4],[5]|
|[6],[7],[8]|
public double [] getTranslationVector()
Return a translation vector array.
Returns
double[3] : translation vector array
[0] : x
[1] : y
[2] : z
public int [] getTriggerInfo()
Return trigger related information.
Parameters
Context context : Application Context
String apiKey : API Key
String secretKey : Secret Key
Returns
int[3] : trigger information
[0] : Left Eye Open (1: opened 0:closed)
[1] : Right Eye Open (1: opened 0:closed)
[2] : MOUTH(0:closed ~ 100:opened)
public boolean isValid()
Check whether face is detected or not.
Returns
true : detected
false : not detected
Method
Description
getTextureId
Return texture id of segmentation result.
public int getTextureId()
Return texture id of segmentation result.
Returns
int : texture id of segmentation result
Method
Description
setItem
Set ARGear contents.
setBeauty
Set face beautification effect.
setBulge
Set face fun bulge effect.
setFilterOption
Set a type of filter option (blur, vignetting).
setFilterLevel
Manipulate level of a filter effect.
clear
Clear applied contents.
public void setItem(Type type, String path, String id, ARGContents.Callback callback)
Set ARGear contents.
Two types of contents (ARGContents.Type.ARGItem, ARGContents.Type.FilterItem) can be set.
The result callback interface is defined as below.
public interface Callback {
void onSuccess();
void onError(Throwable e);
}
For the OnError parameter, InvalidContentsException comes in.
Parameters
Type type : A type of content to be applied
String path : Path of downloaded contents
String id : uuid
ARGContents.Callback callback : Result callback
public void setBeauty(float [] values)
Set a face beautification effect. The function takes a float array as its input, each element of which indicates a level of face beautification effect of its type.
A sample input of a float array is shown below.
public float[] beautyValues = {
10, //VLINE
90, //ACE_SLIM
55, //JAW
-50, //CHIN
5, //EYE
-10, //EYE_GAP
0, //NOSE_LINE
35, //NOSE_SIDE
30, //NOSE_LENGTH
-35, //MOUTH_SIZE
0, //EYE_BACK
0, //EYE_CORNER
0, //LIP_SIZE
50, //SKIN
0, //DARK_CIRCLE
0, //MOUTH_WRINKLE
};
For the range of the float array, please refer to 9.2 Apply Face Beautification Effect.
Parameters
float[ ] values : An array of level of face beautification effects
public void setBulge(BulgeType type)
Apply a face fun bulge effect.
The function provides 6 types of face fun bulge effects as shown below.
public enum BulgeType {
NONE(-1),
FUN1(1),
FUN2(2),
FUN3(3),
FUN4(4),
FUN5(5),
FUN6(6);
public final int code;
BulgeType(int code) {
this.code = code;
}
}
Parameters
BulgeType type : a face fun bulge type
public void setFilterOption(FilterOption option, boolean flag)
Apply a type of filter (blur, vignetting).
The function provides two types of options and its effect is applied only when a filter content is applied beforehand.
public enum FilterOption { BLUR, VIGNETTING }
Parameters
FilterOption option : filter option
boolean flag : Whether a filter is set or not (true : set, false : removed)
Returns
public void setFilterLevel(int level)
The function manipulates a level of a filter effect between 0 and 100. The effect is applied when a filter content is applied beforehand.
Parameters
int level : A level of a filter effect (Range : 0 ~ 100)
public void clear(Type type)
Clear applied contents.
Parameters
Type type : A type of content to be removed (ARGItem, FilterItem, Beauty, Bulge)
Method
Description
initRecorder
Configure video recording options.
startRecording
Start video recording.
stopRecording
Stop video recording.
updateFrame
Encode rendered texture.
isRecording
Check whether video recording is going on or not.
takePicture
Take a picture.
public void initRecorder(String path, int width, int height, int bitrate, boolean videoOnly, boolean flipV, boolean flipH, Ratio ratio)
Configure video recording options. The function must be called before recording a video.
Three different size of ratios are allowed for recording as shown below.
public enum Ratio {
RATIO_16_9(0),
RATIO_4_3(1),
RATIO_1_1(2);
public final int code;
Ratio(int code) {
this.code = code;
}
}
Parameters
String path : Path to save a video
int width : Width of camera preview
int height : Height of camera preview
int bitrate : bitrate
boolean videoOnly : Check whether audio recording should be turned on
boolean flipV : Check whether the recording should flip in vertical axis
boolean flipH : Check whether the recording should flip in horizontal axis
Ratio ratio : Ratio of recording a video
public void startRecording()
The function starts recording a video.
public void stopRecording()
The function stops recording a video. Once stopped, it stores the video in the path set in initRecorder function earlier.
public void updateFrame(int textureId)
The function encodes rendered texture. It must be called in a gl thread.
Parameters
int textureId : texture id rendered in ARGear (It can be obtained from getTextureId method in ARGFrame.)
public boolean isRecording()
Check whether video recording has been started or not.
Returns
true : Recording started.
false : Recording stopped.
Public void takePicture(int textureId, String path, Ratio ratio)
Take a photo.
The function provides three different ratios for photo capture as shown below.
public enum Ratio {
RATIO_16_9(0),
RATIO_4_3(1),
RATIO_1_1(2);
public final int code;
Ratio(int code) {
this.code = code;
}
}
This function must be called in a gl thread environment.
Parameters
int textureId : texture id rendered in ARGear (It can be obtained from getTextureId method in ARGFrame.)
String path : Path to save a photo
Ratio ratio : Size ratio of a photo