public void LoadFromFile(Stream file, string path)
        {
            XmlDocument dataDoc = new XmlDocument();
            dataDoc.Load(file);

            _pointList.Clear();
            XmlNodeList points = dataDoc.GetElementsByTagName("Point");
            foreach(XmlNode pointNode in points)
            {
                Camera3DPoint point = new Camera3DPoint();

                var imgx = pointNode.Attributes["imgx"];
                if(imgx != null)
                    point.Cam1Img.X = double.Parse(imgx.Value);

                var imgy = pointNode.Attributes["imgy"];
                if(imgy != null)
                    point.Cam1Img.Y = double.Parse(imgy.Value);

                var realx = pointNode.Attributes["realx"];
                if(imgy != null)
                    point.Real.X = double.Parse(realx.Value);

                var realy = pointNode.Attributes["realy"];
                if(realy != null)
                    point.Real.Y = double.Parse(realy.Value);

                var realz = pointNode.Attributes["realz"];
                if(realz != null)
                    point.Real.Z = double.Parse(realz.Value);

                _pointList.Add(point);
            }
        }
        private void CrossCheckMatches()
        {
            MatchedPoints = new List<CamCore.Camera3DPoint>();
            int y, x;
            int ps2 = _patchSize / 2;
            double disp_xl, disp_yl, disp_xr, disp_yr;

            for (y = ps2; y < FinalSizeY - ps2; ++y)
            {
                for (x = ps2; x < FinalSizeX - ps2; ++x)
                {
                    if(_leftDisparities[0][y,x] > 0) // if point matched
                    {
                        disp_xl = _leftDisparities[1][y, x];
                        disp_yl = _leftDisparities[2][y, x];

                        disp_xr = _rightDisparities[1][y + (int)disp_yl, x + (int)disp_xl];
                        disp_yr = _rightDisparities[2][y + (int)disp_yl, x + (int)disp_xl];

                        if(Math.Abs((disp_xl+disp_xr)) + Math.Abs(disp_yl+disp_yr) <= 2)
                        {
                            CamCore.Camera3DPoint matchedPoint = new CamCore.Camera3DPoint()
                            {
                                Cam1Img = new Vector2(x, y),
                                Cam2Img = new Vector2(x + (disp_xl - disp_xr) / 2, y + (disp_yl - disp_yr) / 2)
                            };
                            MatchedPoints.Add(matchedPoint);
                        }
                    }
                }
            }
        }
 private void AddPoint(object sender, RoutedEventArgs e)
 {
     Camera3DPoint point = new Camera3DPoint();
     _pointList.Add(point);
 }
        private void MatchFeatures()
        {
            int y, x;
            double bestMatch, match;
            CamCore.Camera3DPoint matchPoint = new CamCore.Camera3DPoint();
            int ps2 = _patchSize / 2;

            // For each point in feature map check if theres feature
            // if yes then find best match
            for(y = ps2; y < FinalSizeY - ps2; ++y)
            {
                for(x = ps2; x < FinalSizeX - ps2; ++x)
                {
                    if(!(_leftFeatureMap[y, x] > 0.0f))
                        continue;

                    bestMatch = 0.0f;
                    matchPoint.Cam1Img = new Vector2(x, y);

                    int dxMax, dxMin, dyMax, dyMin, dx, dy;
                    // Search boundaries such as not to exceed image dimensions
                    dxMin = 0;
                    dxMax = Math.Min(_maxDispX, -x + FinalSizeX - ps2 - 1);
                    dyMin = Math.Max(-_maxDispY, -y + ps2 + 1);
                    dyMax = Math.Min(_maxDispY, -y + FinalSizeY - ps2 - 1);
                    // In expected disparity area find corners and compare patches
                    _leftPatch.StartCol = x - ps2;
                    _leftPatch.StartRow = y - ps2;
                    for(dx = dxMin; dx <= dxMax; dx++)
                    {
                        for(dy = dyMin; dy <= dyMax; dy++)
                        {
                            if((_rightFeatureMap[y + dy, x + dx] > 0.0f))
                            {
                                _rightPatch.StartCol = x + dx - ps2;
                                _rightPatch.StartRow = y + dy - ps2;
                                match = _corrComputer(_leftPatch, _rightPatch, 1.3f * _LoG_sigma);

                                if(match > bestMatch)
                                {
                                    bestMatch = match;
                                    matchPoint.Cam2Img = new Vector2(x + dx, y + dy);
                                }
                            }

                        }
                    }

                    if(bestMatch > _t_match)
                    {
                        MatchedPoints.Add(matchPoint);
                        matchPoint = new CamCore.Camera3DPoint();
                    }

                }
            }
        }