Class CameraStream


  • public class CameraStream
    extends java.lang.Object
    Displays the Camera stream using Filament.
    • 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)
        The Session 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.
      • setDepthOcclusionMode

        public void setDepthOcclusionMode​(CameraStream.DepthOcclusionMode depthOcclusionMode)
             Set the DepthModeUsage to CameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_ENABLED to set the
             occlusion Material. This will process the incoming DepthImage to
             occlude virtual objects behind real world objects. If the Session configuration
             for the Config.DepthMode is set to Config.DepthMode.DISABLED,
             the standard camera Material is used.
        
             Set the DepthModeUsage to CameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_DISABLED to set the
             standard camera Material.
        
             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 Fragment
        
             public 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 for CameraStream.DepthOcclusionMode is CameraStream.DepthOcclusionMode.DEPTH_OCCLUSION_DISABLED.
         
        Parameters:
        depthOcclusionMode - CameraStream.DepthOcclusionMode