public class DeepAR
extends java.lang.Object
implements android.media.ImageReader.OnImageAvailableListener
Modifier and Type | Class and Description |
---|---|
static interface |
DeepAR.AnimationTransitionedCallback
Animation transitioned callback interface.
|
static class |
DeepAR.FaceData
Represents data structure containing all the information available about the detected face.
|
static interface |
DeepAR.FaceTrackedCallback
Face tracked callback interface.
|
static class |
DeepAR.FaceTrackingInitParameters
Face tracking parameters that will determine how the face tracking is initialized.
|
static interface |
DeepAR.FrameRenderedCallback
Frame rendered callback interface.
|
static class |
DeepAR.ToneMapping |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ERROR_EFFECT_FILE_LOAD_FAILED
Effect file load failed error name.
|
static java.lang.String |
ERROR_MODEL_FILE_NOT_FOUND
Model file not found error name.
|
Constructor and Description |
---|
DeepAR(android.content.Context context)
Creates a new DeepAR object.
|
Modifier and Type | Method and Description |
---|---|
void |
backgroundBlur(boolean enable,
int strength)
Enable background blur.
|
void |
backgroundReplacement(boolean enable,
android.graphics.Bitmap image)
Enable background replacement (also known as background removal or green screen effect).
|
void |
changeLiveMode(boolean value)
An optimization method and it allows the user to indicate the DeepAR in which mode it should operate.
|
void |
changeParameterBool(java.lang.String gameObject,
java.lang.String component,
java.lang.String parameter,
boolean val)
Changes a node or component boolean parameter.
|
void |
changeParameterFloat(java.lang.String gameObject,
java.lang.String component,
java.lang.String parameter,
float val)
Changes a node or component float parameter.
|
void |
changeParameterTexture(java.lang.String gameObject,
java.lang.String component,
java.lang.String parameter,
android.graphics.Bitmap image)
Changes a node or component texture parameter.
|
void |
changeParameterVec3(java.lang.String gameObject,
java.lang.String component,
java.lang.String parameter,
float valX,
float valY,
float valZ)
Changes a node or component 3D vector parameter.
|
void |
changeParameterVec4(java.lang.String gameObject,
java.lang.String component,
java.lang.String parameter,
float valX,
float valY,
float valZ,
float valW)
Changes a node or component 4D vector parameter.
|
boolean |
clearVars()
Clear all variables.
|
boolean |
clearVars(java.lang.String slot)
Clear all variables or variables from the specified effect.
|
boolean |
deleteVar(java.lang.String name)
Delete the variable with the given name.
|
boolean |
deleteVar(java.lang.String name,
java.lang.String slot)
Delete the variable with the given name.
|
void |
fireTrigger(java.lang.String trigger)
Fire named trigger of an fbx animation set on the currently loaded effect.
|
int |
getBitRate()
Gets the video bitrate.
|
boolean |
getBoolVar(java.lang.String name)
Get boolean variable with the given name.
|
boolean |
getBoolVar(java.lang.String name,
java.lang.String slot)
Get boolean variable with the given name.
|
double |
getDoubleVar(java.lang.String name)
Get double variable with the given name.
|
double |
getDoubleVar(java.lang.String name,
java.lang.String slot)
Get double variable with the given name.
|
int |
getExternalGlTexture()
Get Android External GL texture.
|
DeepAR.FaceTrackedCallback |
getFaceTrackedCallback()
Gets the face tracked callback.
|
DeepAR.FrameRenderedCallback |
getFrameRenderedCallback()
Gets the frame rendered callback.
|
int |
getIFrameInterval()
Gets the I frame interval (
KEY_I_FRAME_INTERVAL ). |
int |
getIntVar(java.lang.String name)
Get int variable with the given name.
|
int |
getIntVar(java.lang.String name,
java.lang.String slot)
Get int variable with the given name.
|
int |
getKeyFrameRate()
Gets the key frame rate (
KEY_FRAME_RATE ). |
int |
getMaxSupportedVideoHeight()
Gets the maximum supported video height.
|
int |
getMaxSupportedVideoWidth()
Gets the maximum supported video width.
|
int |
getMinSupportedVideoHeight()
Gets the minimum supported video height.
|
int |
getMinSupportedVideoWidth()
Gets the minimum supported video width.
|
int |
getRenderHeight()
Gets the render height.
|
int |
getRenderWidth()
Gets the render width.
|
static java.lang.String |
getSdkVersion() |
java.lang.String |
getStringVar(java.lang.String name)
Get string variable with the given name.
|
java.lang.String |
getStringVar(java.lang.String name,
java.lang.String slot)
Get string variable with the given name.
|
ai.deepar.ar.VarType |
getVarType(java.lang.String name)
Get the type of the variable with the given name.
|
ai.deepar.ar.VarType |
getVarType(java.lang.String name,
java.lang.String slot)
Get the type of the variable with the given name in the specified effect.
|
boolean |
hasVar(java.lang.String name)
Check if the variable with the given name is already created in at least one effect.
|
boolean |
hasVar(java.lang.String name,
java.lang.String slot)
Check if variable with the given name is already created.
|
void |
initialize(android.content.Context context,
AREventListener eventListener)
Initializes the DeepAR engine.
|
void |
initialize(android.content.Context context,
AREventListener eventListener,
java.lang.String modelPath)
Initializes the DeepAR engine.
|
void |
moveGameObject(java.lang.String selectedGameObject,
java.lang.String targetGameObject)
Moves the selected game object from its current position in a tree and sets it as a direct child of a target game object.
|
void |
muteSound(boolean muteSound)
Mutes or un-mutes all the sounds that are currently playing.
|
void |
onImageAvailable(android.media.ImageReader imageReader)
Callback that is called when a new image is available from ImageReader.
|
void |
pauseVideoRecording()
Pauses the video recording.
|
void |
receiveFrame(java.nio.ByteBuffer buffer,
int width,
int height,
int orientation,
boolean mirror,
DeepARImageFormat imageFormat,
int pixelStride)
|
void |
receiveFrameExternalTexture(int width,
int height,
int orientation,
boolean mirror,
int externalGlTexture)
Notify DeepAR that new camera frame is available on the given external GL texture.
|
void |
release()
Releases all resources required by
DeepAR . |
void |
releaseExternalGlTexture(int textureHandle)
Release the external texture aqured from
getExternalGlTexture() . |
void |
resumeVideoRecording()
Resumes the video recording.
|
void |
setAnimationTransitionedCallback(DeepAR.AnimationTransitionedCallback animationTransitionedCallback)
Sets the animation transitioned callback.
|
void |
setAntialiasingLevel(int level)
Sets the MSAA level.
|
void |
setAREventListener(AREventListener listener)
Sets the
AREventListener for DeepAR object. |
void |
setAudioMute(boolean mute)
Mutes or unmutes the audio while video recording.
|
void |
setBitRate(int bitRate)
Sets the video bitrate.
|
void |
setBloomEnabled(boolean enable)
Toggles bloom postprocessing.
|
void |
setBloomRadius(float radius)
Sets bloom radius parameter.
|
void |
setBloomStrength(float strength)
Sets bloom strength parameter.
|
void |
setBloomThreshold(float threshold)
Sets bloom threshold parameter.
|
boolean |
setBoolVar(java.lang.String name,
boolean value)
Set the boolean variable with the given name.
|
boolean |
setBoolVar(java.lang.String name,
boolean value,
java.lang.String slot)
Set the boolean variable with the given name.
|
void |
setDiamondEnvironmentMap(android.graphics.Bitmap bitmap)
Sets new environment map that will be used for rendering materials with diamond shader.
|
boolean |
setDoubleVar(java.lang.String name,
double value)
Set the double variable with the given name.
|
boolean |
setDoubleVar(java.lang.String name,
double value,
java.lang.String slot)
Set the double variable with the given name.
|
void |
setEnvironmentMap(android.graphics.Bitmap bitmap)
Sets a new environment map that will be used for rendering materials with new PBR glTF shader.
|
void |
setEnvironmentMapIntensity(float environmentMapIntensity)
Sets environment map intensity.
|
void |
setExposure(float exposure)
Sets tone mapping exposure.
|
void |
setFaceDetectionSensitivity(int sensitivity)
This method allows the user to change face detection sensitivity.
|
void |
setFaceTrackedCallback(DeepAR.FaceTrackedCallback faceTrackedCallback)
Sets the face tracked callback.
|
void |
setFaceTrackingInitParameters(DeepAR.FaceTrackingInitParameters initParameters)
Sets parameters that will determine how the face tracking is initialized.
|
void |
setFixedDeltaTime(boolean isFixed,
float deltaTimeMs) |
void |
setFrameRenderedCallback(DeepAR.FrameRenderedCallback frameRenderedCallback)
Sets the frame rendered callback.
|
void |
setIFrameInterval(int iFrameInterval)
Sets the I frame interval (
KEY_I_FRAME_INTERVAL ). |
boolean |
setIntVar(java.lang.String name,
int value)
Set the int variable with the given name.
|
boolean |
setIntVar(java.lang.String name,
int value,
java.lang.String slot)
Set the int variable with the given name.
|
void |
setKeyFrameRate(int keyFrameRate)
Sets the key frame rate (
KEY_FRAME_RATE ). |
void |
setLicenseKey(java.lang.String key)
The method used to set the license key for your project.
|
void |
setOffscreenRendering(int width,
int height)
Calling this method sets the engine in off-screen rendering mode.
|
void |
setOffscreenRendering(int width,
int height,
DeepARPixelFormat format)
Calling this method sets the engine in off-screen rendering mode.
|
void |
setPaused(boolean paused)
Pauses or unpauses the rendering.
|
void |
setRenderSurface(android.view.Surface surface,
int width,
int height)
Calling this method sets the engine in on-screen rendering mode (cancels off-screen rendering if set before this call).
|
boolean |
setStringVar(java.lang.String name,
java.lang.String value)
Set the string variable with the given name.
|
boolean |
setStringVar(java.lang.String name,
java.lang.String value,
java.lang.String slot)
Set the string variable with the given name.
|
void |
setToneMapping(DeepAR.ToneMapping toneMapping)
Sets tone mapping.
|
void |
setVisionOnly()
Set DeepAR in the vision-only mode.
|
void |
showColliders(boolean enabled)
Display physics colliders preview on screen.
|
void |
showStats(boolean enabled)
Display debugging stats on screen.
|
void |
simulatePhysics(boolean enabled)
Enable or disable global physics simulation.
|
void |
startCapture()
Starts capturing the DeepAR processing output in an off-screen buffer.
|
void |
startCapture(DeepARPixelFormat format)
Starts capturing the DeepAR processing output in an off-screen buffer.
|
void |
startCapture(int width,
int height,
float xmin,
float xmax,
float ymin,
float ymax,
DeepARPixelFormat format)
Starts capturing the DeepAR processing output in an off-screen buffer.
|
void |
startPreparedVideoRecording()
Starts the prepared video recording.
|
void |
startProfiling() |
void |
startVideoRecording(java.io.FileDescriptor fd)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.io.FileDescriptor fd,
int outputWidth,
int outputHeight)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.io.FileDescriptor fd,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.io.FileDescriptor fd,
android.graphics.Rect subframe,
int outputWidth,
int outputHeight)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.io.FileDescriptor fd,
android.graphics.Rect subframe,
int outputWidth,
int outputHeight,
boolean recordAudio)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.lang.String filePath)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.lang.String filePath,
int outputWidth,
int outputHeight)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.lang.String filePath,
java.util.Map<java.lang.String,java.lang.Object> parameters)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.lang.String filePath,
android.graphics.Rect subframe,
int outputWidth,
int outputHeight)
Starts video recording of the camera preview.
|
void |
startVideoRecording(java.lang.String filePath,
android.graphics.Rect subframe,
int outputWidth,
int outputHeight,
boolean recordAudio)
Starts video recording of the camera preview.
|
void |
stopCapture()
Stops capturing the content of the DeepAR rendering process in the off-screen buffer.
|
void |
stopProfiling() |
void |
stopVideoRecording()
Stops video recording and starts the process of saving the recorded video to the file system.
|
void |
switchEffect(java.lang.String slot,
java.io.InputStream inputStream)
Same as
switchEffect , but uses an InputStream instead of a file path. |
void |
switchEffect(java.lang.String slot,
java.io.InputStream inputStream,
int face)
Same as
switchEffect , but uses an InputStream instead of a file path. |
void |
switchEffect(java.lang.String slot,
java.io.InputStream inputStream,
int face,
java.lang.String targetGameObject)
Same as
switchEffect , but uses an InputStream instead of a file path. |
void |
switchEffect(java.lang.String slot,
java.lang.String path)
The method used to switch any effect in the scene.
|
void |
switchEffect(java.lang.String slot,
java.lang.String path,
int face)
The method used to switch any effect in the scene.
|
void |
switchEffect(java.lang.String slot,
java.lang.String path,
int face,
java.lang.String targetGameObject)
The method used to switch any effect in the scene.
|
void |
takeScreenshot()
Captures a screenshot of the current screen.
|
void |
touchOccurred(ARTouchInfo touchInfo)
Informs DeepAR that the specified touch event occurred.
|
void |
useSingleThreadedMode(boolean useClientsGLContext)
This methods puts DeepAR in single-threaded mode.
|
public static final java.lang.String ERROR_MODEL_FILE_NOT_FOUND
public static final java.lang.String ERROR_EFFECT_FILE_LOAD_FAILED
public DeepAR(android.content.Context context)
context
- Android app context.public void changeLiveMode(boolean value)
receiveFrame
, and DeepAR would process it and stop rendering until a new frame is received. If we did so when the DeepAR is in live mode, it would process the same frame over and over again without ever stopping the rendering process, thus wasting processing time.value
- Enable or disable live mode.public void setFixedDeltaTime(boolean isFixed, float deltaTimeMs)
public void startProfiling()
public void stopProfiling()
public void setLicenseKey(java.lang.String key)
key
- The license key.public void initialize(android.content.Context context, AREventListener eventListener, java.lang.String modelPath)
DeepAR
.
This class should be instantiated and the method initialize should be called before use.
This is typically done in onCreate method in Android Activity.context
- Android app context.eventListener
- The event listener (with callback method implementations).modelPath
- Use if the model file is downloaded over the air. The model file is usually located in the assets folder. The default value for this parameter is file:///android_asset/models.bin and this value is used if modelPath is null.public void initialize(android.content.Context context, AREventListener eventListener)
DeepAR
.
This class should be instantiated and the method initialize should be called before use.
This is typically done in onCreate method in Android Activity.context
- Android app context.eventListener
- The event listener (with callback method implementations).public void startCapture()
AREventListener
method frameAvailable
will be called with the contents of that buffer any time a new frame is ready meaning the frame is processed by the DeepAR engine.
frameAvailable
will not be called unless this method is called explicitly.
User should call this method if they need to further process the DeepAR output like sending them over the network to implement video chat functionality.
This method allows the DeepAR to be simultaneously in both on-screen and off-screen rendering mode - one could display the frames in UI and collect them in the frameAvailable
.public void startCapture(DeepARPixelFormat format)
AREventListener
method frameAvailable
will be called with the contents of that buffer any time a new frame is ready meaning the frame is processed by the DeepAR engine.
frameAvailable
will not be called unless this method is called explicitly.
User should call this method if they need to further process the DeepAR output like sending them over the network to implement video chat functionality.
This method allows the DeepAR to be simultaneously in both on-screen and off-screen rendering mode - one could display the frames in UI and collect them in the frameAvailable
.format
- Specifies the output image frame pixel format of frameAvailable
method. Sometimes 3rd party libraries that do additional frame processing after DeepAR expect the input frames in a specific format (like video streaming libs) and it is controlled by this parameter.public void startCapture(int width, int height, float xmin, float xmax, float ymin, float ymax, DeepARPixelFormat format)
AREventListener
method frameAvailable
will be called with the contents of that buffer any time a new frame is ready meaning the frame is processed by the DeepAR engine.
frameAvailable
will not be called unless this method is called explicitly.
User should call this method if they need to further process the DeepAR output like sending them over the network to implement video chat functionality.
This method allows the DeepAR to be simultaneously in both on-screen and off-screen rendering mode - one could display the frames in UI and collect them in the frameAvailable
.width
- The output resolution width.height
- The output resolution height.xmin
- Sub-rectangle left point in unit coordinates (0.0 - 1.0).xmax
- Sub-rectangle right point in unit coordinates (0.0 - 1.0).ymin
- Sub-rectangle top point in unit coordinates (0.0 - 1.0).ymax
- Sub-rectangle bottom point in unit coordinates (0.0 - 1.0).format
- Specifies the output image frame pixel format of frameAvailable
method. Sometimes 3rd party libraries that do additional frame processing after DeepAR expect the input frames in a specific format (like video streaming libs) and it is controlled by this parameter.public void stopCapture()
public void setVisionOnly()
FaceData
.
To exit vision only mode call either setRenderSurface
or setOffscreenRendering
to switch DeepAR to rendering mode.public void setOffscreenRendering(int width, int height)
frameAvailable
method of the AREventListener
.
Calling this method will automatically stop any on-screen rendering.width
- The output width of the off-screen rendered image.height
- The output height of the off-screen rendered image.public void setOffscreenRendering(int width, int height, DeepARPixelFormat format)
frameAvailable
method of the AREventListener
.
Calling this method will automatically stop any on-screen rendering.width
- The output width of the off-screen rendered image.height
- The output height of the off-screen rendered image.format
- Specifies the output image frame pixel format of frameAvailable
method. Sometimes 3rd party libraries that do additional frame processing after DeepAR expect the input frames in a specific format (like video streaming libs) and it is controlled by this parameter.public void setRenderSurface(android.view.Surface surface, int width, int height)
surface
- The render surface, which is typically obtained in surfaceChanged method in SurfaceHolder.Callback. DeepAR engine uses SurfaceView to render 3D augmented reality elements. The SDK user is required to place the SurfaceView in the view hierarchy (through XML layout or manually from code). The user also needs to add a surface holder callback. DeepAR
.
private DeepAR deepAR; ... @Override public void surfaceCreated(SurfaceHolder surfaceHolder) { } @Override public void surfaceChanged(SurfaceHolder surfaceHolder, int format, int width, int height) { // Pass the surface object along with width and height to DeepAR instance. DeepAR object must be instantiated and initialized at this point. deepAR.setRenderSurface(surfaceHolder.getSurface(), width, height); } @Override public void surfaceDestroyed(SurfaceHolder surfaceHolder) { // If the surface is destroyed, DeepAR engine must be notified by passing null as the Surface object. The rendering will be paused after this call. deepAR.setRenderSurface(null,0,0); } ... }
width
- The surface width.height
- The surface height.public void release()
public void receiveFrame(java.nio.ByteBuffer buffer, int width, int height, int orientation, boolean mirror, DeepARImageFormat imageFormat, int pixelStride)
buffer
- The frame buffer.width
- The frame width.height
- The frame height.orientation
- The camera orientation.mirror
- Indicates that the camera is mirrored.imageFormat
- DeepAR image format.pixelStride
- Pixel stride.public void receiveFrameExternalTexture(int width, int height, int orientation, boolean mirror, int externalGlTexture)
SurfaceTexture.OnFrameAvailableListener#onFrameAvailable(SurfaceTexture)
.
The externalGlTexture must be acquired by getExternalGlTexture()
. Before calling this method, you must
call SurfaceTexture.updateTexImage()
on the SurfaceTexture created with externalGlTexture.
This method must be called on main thread!width
- width of the camera resolutionheight
- height of the camera resolutionorientation
- phone orientationmirror
- flag denoting should the image be mirroredexternalGlTexture
- Acquired by getExternalGlTexture()
and used to create SurfaceTexture
which was used as camera preview Surface.public void switchEffect(java.lang.String slot, java.io.InputStream inputStream) throws java.io.IOException
switchEffect
, but uses an InputStream instead of a file path.slot
- An arbitrary slot name.inputStream
- The effect data input stream.java.io.IOException
- When an IO error occurs.public void switchEffect(java.lang.String slot, java.io.InputStream inputStream, int face) throws java.io.IOException
switchEffect
, but uses an InputStream instead of a file path.slot
- An arbitrary slot name.inputStream
- The effect data input stream.face
- The face index. Valid values are 0, 1, 2 and 3.java.io.IOException
- When an IO error occurs.public void switchEffect(java.lang.String slot, java.io.InputStream inputStream, int face, java.lang.String targetGameObject) throws java.io.IOException
switchEffect
, but uses an InputStream instead of a file path.slot
- An arbitrary slot name.inputStream
- The effect data input stream.face
- The face index. Valid values are 0, 1, 2 and 3.targetGameObject
- The name of the node where the effect will be attached.java.io.IOException
- When an IO error occurs.public void switchEffect(java.lang.String slot, java.lang.String path)
deepAR.switchEffect("mask","file:///android_asset/flowers"); deepAR.switchEffect("filters","file:///android_asset/tv80");When tracking multiple faces is enabled this method only affects the first tracked face.
slot
- An arbitrary slot name.path
- The path to an effect file in the project which has been exported from DeepAR Studio.public void switchEffect(java.lang.String slot, java.lang.String path, int face)
// apply flowers effect to the first face deepAR.switchEffect("mask_f0","file:///android_asset/flowers",0); // apply beard effect to the second face deepAR.switchEffect("mask_f1","file:///android_asset/beard",1); // replace the effect on the first face with the lion deepAR.switchEffect("mask_f0","file:///android_asset/lion",0); // remove the beard effect from the second face deepAR.switchEffect("mask_f1",null,1);
slot
- An arbitrary slot name.path
- The path to an effect file in the project which has been exported from DeepAR Studio.face
- The face index. Valid values are 0, 1, 2 and 3.public void switchEffect(java.lang.String slot, java.lang.String path, int face, java.lang.String targetGameObject)
slot
- An arbitrary slot name.path
- The path to an effect file in the project which has been exported from DeepAR Studio.face
- The face index. Valid values are 0, 1, 2 and 3.targetGameObject
- The name of the node where the effect will be attached.public void takeScreenshot()
AREventListener
method screenshotTaken
will be called with a Bitmap parameter which will be the resulting screenshot.public boolean hasVar(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.public boolean hasVar(java.lang.String name)
name
- The variable name.public ai.deepar.ar.VarType getVarType(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.VarType
Variable type.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist.public ai.deepar.ar.VarType getVarType(java.lang.String name)
name
- The variable name.VarType
Variable type.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist.public boolean getBoolVar(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not a boolean.public boolean getBoolVar(java.lang.String name)
name
- The variable name.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not a boolean.public int getIntVar(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not an int.public int getIntVar(java.lang.String name)
name
- The variable name.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not an int.public double getDoubleVar(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not a double.public double getDoubleVar(java.lang.String name)
name
- The variable name.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not a double.public java.lang.String getStringVar(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not a string.public java.lang.String getStringVar(java.lang.String name)
name
- The variable name.java.lang.IllegalArgumentException
- if the variable with the specified name does not exist or the variable type is not a string.public boolean setBoolVar(java.lang.String name, boolean value, java.lang.String slot)
name
- The variable name.value
- Value to be set.slot
- The slot of the effect in which to set the variable.public boolean setBoolVar(java.lang.String name, boolean value)
name
- The variable name.value
- Value to be set.public boolean setIntVar(java.lang.String name, int value, java.lang.String slot)
name
- The variable name.value
- Value to be set.slot
- The slot of the effect in which to set the variable.public boolean setIntVar(java.lang.String name, int value)
name
- The variable name.value
- Value to be set.public boolean setDoubleVar(java.lang.String name, double value, java.lang.String slot)
name
- The variable name.value
- Value to be set.slot
- The slot of the effect in which to set the variable.public boolean setDoubleVar(java.lang.String name, double value)
name
- The variable name.value
- Value to be set.public boolean setStringVar(java.lang.String name, java.lang.String value, java.lang.String slot)
name
- The variable name.value
- Value to be set.slot
- The slot of the effect in which to set the variable.public boolean setStringVar(java.lang.String name, java.lang.String value)
name
- The variable name.value
- Value to be set.public boolean deleteVar(java.lang.String name, java.lang.String slot)
name
- The variable name.slot
- The slot of the effect in which to search the variable.public boolean deleteVar(java.lang.String name)
name
- The variable name.public boolean clearVars(java.lang.String slot)
slot
- ID of the effect from which to clear all the variables.public boolean clearVars()
public void setAREventListener(AREventListener listener)
AREventListener
for DeepAR
object.listener
- DeepAR event listener object (with implemented callbacks).public void onImageAvailable(android.media.ImageReader imageReader)
onImageAvailable
in interface android.media.ImageReader.OnImageAvailableListener
imageReader
- The ImageReader the callback is associated with.public int getRenderWidth()
public int getRenderHeight()
public void startPreparedVideoRecording()
public void startVideoRecording(java.lang.String filePath)
AREventListener
implementation.filePath
- The video file path.public void startVideoRecording(java.io.FileDescriptor fd)
AREventListener
implementation.fd
- The video file Descriptor.public void startVideoRecording(java.lang.String filePath, int outputWidth, int outputHeight)
AREventListener
implementation.filePath
- The video file path.outputWidth
- The output video width.outputHeight
- The output video height.public void startVideoRecording(java.io.FileDescriptor fd, int outputWidth, int outputHeight)
AREventListener
implementation.fd
- The video file descriptor.outputWidth
- The output video width.outputHeight
- The output video height.public void startVideoRecording(java.lang.String filePath, android.graphics.Rect subframe, int outputWidth, int outputHeight)
AREventListener
implementation.filePath
- The video file path.subframe
- Use to record only part of SurfaceView.outputWidth
- The output video width.outputHeight
- The output video height.public void startVideoRecording(java.io.FileDescriptor fd, android.graphics.Rect subframe, int outputWidth, int outputHeight)
AREventListener
implementation.fd
- The video file descriptor.subframe
- Use to record only part of SurfaceView.outputWidth
- The output video width.outputHeight
- The output video height.public void startVideoRecording(java.io.FileDescriptor fd, android.graphics.Rect subframe, int outputWidth, int outputHeight, boolean recordAudio)
AREventListener
implementation.fd
- The video file descriptor.subframe
- Use to record only part of SurfaceView.outputWidth
- The output video width.outputHeight
- The output video height.recordAudio
- Indicates whether audio will be recorded or not.public void startVideoRecording(java.io.FileDescriptor fd, java.util.Map<java.lang.String,java.lang.Object> parameters)
AREventListener
implementation.fd
- The video file descriptor.parameters
- A dictionary of parameters for configuring the video recording. The following parameters are supported:
public void startVideoRecording(java.lang.String filePath, android.graphics.Rect subframe, int outputWidth, int outputHeight, boolean recordAudio)
AREventListener
implementation.filePath
- The video file path.subframe
- Use to record only part of SurfaceView.outputWidth
- The output video width.outputHeight
- The output video height.recordAudio
- Indicates whether audio will be recorded or not.public void startVideoRecording(java.lang.String filePath, java.util.Map<java.lang.String,java.lang.Object> parameters)
AREventListener
implementation.filePath
- The video file path.parameters
- A dictionary of parameters for configuring the video recording. The following parameters are supported:
public int getMinSupportedVideoHeight()
public int getMaxSupportedVideoHeight()
public int getMinSupportedVideoWidth()
public int getMaxSupportedVideoWidth()
public void stopVideoRecording()
videoRecordingFinished
will be called.public void setAudioMute(boolean mute)
mute
- Indicates whether you want to mute or unmute the audio.public int getBitRate()
public void setBitRate(int bitRate)
bitRate
- The video bitrate.public int getIFrameInterval()
KEY_I_FRAME_INTERVAL
).public void setIFrameInterval(int iFrameInterval)
KEY_I_FRAME_INTERVAL
).
The default value is 5.iFrameInterval
- The I frame interval.public int getKeyFrameRate()
KEY_FRAME_RATE
).public void setKeyFrameRate(int keyFrameRate)
KEY_FRAME_RATE
).
The default value is 25.keyFrameRate
- The key frame rate.public DeepAR.FrameRenderedCallback getFrameRenderedCallback()
public void setFrameRenderedCallback(DeepAR.FrameRenderedCallback frameRenderedCallback)
frameRenderedCallback
- The frame rendered callback.public DeepAR.FaceTrackedCallback getFaceTrackedCallback()
public void setFaceTrackedCallback(DeepAR.FaceTrackedCallback faceTrackedCallback)
faceTrackedCallback
- The face tracked callback.public void setAnimationTransitionedCallback(DeepAR.AnimationTransitionedCallback animationTransitionedCallback)
animationTransitionedCallback
- Animation transitioned callback.public void setAntialiasingLevel(int level)
level
- The MSAA level.public void touchOccurred(ARTouchInfo touchInfo)
touchInfo
- Touch event information.public void pauseVideoRecording()
public void resumeVideoRecording()
public void changeParameterFloat(java.lang.String gameObject, java.lang.String component, java.lang.String parameter, float val)
gameObject
- The name of the node. If multiple nodes share the same name, only the first one will be affected.component
- The name of the component. If the name of the component is null or an empty string, the node itself will be affected.parameter
- The name of the parameter.val
- New parameter value.public void changeParameterBool(java.lang.String gameObject, java.lang.String component, java.lang.String parameter, boolean val)
gameObject
- The name of the node. If multiple nodes share the same name, only the first one will be affected.component
- The name of the component. If the name of the component is null or an empty string, the node itself will be affected.parameter
- The name of the parameter.val
- New parameter value.public void changeParameterVec4(java.lang.String gameObject, java.lang.String component, java.lang.String parameter, float valX, float valY, float valZ, float valW)
gameObject
- The name of the node. If multiple nodes share the same name, only the first one will be affected.component
- The name of the component. If the name of the component is null or an empty string, the node itself will be affected.parameter
- The name of the parameter.valX
- New parameter X value.valY
- New parameter Y value.valZ
- New parameter Z value.valW
- New parameter W value.public void changeParameterVec3(java.lang.String gameObject, java.lang.String component, java.lang.String parameter, float valX, float valY, float valZ)
gameObject
- The name of the node. If multiple nodes share the same name, only the first one will be affected.component
- The name of the component. If the name of the component is null or an empty string, the node itself will be affected.parameter
- The name of the parameter.valX
- New parameter X value.valY
- New parameter Y value.valZ
- New parameter Z value.public void changeParameterTexture(java.lang.String gameObject, java.lang.String component, java.lang.String parameter, android.graphics.Bitmap image)
gameObject
- The name of the node. If multiple nodes share the same name, only the first one will be affected.component
- The name of the component. If the name of the component is null or an empty string, the node itself will be affected.parameter
- The name of the parameter.image
- New parameter Bitmap texture.public void fireTrigger(java.lang.String trigger)
trigger
- The trigger name.public void setFaceDetectionSensitivity(int sensitivity)
sensitivity
- The sensitivity parameter can range from 0 to 3, where 0 is the fastest but might not recognize smaller (further away) faces, and 3 is the slowest but will find smaller faces. By default, this parameter is set to 1.public void setPaused(boolean paused)
shutdown
method to stop the engine and release the resources.paused
- Indicates whether to pause or unpause the rendering.public void showStats(boolean enabled)
enabled
- Enable debugging stats.public void simulatePhysics(boolean enabled)
enabled
- Enable global physics simulation.public void showColliders(boolean enabled)
enabled
- Enable physics colliders preview.public void moveGameObject(java.lang.String selectedGameObject, java.lang.String targetGameObject)
selectedGameObject
- Node to move.targetGameObject
- New node parent.public void useSingleThreadedMode(boolean useClientsGLContext)
receiveFrame(ByteBuffer, int, int, int, boolean, DeepARImageFormat, int)
or receiveFrameExternalTexture(int, int, int, boolean, int)
.
In single-threaded mode, calls to receiveFrame(ByteBuffer, int, int, int, boolean, DeepARImageFormat, int)
and receiveFrameExternalTexture(int, int, int, boolean, int)
will be blocking. When those methods return, the frame will be rendered in the surface set by setRenderSurface(Surface, int, int)
.
If you wish to call receiveFrameExternalTexture(int, int, int, boolean, int)
with parameter externalGlTexture set to texture that was not created
by getExternalGlTexture()
but rather to the texture created by your openGL context - then you must set useClientsGLContext flag.
When useClientsGLContext flag is set, then your OpenGL context must be made current before calling setRenderSurface(Surface, int, int)
.
This way DeepAR can initialize its internal OpenGL context by sharing your OpenGL context. Your OpenGL context will be preserved (current)
after calls to DeepAR methods that do rendering.
WARNING: This method must be called before first call to setRenderSurface(Surface, int, int)
.useClientsGLContext
- public int getExternalGlTexture()
receiveFrameExternalTexture(int, int, int, boolean, int)
.
This is a GL texture bound to GL_TEXTURE_EXTERNAL_OES. Use this GL texture to create SurfaceTexture
. Use created
SurfaceTexture as preview Surface for camera. When SurfaceTexture.OnFrameAvailableListener#onFrameAvailable(SurfaceTexture)
is called, call
receiveFrameExternalTexture(int, int, int, boolean, int)
to notify DeepAR of the new camera frame.
This method must be called on main thread!public void releaseExternalGlTexture(int textureHandle)
getExternalGlTexture()
.textureHandle
- public void setFaceTrackingInitParameters(DeepAR.FaceTrackingInitParameters initParameters)
initParameters
- DeepAR.FaceTrackingInitParameters
public void muteSound(boolean muteSound)
muteSound
- public void backgroundReplacement(boolean enable, android.graphics.Bitmap image)
enable
- - Boolean value indicating whether to enable or disable the background replacement effect.image
- - Image to be used as the background.public void backgroundBlur(boolean enable, int strength)
enable
- - Boolean value indicating whether to enable or disable the background blur effect.strength
- - Blur strength. Integer value in range 1-10.public void setEnvironmentMap(android.graphics.Bitmap bitmap)
bitmap
- image to be used as an environment map.public void setEnvironmentMapIntensity(float environmentMapIntensity)
environmentMapIntensity
- environment map intensitypublic void setExposure(float exposure)
exposure
- exposure valuepublic void setToneMapping(DeepAR.ToneMapping toneMapping)
toneMapping
- tone mapping functionpublic void setBloomEnabled(boolean enable)
public void setBloomThreshold(float threshold)
threshold
- bloom thresholdpublic void setBloomStrength(float strength)
strength
- bloom strengthpublic void setBloomRadius(float radius)
radius
- bloom radiuspublic void setDiamondEnvironmentMap(android.graphics.Bitmap bitmap)
bitmap
- Path to fetch or ArrayBuffer with an image.public static java.lang.String getSdkVersion()