Class CameraStream
- java.lang.Object
-
- com.google.ar.sceneform.rendering.CameraStream
-
public class CameraStream extends java.lang.ObjectDisplays the Camera stream using Filament.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCameraStream.DepthModeThe DepthMode Enum is used to reflect theSessionconfiguration 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 classCameraStream.DepthOcclusionModeIndependent from theSessionconfiguration, the user can decide with the DeptModeUsage whichMaterialshould be set to the CameraStream renderable.
-
Field Summary
Fields Modifier and Type Field Description intcameraStreamRenderablestatic java.lang.StringMATERIAL_CAMERA_TEXTUREstatic java.lang.StringMATERIAL_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 voidcheckIfDepthIsEnabled(com.google.ar.core.Session session, com.google.ar.core.Config config)TheSessionholds the information if the DepthMode is configured or not.CameraStream.DepthModegetDepthMode()Gets the currently applied depth mode depending on the device supported modes.CameraStream.DepthOcclusionModegetDepthOcclusionMode()Gets the current Depth Occlusion ModeintgetRenderPriority()voidinitializeTexture(com.google.ar.core.Frame frame)booleanisDepthOcclusionModeSupported(CameraStream.DepthOcclusionMode depthOcclusionMode)Checks whether the provided DepthOcclusionMode is supported on this device with the selected camera configuration and AR config.booleanisTextureInitialized()voidrecalculateCameraUvs(com.google.ar.core.Frame frame)voidrecalculateOcclusion(android.media.Image depthImage)Update the DepthTexture.voidsetDepthOcclusionMode(CameraStream.DepthOcclusionMode depthOcclusionMode)Set the DepthModeUsage toCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_ENABLEDto set the occlusionMaterial.voidsetRenderPriority(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)TheSessionholds the information if the DepthMode is configured or not. Based on that result different materials and textures are used for the camera.- Parameters:
session-Sessionconfig-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 toCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_ENABLEDto set the occlusionMaterial. This will process the incoming DepthImage to occlude virtual objects behind real world objects. If theSessionconfiguration for theConfig.DepthModeis set toConfig.DepthMode.DISABLED, the standard cameraMaterialis used. Set the DepthModeUsage toCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_DISABLEDto 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.DepthOcclusionModeisCameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_DISABLED.- Parameters:
depthOcclusionMode-CameraStream.DepthOcclusionMode
-
-