Example #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!");
            });
        }
Example #2
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);
            }
        }