keel-210 / OpenPose-Rig

tf-openpose and unity IK
98 stars 28 forks source link

data type conversion failed #5

Closed AndroidUnityGit closed 4 years ago

AndroidUnityGit commented 4 years ago

Hello, I ran the main scene in your project and encountered the same problem. The data type conversion failed. I used windows 10, unity2018.2

FormatException: Input string was not in the correct format System.Double.Parse (System.String s, NumberStyles style, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Double.cs:209) System.Single.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Single.cs:183) BoneController.m3 (System.String f) (at Assets/BoneController.cs:106) System.Linq.Enumerable+cIterator102[System.String,System.Single].MoveNext () System.Collections.Generic.List1[System.Single].AddEnumerable (IEnumerable1 enumerable) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:128) System.Collections.Generic.List1[System.Single]..ctor (IEnumerable1 collection) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:65) System.Linq.Enumerable.ToArray[Single] (IEnumerable1 source) BoneController.PointUpdate () (at Assets/BoneController.cs:106) BoneController.PointUpdateByTime () (at Assets/BoneController.cs:129) BoneController.Update () (at Assets/BoneController.cs:43)

keel-210 commented 4 years ago

I also tried using Unity 2018.4.9f1. But no error appeared. As far as the error message is seen, it seems that string parsing on line 106 has failed. However, in the latest commit, line 106 is brace, so it is unknown what kind of error has occurred. Check if the data is in the format. Since it was written a long time ago, it is recommended to rewrite the file reading part.

AndroidUnityGit commented 4 years ago

Hello ,Rewriting the file reading part. it can be run. float[] z = axis[1].Replace("[", "").Replace(Environment.NewLine, "").Split(' ').Where(s => s != "").Select(f => float.Parse(f)).ToArray();

float[] z = axis[1].Replace("[", "").Replace("\n", "").Split(' ').Where(s => s != "").Select(f => float.Parse(f)).ToArray();

“Environment.NewLine” This code doesn't work for me, Cause type conversion to fail

keel-210 commented 4 years ago

OK. I see. This is probably a bug due to Environment.NewLine not being \n in Windows. I modified lines 102 to 104 as follows. It maybe works. float[] z = axis[1].Replace("[", "").Replace("\r\n", "").Replace("\n", "").Split(' ').Where(s => s != "").Select(f => float.Parse(f)).ToArray(); Thank you!