Skip to content

Commit d5287a9

Browse files
committed
Send blend shape message for each frame rather than streaming each individual blend shape
1 parent 241b49d commit d5287a9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

iPhoneMoCap/FaceGeoViewController.swift

+8-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,14 @@ class FaceGeoViewController: UIViewController, ARSessionDelegate, SocketControll
3838
self.view.addSubview(blurView)
3939

4040
blendShapeTracker.didGetBlendShapes = {
41-
$0.forEach {
42-
key, value in
43-
44-
self.socketController?.sendMessage(message: "\(key.rawValue) - \(Int(value.doubleValue * 100))")
45-
}
41+
42+
// Reduce all of the blend shapes into a message delimited by a |
43+
let message = $0.reduce("", {
44+
result, input in
45+
result.appending("\(input.key.rawValue) - \(Int(input.value.doubleValue * 100))|")
46+
})
47+
48+
self.socketController?.sendMessage(message: message)
4649
}
4750

4851

iPhoneMoCap/SocketController.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ class SocketController: NSObject, StreamDelegate, GCDAsyncUdpSocketDelegate {
6464
if (message?.contains("iPhoneMoCapBroadCast") ?? false) {
6565

6666
var host: NSString?
67-
var port1: UInt16 = 0
68-
GCDAsyncUdpSocket.getHost(&host, port: &port1, fromAddress: address)
67+
var port: UInt16 = 0
68+
69+
GCDAsyncUdpSocket.getHost(&host, port: &port, fromAddress: address)
6970

7071
if let host = host {
7172
hostReceived(host: String(host))

0 commit comments

Comments
 (0)