public CameraCalibrationModel LoadCalibration(string guid)
        {
            CameraCalibrationModel calibration = new CameraCalibrationModel()
            {
                CameraGuid = guid
            };
            TextReader reader = null;

            string path = String.Format(AppDomain.CurrentDomain.BaseDirectory + "\\cfg\\{0}.calib.json", guid);
            if (File.Exists(path))
            {
                try
                {
                    reader = new StreamReader(path);
                    string fileContents = reader.ReadToEnd();
                    calibration = JsonConvert.DeserializeObject<CameraCalibrationModel>(
                        fileContents,
                        new JsonIntrinsicCameraParametersConverter(),
                        new JsonExtrinsicCameraParametersConverter(),
                        new JsonMatrixConverter(),
                        new JsonPointFConverter());
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Close();
                    }
                }
            }
            return calibration;
        }
Пример #2
0
 public CameraModel()
 {
     Calibration = new CameraCalibrationModel();
     FPS = 60;
 }
Пример #3
0
 public CameraModel()
 {
     Calibration = new CameraCalibrationModel();
     FPS         = 60;
 }
 public void SaveCalibration(CameraCalibrationModel calibration)
 {
     TextWriter writer = null;
     try
     {
         string json = JsonConvert.SerializeObject(
             calibration,
             Formatting.Indented,
             new JsonIntrinsicCameraParametersConverter(),
             new JsonExtrinsicCameraParametersConverter(),
             new JsonMatrixConverter(),
             new JsonPointFConverter());
         writer = new StreamWriter(String.Format(AppDomain.CurrentDomain.BaseDirectory + "\\cfg\\{0}.calib.json", calibration.CameraGuid), false);
         writer.Write(json);
     }
     finally
     {
         if (writer != null) writer.Close();
     }
 }