Meadow.Foundation.Sensors.Camera.UsefulSensors.PersonSensor
| PersonSensor | |
|---|---|
| Status | |
| Source code | GitHub |
| Datasheet(s) | GitHub |
| NuGet package |
Code Example
PersonSensor personSensor;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
personSensor = new PersonSensor(Device.CreateI2cBus());
return Task.CompletedTask;
}
public override Task Run()
{
while (true)
{
var sensorData = personSensor.GetSensorData();
DisplaySensorData(sensorData);
Thread.Sleep(1500);
}
}
private void DisplaySensorData(PersonSensorResults sensorData)
{
if (sensorData.NumberOfFaces == 0)
{
Resolver.Log.Info("No faces found");
return;
}
for (int i = 0; i < sensorData.NumberOfFaces; ++i)
{
var face = sensorData.FaceData[i];
Resolver.Log.Info($"Face #{i}: {face.BoxConfidence} confidence, ({face.BoxLeft}, {face.BoxTop}), ({face.BoxRight}, {face.BoxBottom}), facing: {face.IsFacing}");
}
}
Sample project(s) available on GitHub
API Reference
Class PersonSensor
Represents a Useful Sensor's Person Sensor
Assembly: UsefulSensorsPersonSensor.dll
View Source
public class PersonSensor : II2cPeripheral
Implements:
Meadow.Hardware.II2cPeripheral
Properties
DefaultI2cAddress
The default I2C address for the peripheral
View Source
public byte DefaultI2cAddress { get; }
MAX_FACE_COUNT
The maximun number of faces the sensor can recognize
View Source
public int MAX_FACE_COUNT { get; }
MAX_IDS_COUNT
The max number of specific face IDs the sensor can track
View Source
public int MAX_IDS_COUNT { get; }
Methods
SetContinuousMode(bool)
Sets the capture mode of the sensor
View Source
public void SetContinuousMode(bool enable)
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | enable | Continuous if true |
SetSingleShotMode()
Sets the Person Sensor to single-shot mode for inference.
View Source
public void SetSingleShotMode()
SetDebugMode(bool)
Sets the debug mode for the Person Sensor.
View Source
public void SetDebugMode(bool enable)
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | enable | True to enable debug mode, False to disable. |
SetEnableId(bool)
Enables or disables the ID model for the Person Sensor.
View Source
public void SetEnableId(bool enable)
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | enable | True to enable the ID model, False to disable. |
| With this flag set to False, only bounding boxes are captured. |
SetPersistIds(bool)
Sets whether to persist recognized IDs even when unpowered for the Person Sensor.
View Source
public void SetPersistIds(bool enable)
Parameters
| Type | Name | Description |
|---|---|---|
System.Boolean | enable | True to store recognized IDs even when unpowered, False otherwise. |
SetEraseIds()
Initiates wiping recognized IDs from storage for the Person Sensor.
View Source
public void SetEraseIds()
SetCalibrateId(byte)
Initiates calibration for the next identified frame as a specific person ID (0 to 7) for the Person Sensor.
View Source
public void SetCalibrateId(byte id)
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte | id | The person ID to calibrate. |
Exceptions
System.Exception
Thrown if the specified ID exceeds the maximum number of IDs.
GetSensorData()
Gets the structured sensor data.
View Source
public PersonSensorResults GetSensorData()
Returns
Meadow.Foundation.Sensors.Camera.UsefulSensors.PersonSensorResults: The structured sensor data.
ParseSensorResults(byte[])
Parses the sensor results from the provided byte array.
View Source
public PersonSensorResults ParseSensorResults(byte[] data)
Returns
Meadow.Foundation.Sensors.Camera.UsefulSensors.PersonSensorResults: The structured sensor data.
Parameters
| Type | Name | Description |
|---|---|---|
System.Byte[] | data | The byte array containing sensor data. |
Implements
Meadow.Hardware.II2cPeripheral