Ejemplo n.º 1
0
            public static Dictionary <string, NodeData> Load()
            {
                string jsonString = ParseDllInput();

                if (jsonString == null)
                {
                    return(null);
                }

                var JsonRootNode = JSON.Parse(jsonString);

                if (JsonRootNode == null)
                {
                    return(null);
                }

                var nodes = JsonRootNode.AsArray;

                Dictionary <string, NodeData> profiles = new Dictionary <string, NodeData>();

                int nodeCounter = 0;

                foreach (JSONNode n in nodes)
                {
                    string name = null;
                    try
                    {
                        name = n["name"];
                        // Matrix4x4 poseMat = Matrix4x4.zero;
                        double[] r = n["relative_pose"].AsArray.Childs.Select(d => Double.Parse(d)).ToArray();
                        if (r.Length < 12)
                        {
                            // Debug.LogError("CalibrationParameterLoader: array was too short.");
                            // throw();
                        }

                        double[] cameraModel = n["camera_model"].AsArray.Childs.Select(d => Double.Parse(d)).ToArray();

                        profiles.Add(name, new NodeData {
                            entry_name = name, pose_data = r, projection_model_data = cameraModel
                        });

                        // Debug.Log(profiles[name].RelativePose + "|||" +
                        //          string.Join(" ", (profiles[name].CameraModel.Select(x => x.ToString())).ToArray()));
                    }
                    catch
                    {
                        if (name != null)
                        {
                            //Debug.LogError(
                            //    string.Format(
                            //        "CalibrationParameter parsing error: node named '{0}' was not formatted correctly.", name));
                        }
                        else
                        {
                            //Debug.LogError(
                            //    string.Format("CalibrationParameter parsing error: node {0} was not formatted correctly.",
                            //        nodeCounter));
                        }
                    }

                    nodeCounter++;
                }

                return(profiles);
            }
Ejemplo n.º 2
0
		} //CanConvertFrom
		public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
			string[] extrema = ((string)value).Split(new char[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
			return new Domain(Numeric.Parse(extrema[0]), Numeric.Parse(extrema[1]), Numeric.Parse(extrema[2]), Numeric.Parse(extrema[3]));
		} //ConvertFrom