Class CameraStream
- java.lang.Object
-
- com.google.ar.sceneform.rendering.CameraStream
-
public class CameraStream extends java.lang.Object
Displays the Camera stream using Filament.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CameraStream.DepthMode
The DepthMode Enum is used to reflect theSession
configuration for the DepthMode to decide if the occlusion material should be set and if frame.acquireDepthImage() or frame.acquireRawDepthImage() should be called to get the input data for the depth texture.static class
CameraStream.DepthOcclusionMode
Independent from theSession
configuration, the user can decide with the DeptModeUsage whichMaterial
should be set to the CameraStream renderable.
-
Field Summary
Fields Modifier and Type Field Description int
cameraStreamRenderable
static java.lang.String
MATERIAL_CAMERA_TEXTURE
static java.lang.String
MATERIAL_DEPTH_TEXTURE
-
Constructor Summary
Constructors Constructor Description CameraStream(int cameraTextureId, Renderer renderer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkIfDepthIsEnabled(com.google.ar.core.Session session, com.google.ar.core.Config config)
TheSession
holds the information if the DepthMode is configured or not.CameraStream.DepthMode
getDepthMode()
Gets the currently applied depth mode depending on the device supported modes.CameraStream.DepthOcclusionMode
getDepthOcclusionMode()
Gets the current Depth Occlusion Modeint
getRenderPriority()
void
initializeTexture(com.google.ar.core.Frame frame)
boolean
isDepthOcclusionModeSupported(CameraStream.DepthOcclusionMode depthOcclusionMode)
Checks whether the provided DepthOcclusionMode is supported on this device with the selected camera configuration and AR config.boolean
isTextureInitialized()
void
recalculateCameraUvs(com.google.ar.core.Frame frame)
void
recalculateOcclusion(android.media.Image depthImage)
Update the DepthTexture.void
setDepthOcclusionMode(CameraStream.DepthOcclusionMode depthOcclusionMode)
Set the DepthModeUsage toCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_ENABLED
to set the occlusionMaterial
.void
setRenderPriority(int priority)
-
-
-
Field Detail
-
MATERIAL_CAMERA_TEXTURE
public static final java.lang.String MATERIAL_CAMERA_TEXTURE
- See Also:
- Constant Field Values
-
MATERIAL_DEPTH_TEXTURE
public static final java.lang.String MATERIAL_DEPTH_TEXTURE
- See Also:
- Constant Field Values
-
cameraStreamRenderable
public int cameraStreamRenderable
-
-
Constructor Detail
-
CameraStream
public CameraStream(int cameraTextureId, Renderer renderer)
-
-
Method Detail
-
checkIfDepthIsEnabled
public void checkIfDepthIsEnabled(com.google.ar.core.Session session, com.google.ar.core.Config config)
TheSession
holds the information if the DepthMode is configured or not. Based on that result different materials and textures are used for the camera.- Parameters:
session
-Session
config
-Config
-
isTextureInitialized
public boolean isTextureInitialized()
-
initializeTexture
public void initializeTexture(com.google.ar.core.Frame frame)
-
recalculateOcclusion
public void recalculateOcclusion(android.media.Image depthImage)
Update the DepthTexture.
- Parameters:
depthImage
-Image
-
recalculateCameraUvs
public void recalculateCameraUvs(com.google.ar.core.Frame frame)
-
getRenderPriority
public int getRenderPriority()
-
setRenderPriority
public void setRenderPriority(int priority)
-
getDepthMode
public CameraStream.DepthMode getDepthMode()
Gets the currently applied depth mode depending on the device supported modes.
-
isDepthOcclusionModeSupported
public boolean isDepthOcclusionModeSupported(CameraStream.DepthOcclusionMode depthOcclusionMode)
Checks whether the provided DepthOcclusionMode is supported on this device with the selected camera configuration and AR config. The current list of supported devices is documented on the ARCore supported devices page.- Parameters:
depthOcclusionMode
- The desired depth mode to check.- Returns:
- True if the depth mode has been activated on the AR session config and the provided depth occlusion mode is supported on this device.
-
getDepthOcclusionMode
public CameraStream.DepthOcclusionMode getDepthOcclusionMode()
Gets the current Depth Occlusion Mode- Returns:
- the occlusion mode currently defined for the CarmeraStream
- See Also:
setDepthOcclusionMode(com.google.ar.sceneform.rendering.CameraStream.DepthOcclusionMode)
,CameraStream.DepthOcclusionMode
-
setDepthOcclusionMode
public void setDepthOcclusionMode(CameraStream.DepthOcclusionMode depthOcclusionMode)
Set the DepthModeUsage to
CameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_ENABLED
to set the occlusionMaterial
. This will process the incoming DepthImage to occlude virtual objects behind real world objects. If theSession
configuration for theConfig.DepthMode
is set toConfig.DepthMode.DISABLED
, the standard cameraMaterial
is used. Set the DepthModeUsage toCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_DISABLED
to set the standard cameraMaterial
. A good place to set the DepthModeUsage is inside of the onViewCreated() function call. To make sure that this function is called in your code set the correct listener on your Ar Fragmentpublic void onAttachFragment( FragmentManager fragmentManager, Fragment fragment ) { if (fragment.getId() == R.id.arFragment) { arFragment = (ArFragment) fragment; arFragment.setOnViewCreatedListener(this); arFragment.setOnSessionConfigurationListener(this); } } public void onViewCreated( ArFragment arFragment, ArSceneView arSceneView ) { arSceneView .getCameraStream() .setDepthModeUsage(CameraStream .setDepthOcclusionMode .DEPTH_OCCLUSION_DISABLED); }
The default value forCameraStream.DepthOcclusionMode
isCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_DISABLED
.- Parameters:
depthOcclusionMode
-CameraStream.DepthOcclusionMode
-
-