> For the complete documentation index, see [llms.txt](https://sparkar-community.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sparkar-community.gitbook.io/docs/personsegmentationmodule.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
