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!"); }); }
public static System.Drawing.Rectangle GetBoundingBox(this Emgu.CV.Structure.RotatedRect rotatedRect, System.Int32 maxWidth, System.Int32 maxHeight) { var minAreaRect = rotatedRect.MinAreaRect(); return(new System.Drawing.Rectangle(x: System.Math.Max(0, minAreaRect.X - 5), y: System.Math.Max(0, minAreaRect.Y - 5), width: System.Math.Min(minAreaRect.Width + 10, maxWidth), height: System.Math.Min(minAreaRect.Height + 10, maxHeight))); }
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); } }