Skip to main content

Meadow.Foundation.Sensors.Camera.UsefulSensors.PersonSensor

PersonSensor
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Camera.UsefulSensors.PersonSensor

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​
Declaration
public class PersonSensor : II2cPeripheral

Implements:
Meadow.Hardware.II2cPeripheral

Properties​

DefaultI2cAddress​

The default I2C address for the peripheral

View Source​
Declaration
public byte DefaultI2cAddress { get; }

MAX_FACE_COUNT​

The maximun number of faces the sensor can recognize

View Source​
Declaration
public int MAX_FACE_COUNT { get; }

MAX_IDS_COUNT​

The max number of specific face IDs the sensor can track

View Source​
Declaration
public int MAX_IDS_COUNT { get; }

Methods​

SetContinuousMode(bool)​

Sets the capture mode of the sensor

View Source​
Declaration
public void SetContinuousMode(bool enable)
Parameters​
TypeNameDescription
System.BooleanenableContinuous if true

SetSingleShotMode()​

Sets the Person Sensor to single-shot mode for inference.

View Source​
Declaration
public void SetSingleShotMode()

SetDebugMode(bool)​

Sets the debug mode for the Person Sensor.

View Source​
Declaration
public void SetDebugMode(bool enable)
Parameters​
TypeNameDescription
System.BooleanenableTrue to enable debug mode, False to disable.

SetEnableId(bool)​

Enables or disables the ID model for the Person Sensor.

View Source​
Declaration
public void SetEnableId(bool enable)
Parameters​
TypeNameDescription
System.BooleanenableTrue 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​
Declaration
public void SetPersistIds(bool enable)
Parameters​
TypeNameDescription
System.BooleanenableTrue to store recognized IDs even when unpowered, False otherwise.

SetEraseIds()​

Initiates wiping recognized IDs from storage for the Person Sensor.

View Source​
Declaration
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​
Declaration
public void SetCalibrateId(byte id)
Parameters​
TypeNameDescription
System.ByteidThe 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​
Declaration
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​
Declaration
public PersonSensorResults ParseSensorResults(byte[] data)
Returns​

Meadow.Foundation.Sensors.Camera.UsefulSensors.PersonSensorResults: The structured sensor data.

Parameters​
TypeNameDescription
System.Byte[]dataThe byte array containing sensor data.

Implements​

  • Meadow.Hardware.II2cPeripheral