private void cmBones_Click(object sender, EventArgs e) { var bw = new BackgroundWorker(); bw.DoWork += (a, b) => { Data dat = new Data(); try { Bitmap img = (Bitmap)b.Argument; var detector = new BoneDetector(img); var ld = new LineDetector(); image = ld.Apply(detector.Apply()); picture.Image = image; if (ld.Lines.Count == 2) { var data2 = image.Lock(); var um2 = new UnmanagedImage(data2); var crossed = ld.Lines[0].CrossPoint(ld.Lines[1]); Drawing.Rectangle(um2, new Rectangle(crossed.X - 10, crossed.Y - 10, 20, 20), Color.Green); image.Unlock(data2); } dat.image = image; dat.message = ld.GetInfo(); } catch (Exception ex) { dat.image = null; dat.message = ex.GetError(); } b.Result = dat; }; bw.RunWorkerCompleted += (a, b) => { Data dat = (Data)b.Result; picture.Image = dat.image; bonesInfo = dat.message; blockInterface(false); progress.Visible = false; status.Text = "Przetwarzanie zakończone"; MessageBox.Show(dat.message); }; if (image == null) { openFile(); } blockInterface(true); progress.Enabled = true; progress.Style = ProgressBarStyle.Marquee; progress.Visible = true; status.Text = "Przetwarzanie rozpoczęte..."; bw.RunWorkerAsync(image); }
private void DrawImportButton() { SerializedLineDetectionSettings.ApplyModifiedProperties(); SerializedMeshBuilderSettings.ApplyModifiedProperties(); if (GUILayout.Button("Create")) { var parent = GameObject.Find(ParentObjectName); if (parent != null) { CoreUtils.Destroy(parent); } parent = new GameObject(ParentObjectName); switch (lineDetectionSettings.lineSource) { case LineDetectionSettings.LineSource.HdMap: { CreateLinesFromHdMap(parent); } break; case LineDetectionSettings.LineSource.IntensityMap: { LineDetector.Execute(parent.transform, lineDetectionSettings); } break; case LineDetectionSettings.LineSource.CorrectedHdMap: { LineDetector.Execute(parent.transform, lineDetectionSettings); var linesOverride = parent.GetComponent <LaneLineOverride>(); CreateLinesFromHdMap(parent, linesOverride); } break; default: throw new ArgumentOutOfRangeException(); } if (lineDetectionSettings.generateLineSensorData) { if (parent.GetComponent <LaneLineOverride>() == null) { LineDetector.Execute(parent.transform, lineDetectionSettings); } } else { var overrideData = parent.GetComponent <LaneLineOverride>(); if (overrideData != null) { CoreUtils.Destroy(overrideData); } } } }
static void Main(string[] args) { if (!Directory.Exists(OutputFolder)) { Directory.CreateDirectory(OutputFolder); } // Create LineDetector instance and load document LineDetector lineDetector = new LineDetector("demo", "demo"); lineDetector.LoadDocumentFromFile(InputFile); // Create RasterRenderer instance and load document RasterRenderer rasterRenderer = new RasterRenderer("demo", "demo"); rasterRenderer.LoadDocumentFromFile(InputFile); try { int pageCount = lineDetector.GetPageCount(); for (int pageIndex = 0; pageIndex < pageCount; pageIndex++) { Console.WriteLine("Processing page #{0}", pageIndex); // Find horizontal lines on the page FoundLinesCollection horzLines = lineDetector.FindLines(pageIndex, LineOrientationsToFind.OnlyHorizontal); // Slice page by separating lines and create new PDF documents Slice(pageIndex, horzLines, rasterRenderer); } } catch (Exception exception) { Console.WriteLine(exception); } finally { // Cleanup rasterRenderer.Dispose(); lineDetector.Dispose(); } Console.WriteLine(); Console.WriteLine("Press any key..."); Console.ReadKey(); }
static void Main(string[] args) { // Create Bytescout.PDFExtractor.LineDetector instance LineDetector lineDetector = new LineDetector(); lineDetector.RegistrationName = "demo"; lineDetector.RegistrationKey = "demo"; // Load sample PDF document lineDetector.LoadDocumentFromFile(@".\sample2.pdf"); FoundLinesCollection foundLines = lineDetector.FindLines(1, LineOrientationsToFind.HorizontalAndVertical); Console.WriteLine("Number of lines found: " + foundLines.Count); for (int i = 0; i < foundLines.Count; i++) { FoundLine line = foundLines[i]; Console.WriteLine("Line # " + i); // Line Orientation Console.WriteLine("LineOrientation: " + line.LineOrientation); // Starting point of the line Console.WriteLine("From point: " + line.From); // Ending point of the line Console.WriteLine("To point: " + line.To); // Line width Console.WriteLine("Width: " + line.Width); } Console.ReadLine(); }