Example #1
0
        public static CalibrateInfo GetCalibrationInfo(string MatrixPath, string DistCoeffsPath, Size SizePattern, Rectangle ROI)
        {
            CalibrateInfo info = new CalibrateInfo();
            Rectangle     roi  = ROI;

            info.CameraMatrix = new Matrix <double>(3, 3);
            info.DistCoeffs   = new Matrix <double>(8, 1);
            FileInfo fi = new FileInfo(MatrixPath);

            string[] matrixStr = File.ReadAllLines(fi.FullName);
            fi = new FileInfo(DistCoeffsPath);
            string disStr = File.ReadAllText(fi.FullName);

            for (int i = 0; i < matrixStr.Length; i++)
            {
                string[] val = matrixStr[i].Split(' ');
                for (int j = 0; j < val.Length; j++)
                {
                    info.CameraMatrix[i, j] = Convert.ToDouble(val[j]);
                }
            }
            string[] disval = disStr.Split(' ');
            for (int j = 0; j < disval.Length; j++)
            {
                info.DistCoeffs[j, 0] = Convert.ToDouble(disval[j]);
            }
            info.NewCameraMatrix = CvInvoke.GetOptimalNewCameraMatrix(info.CameraMatrix, info.DistCoeffs, SizePattern, 1, SizePattern, ref roi);
            info.ROI             = roi;
            return(info);
        }
Example #2
0
 public static CalibrateInfo GetIntance()
 {
     if (mCalibrate == null)
     {
         mCalibrate = UpdateInstance();
     }
     return(mCalibrate);
 }