Beispiel #1
0
        public async Task PrepareFolderAsync()
        {
            var folderName = Path.GetDirectoryName(f_StartName);
            var fileExt    = Path.GetExtension(f_StartName);
            var files      = Directory.GetFiles(folderName, $"*{fileExt}");

            foreach (var file in files)
            {
                var rawCluster = new RawCluster(
                    file,
                    Properties.Settings.Default.GaussianParam,
                    Properties.Settings.Default.BinarizationThreshold,
                    Properties.Settings.Default.MaxAspectRatio,
                    Properties.Settings.Default.MinPerimetherLen);
                await rawCluster.MakeCluster();

                var position = rawCluster.RelativeToPos(f_CurrentPosition);
                var pt       = new Emgu.CV.Structure.RotatedRect(
                    new System.Drawing.PointF((float)(position.X), (float)(position.Y)),
                    new System.Drawing.SizeF(),
                    0
                    );
                var markedElement = rawCluster.GetNearer(pt);

                rawCluster.CreateHexagon(markedElement);
                f_Hexagon.Add(rawCluster.Hexagon);
                f_CurrentPosition = rawCluster.GetRelativePosition(rawCluster.Hexagon.Center.Element.Center);
            }
            Application.Current.Dispatcher.Invoke(() =>
            {
                MessageBox.Show("Operation finished!");
            });
        }
Beispiel #2
0
 public HexagonPack(string fileName, RelativePosition startPos)
 {
     f_Hexagon         = new List <Hexagon>();
     f_CurrentPosition = startPos;
     f_StartName       = fileName;
     f_Zoom            = Properties.Settings.Default.CameraZoom;
 }
Beispiel #3
0
        public PointF RelativeToPos(RelativePosition position)
        {
            var minX   = f_Cluster.Min(x => x.Element.Center.X);
            var maxX   = f_Cluster.Max(x => x.Element.Center.X);
            var sizeX  = maxX - minX;
            var minY   = f_Cluster.Min(x => x.Element.Center.Y);
            var maxY   = f_Cluster.Max(x => x.Element.Center.Y);
            var sizeY  = maxY - minY;
            var center = GetCenter();

            return(new PointF(
                       (float)(center.X + position.Rx * sizeX),
                       (float)(center.Y + position.Ry * sizeY)
                       ));
        }
Beispiel #4
0
        private void ViewContainer_MouseDown(object sender, MouseButtonEventArgs e)
        {
            var position = Mouse.GetPosition(ViewContainer);
            var pt       = new Emgu.CV.Structure.RotatedRect(
                new System.Drawing.PointF((float)(position.X / f_Ratio), (float)(position.Y / f_Ratio)),
                new System.Drawing.SizeF(),
                0
                );

            if (f_RawCluster != null)
            {
                var markedElement = f_RawCluster.GetNearer(pt);
                //DrawMarker(markedElement, Colors.Orange);
                f_RawCluster.CreateHexagon(markedElement);
                DrawHexagon(f_RawCluster.Hexagon);
                f_RawCluster.Hexagon.AverageLink();
                f_RPosition = f_RawCluster.GetRelativePosition(pt.Center);
            }
        }
Beispiel #5
0
 public PointF RelativeToPos(RelativePosition position)
 {
     return(f_Cluster.RelativeToPos(position));
 }