void AVLGraphics(bool graphicsSwitch) { if (graphicsSwitch) { displayImageTop = new AvlNet.Image(TopIntensityImage.CreateBitmap()); displayImageBottom = new AvlNet.Image(BottomIntensityImage.CreateBitmap()); //Match Edges //foreach (var item in outMatchEdges) //{ // AVL.DrawPath(ref displayImageTop, item, Pixel.Green, new DrawingStyle(DrawingMode.Fast, 1, 1, false, PointShape.Circle, 2)); //} //Match Point //AVL.DrawPoint(ref displayImageTop, outMatchPoint.Value, Pixel.Green, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 60)); // Intersection Point 1 // AVL.DrawPoint(ref displayImageTop, outIntersectionPoint01.Value, Pixel.Fuchsia, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120)); // Intersection Point 2 // AVL.DrawPoint(ref displayImageTop, outIntersectionPoint02.Value, Pixel.Purple, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120)); //Fit line //AVL.DrawLine(ref displayImageTop, outLine01.Value, Pixel.Yellow, new DrawingStyle(DrawingMode.Fast, 1, 2, false, PointShape.Circle, 2)); //AVL.DrawLine(ref displayImageTop, outLine02.Value, Pixel.Yellow, new DrawingStyle(DrawingMode.Fast, 1, 1, false, PointShape.Circle, 2)); //AVL.DrawLine(ref displayImageTop, outLineMid.Value, new Pixel(LineColor), new DrawingStyle(DrawingMode.Fast, 1, 2, false, PointShape.Circle, 2)); //AVL.DrawPoint(ref displayImageTop, MidPoint01.Value, Pixel.Fuchsia, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120)); // AVL.DrawPoint(ref displayImageTop, MidPoint02.Value, Pixel.Fuchsia, new DrawingStyle(DrawingMode.Fast, 1, 5, false, PointShape.Cross, 120)); //displayImageTop.Save($@"{ConfigPath.ImageDataPathTop}{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.png"); ImageSourceTop = ImageConvert.BitmapToImageSource(displayImageTop.CreateBitmap()); ImageSourceBottom = ImageConvert.BitmapToImageSource(displayImageBottom.CreateBitmap()); } }
/// <summary> /// Loads image from path specified in text box and saves it in 'image' variable. /// </summary> private void LoadImage() { try { //mr?? 为啥不将这个代码封装到ExtendedPictureBox内部. if (pictureBox.Image != null) { pictureBox.Image.Dispose(); pictureBox.Image = null; } string imagePath = textImagePath.Text; AVL.LoadImage(imagePath, false, image); pictureBox.Image = image.CreateBitmap(); SetStatusLabel("Please, select the scanning segment on image"); openFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(System.IO.Path.GetFullPath(imagePath)); } catch (Exception ex) { SetStatusLabel(string.Format("Error: {0}", ex.Message)); return; } }
/// <summary> /// Performs inspection in 500ms interval. /// </summary> private void timer_Tick(object sender, EventArgs e) { using (var currentImage = new AvlNet.Image()) { if (currentImageIndex < ImagePaths.Length) { AVL.LoadImage(ImagePaths[currentImageIndex], false, currentImage); GasketInspector.Inspect(currentImage, out circles, out arcs, out segments); if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } pictureBox1.Image = currentImage.CreateBitmap(); ++currentImageIndex; } else { timer.Enabled = false; startButton.Enabled = true; } } }