# PersonSegmentationModule

The `PersonSegmentationModule` class enables the separation of a person from a scene.

## Example

```
//==============================================================================
// The following example demonstrates how to enable and disable segementation
// when detecting a person in the camera view as well as changing the opacity of
// a material depending on how close the person is to the camera.
//
// Project setup:
// - Follow the segmentation steps here (www.fb.me/spark-ar-using-segmentation)
//==============================================================================

// Load in the required modules
const Materials = require('Materials');
const PersonSegmentation = require('PersonSegmentation');
const Scene = require('Scene');

// Locate the rectangle and material in the Scene and Assets
const rectangle = Scene.root.find('rectangle0');
const rectangleMaterial = Materials.get('defaultMaterial0');

// Bind the foregroundPercent scalar signal to the opacity of the material
rectangleMaterial.opacity = PersonSegmentation.foregroundPercent;

// Bind the inverse of the hasForeground boolean signal to the hidden property
// of the rectangle
rectangle.hidden = PersonSegmentation.hasForeground.not();
```

## Properties

| Property            | Description                                                                                                                                                                                                              |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `foregroundPercent` | <p><code>(get) foregroundPercent: ScalarSignal (set) (Not Available)</code></p><p>Represents the percentage of screen space occupied by a person/people.</p>                                                             |
| `hasForeground`     | <p><code>(get) hasForeground: BoolSignal (set) (Not Available)</code></p><p>Represents whether there is anybody in the scene (TRUE/FALSE), based on whether the percentage of foreground is larger than a threshold.</p> |
| `isEnabled`         | <p><code>(get) (Not Available) (set) isEnabled: BoolSignal</code></p><p>Specifies whether the segmentation should be enabled. Default value is 'true'.</p>                                                               |

## Methods

This module exposes no methods.

## Classes

This module exposes no classes.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sparkar-community.gitbook.io/docs/personsegmentationmodule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
