public PointF GetPhysicalPoint(PointF cameraPoint)
        {
            CalibrationPoint closestCalibrationPoint = FindClosesCalibrationPoint(cameraPoint);
            PointF           physicalPoint           = closestCalibrationPoint.GetPhysicalPoint(cameraPoint);

            return(physicalPoint);
        }
        public void Initialize(string serializedData)
        {
            string line;

            using (StringReader reader = new StringReader(serializedData))
            {
                line = reader.ReadLine();
                ParseXYCount(line);

                m_CalibrationPoints = new CalibrationPoint[m_XCount, m_YCount];
                for (int i = 0; i < m_XCount; i++)
                {
                    for (int j = 0; j < m_YCount; j++)
                    {
                        line = reader.ReadLine();
                        m_CalibrationPoints[i, j] = CalibrationPoint.Parse(line);
                    }
                }
            }
        }
        public void Initialize(CameraVsPhysicalPoint[,] cameraVsPhysicalPoints)
        {
            m_XCount            = cameraVsPhysicalPoints.GetLength(0);
            m_YCount            = cameraVsPhysicalPoints.GetLength(1);
            m_CalibrationPoints = new CalibrationPoint[m_XCount, m_YCount];

            CameraVsPhysicalPoint center, left, right, above, below;

            for (int i = 0; i < m_XCount; i++)
            {
                for (int j = 0; j < m_YCount; j++)
                {
                    center = cameraVsPhysicalPoints[i, j];
                    left   = (i == 0 ? null : cameraVsPhysicalPoints[i - 1, j]);
                    right  = (i == m_XCount - 1 ? null : cameraVsPhysicalPoints[i + 1, j]);
                    above  = (j == 0 ? null : cameraVsPhysicalPoints[i, j - 1]);
                    below  = (j == m_YCount - 1 ? null : cameraVsPhysicalPoints[i, j + 1]);

                    m_CalibrationPoints[i, j] = new CalibrationPoint(center, left, right, above, below);
                }
            }
        }
		public void Initialize(CameraVsPhysicalPoint[,] cameraVsPhysicalPoints)
		{
			m_XCount = cameraVsPhysicalPoints.GetLength(0);
			m_YCount = cameraVsPhysicalPoints.GetLength(1);
			m_CalibrationPoints = new CalibrationPoint[m_XCount, m_YCount];

			CameraVsPhysicalPoint center, left, right, above, below;

			for (int i = 0; i < m_XCount; i++)
			{
				for (int j = 0; j < m_YCount; j++)
				{
					center = cameraVsPhysicalPoints[i,j];
					left = (i == 0 ? null : cameraVsPhysicalPoints[i - 1, j]);
					right = (i == m_XCount - 1 ? null : cameraVsPhysicalPoints[i + 1, j]);
					above = (j == 0 ? null : cameraVsPhysicalPoints[i, j - 1]);
					below = (j == m_YCount - 1 ? null : cameraVsPhysicalPoints[i, j + 1]);

					m_CalibrationPoints[i, j] = new CalibrationPoint(center, left, right, above, below);
				}
			}
		}
        private CalibrationPoint FindClosesCalibrationPoint(PointF cameraPoint)
        {
            CalibrationPoint closestCalibrationPoint = null;
            float            closestDistance         = float.MaxValue;

            for (int i = 0; i < m_XCount; i++)
            {
                for (int j = 0; j < m_YCount; j++)
                {
                    PointF calibrationCameraPoint = m_CalibrationPoints[i, j].CameraPoint;
                    float  distance =
                        (cameraPoint.X - calibrationCameraPoint.X) * (cameraPoint.X - calibrationCameraPoint.X) +
                        (cameraPoint.Y - calibrationCameraPoint.Y) * (cameraPoint.Y - calibrationCameraPoint.Y);

                    if (distance < closestDistance)
                    {
                        closestDistance         = distance;
                        closestCalibrationPoint = m_CalibrationPoints[i, j];
                    }
                }
            }

            return(closestCalibrationPoint);
        }