Skip to content

Commit

Permalink
Merge pull request #8 from Presage-Security/sync
Browse files Browse the repository at this point in the history
add face mesh points example from sdk
  • Loading branch information
jimwinkpresage authored Aug 23, 2024
2 parents 3d74285 + df635b5 commit 2c1e4ee
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,31 @@ You can display the strict breathing rate and pulse rate which is the average of
```Swift
SmartSpectraSwiftUIView()
```

### Displaying face mesh points

You can display the face mesh points by following the example in [ContentView.swift](Test%20SmartSpectra%20SDK/ContentView.swift)

```Swift
if !sdk.meshPoints.isEmpty {
// Visual representation of mesh points
GeometryReader { geometry in
ZStack {
ForEach(Array(sdk.meshPoints.enumerated()), id: \.offset) { index, point in
Circle()
.fill(Color.blue)
.frame(width: 3, height: 3)
.position(x: CGFloat(point.x) * geometry.size.width / 1280.0,
y: CGFloat(point.y) * geometry.size.height / 1280.0)
}
}
}
.frame(width: 400, height: 400) // Adjust the height as needed
}
```

Since the mesh points are published you can also use `combine` to subscribe to the mesh points to add a custom callback to further process the mesh points.

### Extracting Metrics Data
To extract metrics data from the SDK import the following into your content view:
```Swift
Expand Down
16 changes: 16 additions & 0 deletions Test SmartSpectra SDK/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ struct ContentView: View {
if !sdk.ie.isEmpty {
LineChartView(orderedPairs: sdk.ie, title: "IE", xLabel: "Time", yLabel: "Value", showYTicks: true)
}

if !sdk.meshPoints.isEmpty {
// Visual representation of mesh points
GeometryReader { geometry in
ZStack {
ForEach(Array(sdk.meshPoints.enumerated()), id: \.offset) { index, point in
Circle()
.fill(Color.blue)
.frame(width: 3, height: 3)
.position(x: CGFloat(point.x) * geometry.size.width / 1280.0,
y: CGFloat(point.y) * geometry.size.height / 1280.0)
}
}
}
.frame(width: 400, height: 400) // Adjust the height as needed
}
}
}
}
Expand Down

0 comments on commit 2c1e4ee

Please sign in to comment.