Combining Ground Segmentation and Connected Templates

Theo Knoll
Theo Knoll Posts: 1
edited November 2022 in General #1

How do you combine the Ground Segmentation Template with the Connected Lens Template? I am having trouble getting the camera from the different templates to play well together and display a texture over the ground.


  • Bakari Mustafa
    Bakari Mustafa Posts: 178 🔥🔥🔥

    To combine the Ground Segmentation template with the Connected Lens template, you will need to modify the scripts and assets from both templates to work together in a single project. Here are the steps you can follow to do this:

    1. Create a new project in Lens Studio and choose the Connected Lens template. This will create a new project with the necessary scripts and assets for creating a connected lens.
    2. Import the ground segmentation script: In the Assets panel, click the "Import" button and select the "Scripts/GroundSegmentation.script" file from the Ground Segmentation template. This will add the ground segmentation script to your project.
    3. Add a Depth component to your scene: Drag a Depth component from the Object Library onto the root object of your scene. This will generate a depth map for the scene.
    4. Create a new script to combine the two templates: Create a new script and attach it to the root object of your scene. In the script, use the "Depth" output of the Depth component to get a grayscale image that represents the depth of the scene. Then use the ground segmentation script to detect the position of the ground in the scene and apply a texture to it.
    5. Modify the Connected Lens script: In the Connected Lens template, the "Scripts/ConnectedLens.script" file contains the code that handles the connection to Snapchat and the display of the lens. You will need to modify this script to use the depth map and the ground segmentation script to display the texture on the ground.