From e4fc681ff4b164e3e2130d24697176676beb562e Mon Sep 17 00:00:00 2001 From: Ganesh Saraswat Date: Sat, 2 Sep 2023 21:42:06 -0600 Subject: [PATCH] fixed float parse bug made float parsing cultural invariant (caused some problems in non english languages) --- UnityMediaPipeBody/Assets/PipeServer.cs | 6 +++++- mediapipebody/body.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/UnityMediaPipeBody/Assets/PipeServer.cs b/UnityMediaPipeBody/Assets/PipeServer.cs index c391866..4c9ab56 100644 --- a/UnityMediaPipeBody/Assets/PipeServer.cs +++ b/UnityMediaPipeBody/Assets/PipeServer.cs @@ -202,6 +202,8 @@ public class PipeServer : MonoBehaviour private void Start() { + System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + body = new Body(lParent,landmarkPrefab,linePrefab,landmarkScale,enableHead?headPrefab:null); Thread t = new Thread(new ThreadStart(Run)); @@ -233,6 +235,8 @@ public class PipeServer : MonoBehaviour void Run() { + System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; + // Open the named pipe. server = new NamedPipeServerStream("UnityMediaPipeBody",PipeDirection.InOut, 99, PipeTransmissionMode.Message); @@ -240,7 +244,7 @@ public class PipeServer : MonoBehaviour server.WaitForConnection(); print("Connected."); - var br = new BinaryReader(server); + var br = new BinaryReader(server, Encoding.UTF8); while (true) { diff --git a/mediapipebody/body.py b/mediapipebody/body.py index 4ed9101..5884483 100644 --- a/mediapipebody/body.py +++ b/mediapipebody/body.py @@ -106,7 +106,7 @@ class BodyThread(threading.Thread): for i in range(0,33): self.data += "{}|{}|{}|{}\n".format(i,hand_world_landmarks.landmark[i].x,hand_world_landmarks.landmark[i].y,hand_world_landmarks.landmark[i].z) - s = self.data.encode('ascii') + s = self.data.encode('utf-8') try: self.pipe.write(struct.pack('I', len(s)) + s) self.pipe.seek(0)