Esempio n. 1
0
        public double[] getCameraIntri()
        {
            byte[]  reply          = sendRequest(Command.GetCameraIntri);
            JObject info           = JObject.Parse(System.Text.Encoding.Default.GetString(reply.Skip(SIZE_OF_JSON).ToArray()));
            string  intri_original = info["camera_intri"]["intrinsic"].ToString();
            int     start          = intri_original.LastIndexOf('[');
            int     end            = intri_original.LastIndexOf(']');
            int     length         = intri_original.Length;

            if (start == -1 || end == -1 || end < start)
            {
                Console.WriteLine("Wrong camera intrinsics");
                return(null);
            }
            string intri_str = intri_original.Remove(0, start + 1).Substring(0, end - start - 1);

            string[] intrivalue_str = intri_str.Split(',');
            if (intrivalue_str.Length != 4)
            {
                Console.WriteLine("Wrong intrinscis value");
                return(null);
            }
            CameraIntri intri = new CameraIntri();

            intri.setValue(double.Parse(intrivalue_str[0]),
                           double.Parse(intrivalue_str[1]),
                           double.Parse(intrivalue_str[2]),
                           double.Parse(intrivalue_str[3])
                           );
            double[] rel = intri.getValue();
            return(rel);
        }
        public double[] getCameraIntri()
        {
            Mmind.Response reply          = sendRequest(GetCameraIntri, 0.0, "");
            string         intri_original = reply.CamIntri;
            int            start          = intri_original.LastIndexOf('[');
            int            end            = intri_original.LastIndexOf(']');
            int            length         = intri_original.Length;

            if (start == -1 || end == -1 || end < start)
            {
                Console.WriteLine("Wrong camera intrinsics");
                return(null);
            }
            string intri_str = intri_original.Remove(0, start + 1).Substring(0, end - start - 1);

            string[] intrivalue_str = intri_str.Split(',');
            if (intrivalue_str.Length != 4)
            {
                Console.WriteLine("Wrong intrinscis value");
                return(null);
            }
            CameraIntri intri = new CameraIntri();

            intri.setValue(double.Parse(intrivalue_str[0]),
                           double.Parse(intrivalue_str[1]),
                           double.Parse(intrivalue_str[2]),
                           double.Parse(intrivalue_str[3])
                           );
            double[] rel = intri.getValue();
            //Console.WriteLine("fx = " + rel[0].ToString());
            //Console.WriteLine("fy = " + rel[1].ToString());
            //Console.WriteLine("u = " + rel[2].ToString());
            //Console.WriteLine("v = " + rel[3].ToString());
            return(rel);
        }