public static Chessboard Load(out Vector3[] fourImageCorners, Size projectorResolution) { var df = new DictionaryFile(File.ReadAllLines(FourCornersPath)); fourImageCorners = new[] { new Vector3(df.Get<float>("imageCorner0.X"), df.Get<float>("imageCorner0.Y"), 0), new Vector3(df.Get<float>("imageCorner1.X"), df.Get<float>("imageCorner1.Y"), 0), new Vector3(df.Get<float>("imageCorner2.X"), df.Get<float>("imageCorner2.Y"), 0), new Vector3(df.Get<float>("imageCorner3.X"), df.Get<float>("imageCorner3.Y"), 0), }; var tileCount = new Size(df.Get<int>("tileCount.Width"), df.Get<int>("tileCount.Height")); return new Chessboard(tileCount); }
private Size Load() { var df = new DictionaryFile(File.ReadAllLines(FourCornersPath)); ProjectorQuadCorners = new[] { new PointF(df.Get<float>("corner0.X"), df.Get<float>("corner0.Y")), new PointF(df.Get<float>("corner1.X"), df.Get<float>("corner1.Y")), new PointF(df.Get<float>("corner2.X"), df.Get<float>("corner2.Y")), new PointF(df.Get<float>("corner3.X"), df.Get<float>("corner3.Y")), }; return new Size(df.Get<int>("tileCount.Width"), df.Get<int>("tileCount.Height")); }
private static IntrinsicCameraParameters LoadCameraParameters(Size imageSize, Stream s) { using (var tr = new StreamReader(s)) { DictionaryFile df = new DictionaryFile(tr); var cp = new IntrinsicCameraParameters(); cp.DistortionCoeffs[CoefficientIndexOfK1, 0] = df.Get<double>("Lens.K1"); cp.DistortionCoeffs[CoefficientIndexOfK2, 0] = df.Get<double>("Lens.K2"); cp.DistortionCoeffs[CoefficientIndexOfK3, 0] = df.Get<double>("Lens.K3"); cp.IntrinsicMatrix[0, 2] = df.Get<double>("Lens.Cx") * imageSize.Width; cp.IntrinsicMatrix[1, 2] = df.Get<double>("Lens.Cy") * imageSize.Height; cp.IntrinsicMatrix[0, 0] = df.Get<double>("Lens.Fx") * imageSize.Width; cp.IntrinsicMatrix[1, 1] = df.Get<double>("Lens.Fy") * imageSize.Height; cp.IntrinsicMatrix[2, 2] = 1; return cp; } }