Пример #1
0
        public List<CalibrationPoint> AddNoise(List<CalibrationPoint> points,
            double varReal, double varImg, int seed = 0)
        {
            List<CalibrationPoint> noisedPoints = new List<CalibrationPoint>(points.Count);

            GaussianNoiseGenerator noiseReal = new GaussianNoiseGenerator();
            noiseReal.Variance = varReal;
            noiseReal.Mean = 0.0;
            noiseReal.RandomSeed = seed != 0;
            noiseReal.Seed = seed;
            noiseReal.UpdateDistribution();

            GaussianNoiseGenerator noiseImage = new GaussianNoiseGenerator();
            noiseImage.Variance = varImg;
            noiseImage.Mean = 0.0;
            noiseImage.RandomSeed = seed != 0;
            noiseImage.Seed = seed;
            noiseImage.UpdateDistribution();

            for(int i = 0; i < _pointsCount; ++i)
            {
                CalibrationPoint cpoint = new CalibrationPoint();

                cpoint.RealX = points[i].RealX + noiseReal.GetSample();
                cpoint.RealY = points[i].RealY + noiseReal.GetSample();
                cpoint.RealZ = points[i].RealZ + noiseReal.GetSample();

                cpoint.ImgX = points[i].ImgX + noiseImage.GetSample();
                cpoint.ImgY = points[i].ImgY + noiseImage.GetSample();

                noisedPoints.Add(cpoint);
            }

            return noisedPoints;
        }
        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)
            {
                CalibrationPoint cpoint = new CalibrationPoint();
                var imgx = pointNode.Attributes["imgx"];
                if(imgx != null)
                    cpoint.ImgX = double.Parse(imgx.Value);

                var imgy = pointNode.Attributes["imgy"];
                if(imgy != null)
                    cpoint.ImgY = double.Parse(imgy.Value);

                var gridNum = pointNode.Attributes["grid"];
                if(gridNum != null)
                    cpoint.GridNum = int.Parse(gridNum.Value);

                var col = pointNode.Attributes["gridColumn"];
                if(col != null)
                    cpoint.RealCol = int.Parse(col.Value);

                var row = pointNode.Attributes["gridRow"];
                if(row != null)
                    cpoint.RealRow = int.Parse(row.Value);

                var realx = pointNode.Attributes["realx"];
                if(realx != null)
                    cpoint.RealX = double.Parse(realx.Value);

                var realy = pointNode.Attributes["realy"];
                if(realy != null)
                    cpoint.RealY = double.Parse(realy.Value);

                var realz = pointNode.Attributes["realz"];
                if(realz != null)
                    cpoint.RealZ = double.Parse(realz.Value);

                _pointList.Add(cpoint);
            }
        }
Пример #3
0
 private void AcceptImagePoint(object sender, RoutedEventArgs e)
 {
     // Open real point dialog
     ChooseRealGridPointDialog realPointDialog = new ChooseRealGridPointDialog();
     bool? res = realPointDialog.ShowDialog();
     if(res != null && res == true)
     {
         CalibrationPoint cp = new CalibrationPoint()
         {
             ImgX = (double)_curPoint.X,
             ImgY = (double)_curPoint.Y,
             GridNum = realPointDialog.GridNum,
             RealCol = realPointDialog.X,
             RealRow = realPointDialog.Y
         };
         _currentImageGrid.Add(cp);
         _imageControl.AcceptTempPoint(cp);
         _butAcceptGrid.IsEnabled = true;
     }
 }
 private void AddPoint(object sender, RoutedEventArgs e)
 {
     CalibrationPoint point = new CalibrationPoint();
     point.GridNum = _pointList.Count;
     _pointList.Add(point);
 }
Пример #5
0
        public List<CalibrationPoint> GenerateCalibrationPoints_Random(int seed = 0)
        {
            List<CalibrationPoint> pointList = new List<CalibrationPoint>(_pointsCount);

            Random rand;
            if(seed == 0)
                rand = new Random();
            else
                rand = new Random(seed);

            for(int i = 0; i < _pointsCount; ++i)
            {
                double rx = rand.NextDouble() * (_rangeReal_MaxX - _rangeReal_MinX) + _rangeReal_MinX;
                double ry = rand.NextDouble() * (_rangeReal_MaxY - _rangeReal_MinY) + _rangeReal_MinY;
                double rz = rand.NextDouble() * (_rangeReal_MaxZ - _rangeReal_MinZ) + _rangeReal_MinZ;

                CalibrationPoint cpoint = new CalibrationPoint();
                cpoint.Real = new Vector3(rx, ry, rz);

                Vector<double> rp = new DenseVector(4);
                rp[0] = rx;
                rp[1] = ry;
                rp[2] = rz;
                rp[3] = 1.0;
                var imagePoint = _CM * rp;

                cpoint.Img = new Vector2(imagePoint[0] / imagePoint[2], imagePoint[1] / imagePoint[2]);

                pointList.Add(cpoint);
            }

            return pointList;
        }