void ChangeFront2ImgProcStep() { btnStartProcssing.IsEnabled = true; Removeevent(CornerCanvs); ClearLRFrame(); while (canvas.Children.Count > 0) { canvas.Children.RemoveAt(canvas.Children.Count - 1); } // delect rect titleRB.Text = "Histogram"; titleLT.Text = "Indexing View"; Core.CreateEstedChipFunc(Core.PData.CornerPos_Img, ckbEst4Pos.IsChecked.Value ? EstChipPosMode.With4Point : EstChipPosMode.With2Point); Core.IndexViewImg = new Image <Bgr, byte>(Core.PData.ChipWNum, Core.PData.ChipHNum); Core.IndexViewImg.Data = MatPattern(Core.PData.ChipHNum, Core.PData.ChipWNum, 3); imgIndex.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.IndexViewImg); imgRB.ImageSource = null; WinHost = CreateWinHost(canvasLT); HistoBox = new HistogramBox(); canvasRB.Children.Clear(); AddHist2Box(HistoBox, ref HistogramList, HistoFromImage(Core.OriginImg, Core.BinSize), ( bool )ckbSetHistRange.IsChecked ? float.Parse(nudHistDW.Text) : 0, ( bool )ckbSetHistRange.IsChecked ? float.Parse(nudHistUP.Text) : 255); HistoBox.Refresh(); WinHost.Child = HistoBox; canvasRB.Children.Add(WinHost); }
private async void btnStartProcssing_Click(object sender, RoutedEventArgs e) { this.BeginInvoke(() => Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait); var result = CheckNGMode(txbFactorName.Text); if (ReadyProc()) { await Task.Run(() => Core.ProcessingStep1(result)()); } this.BeginInvoke(() => { imgPro.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.ProcedImg); imgIndex.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.IndexViewImg); Mouse.OverrideCursor = null; }); lblPassChipnum.BeginInvoke(() => lblPassChipnum.Content = Core.PResult.ChipPassCount); lblFailChipnum.BeginInvoke(() => lblFailChipnum.Content = Core.PResult.ChipFailCount); lblTotalChip.BeginInvoke(() => lblTotalChip.Content = Core.PData.ChipHNum * Core.PData.ChipWNum); Core.Analysis_Processing(); this.BeginInvoke(() => lblAccuracy.Content = Core.Confusion_Matrix["Accuracy"]); this.BeginInvoke(() => lblSpecificity.Content = Core.Confusion_Matrix["Specificity"]); //DisplayResultHisto(Core.PResult); }
private async void btnStartProcssing_Click(object sender, RoutedEventArgs e) { if (ckbAdvancedPos.IsChecked == true && Core.PData.AdvHChipPos[0] == null || Core.PData.AdvHChipPos [1] == null || Core.PData.AdvHChipPos [2] == null) { System.Windows.MessageBox.Show("Select Position of Chip first"); return; } timer.Start(); this.BeginInvoke(() => Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait); var thresvalue = (int)nudThresh.Value; if (ReadyProc()) { await Task.Run(() => Core.ProcessingStep1_Normal( thresvalue , Core.SelectedSample // automated , (int)Core.PData.ChipHNum , (int)Core.PData.ChipWNum) ( Core.OriginImg, Core.ColorOriImg )); } this.BeginInvoke(() => { imgPro.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.ProcedImg); imgIndex.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.IndexViewImg); Mouse.OverrideCursor = null; }); }
void SetInitImg(ImageBrush[] cornerImg, Canvas oriCanvas, Canvas Pro, Canvas[] cornerCanv) { List <Rectangle> rectList = new List <Rectangle>(); /*Canvas Setting*/ double[] canvXYLen = Core.MapImg2Canv(new double[2] { Core.LTRBPixelNumberH, Core.LTRBPixelNumberW }); Core.SetCornerRect(oriCanvas, canvXYLen[0], canvXYLen[1]); RenderOptions.SetBitmapScalingMode(Pro, BitmapScalingMode.NearestNeighbor); for (int i = 0; i < 4; i++) { RenderOptions.SetBitmapScalingMode(cornerCanv[i], BitmapScalingMode.NearestNeighbor); var temp = CornerImgCrops[i](Core.OriginImg); //ImageViewer.Show( temp , "Test Window" ); cornerImg[i].ImageSource = BitmapSrcConvert.ToBitmapSource(CornerImgCrops[i](Core.OriginImg)); cornerCanv[i].MouseLeftButtonUp += new MouseButtonEventHandler(CornerClickEvt[i]); } imgOri.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.OriginImg); }
private async void btnfulleste_Click(object sender, RoutedEventArgs e) { try { this.BeginInvoke(() => Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait); int hsize = (int)nudboxSizeH.Value; int wsize = (int)nudboxSizeW.Value; if (ReadyProc()) { await Task.Run(() => Core.ProcessingStep1_Simple( Core.SelectedSample // automated , ( int )Core.PData.ChipHNum , ( int )Core.PData.ChipWNum , hsize , wsize) ( Core.OriginImg, Core.ColorOriImg )); } this.BeginInvoke(() => { imgPro.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.ProcedImg); imgIndex.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.IndexViewImg); Mouse.OverrideCursor = null; }); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
Task PorcessingStep1() { return(Task.Run(() => { try { Console.WriteLine("TaskIn1"); this.BeginInvoke(() => Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait); var temp = Core.PResult; Core.PResult = new ImgPResult(); /* For Simple Notation */ double cHnum = Core.PData.ChipHNum; double cWnum = Core.PData.ChipWNum; Image <Bgr, byte> targetimg = null; /* Create Data */ byte[,,] failchipDisplayData = MatPattern((int)cHnum, (int)cWnum, 3); byte[,,] passfailPosData = new byte[(int)cHnum, (int)cWnum, 1]; double[,,] estedChipP = Core.EstedChipPos(cHnum, cWnum); var passContours = Core.FindPassContour(Core.OriginImg); Core.passChipList = new List <System.Drawing.PointF>(); Core.failChipList = new List <System.Drawing.PointF>(); targetimg = Core.ColorOriImg.Clone(); /* Draw Contour and Save */ //targetimg = DrawContour( targetimg , passContours ); //targetimg.Save( TestFileSavePath.ContourName ); Core.CreateSortcontour(passContours); passContours = Core.Sortcontours(); var boxlist = Core.ApplyBox(passContours); targetimg = DrawBox(targetimg, boxlist); //targetimg.Save( TestFileSavePath.BoxName ); // Draw EstedPoint on Image and Cavnas targetimg = DrawCenterPoint(targetimg, estedChipP); #region check pass fail var boximg = Core.ColorOriImg.Clone(); Console.WriteLine("TaskIn2"); for (int j = 0; j < estedChipP.GetLength(1); j++) // col { for (int i = 0; i < estedChipP.GetLength(0); i++) // row { bool isFail = true; for (int k = 0; k < boxlist.Count; k++) { /* Check Ested Chip Pos in Contour*/ Core.CreateInbox(boxlist[k], 3); if (Core.InBox(estedChipP[i, j, 0], estedChipP[i, j, 1])) { Core.PResult.OutData.Add(new ExResult(j, i, true, Core.SumBox(boxlist[k]), CvInvoke.ContourArea(passContours[k]))); Core.passChipList.Add(new System.Drawing.PointF(( float )estedChipP[i, j, 0], ( float )estedChipP[i, j, 1])); isFail = false; break; } } if (isFail) { double failboxInten = Core.SumAreaPoint((int)estedChipP[i, j, 0], (int)estedChipP[i, j, 1]); Core.PResult.OutData.Add(new ExResult(j, i, false, failboxInten, 0)); Core.failChipList.Add(new System.Drawing.PointF(( float )estedChipP[i, j, 0], ( float )estedChipP[i, j, 1])); failchipDisplayData[i, j, 0] = ( byte )(failchipDisplayData[i, j, 0] * 0.3); failchipDisplayData[i, j, 1] = ( byte )(failchipDisplayData[i, j, 1] * 0.5); failchipDisplayData[i, j, 2] = 200; } } } Console.WriteLine("TaskIn3"); Core.IndexViewImg.Data = failchipDisplayData; Core.ProcedImg = targetimg; lblPassChipnum.BeginInvoke(() => lblPassChipnum.Content = Core.passChipList.Count()); lblFailChipnum.BeginInvoke(() => lblFailChipnum.Content = Core.failChipList.Count()); Core.PResult.ChipPassCount = Core.passChipList.Count(); Core.PResult.ChipFailCount = Core.failChipList.Count(); #endregion this.BeginInvoke(() => { imgPro.ImageSource = BitmapSrcConvert.ToBitmapSource(targetimg); imgIndex.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.IndexViewImg); Mouse.OverrideCursor = null; }); } catch (Exception er) { System.Windows.Forms.MessageBox.Show(er.ToString()); } })); }
private async void btnStartProcssing_Click(object sender, RoutedEventArgs e) { try { if (ckbAdvancedPos.IsChecked == true && (Core.PData.AdvHChipPos [0] == null || Core.PData.AdvHChipPos [1] == null || Core.PData.AdvHChipPos [2] == null)) { System.Windows.MessageBox.Show("Select Position of Chip first"); return; } timer.Start(); this.BeginInvoke(() => Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait); var thresvalue = (int)nudThresh.Value; Core.APBoxTolerance = nudTol.Value == null ? 1 : ( int )nudTol.Value; var gridstyle = (bool)ckbGridStyle.IsChecked; var needdebug = (bool)chbDebugImg.IsChecked; Core.SelectedSample = Core.SampleTypeList [cbSampleMethod.SelectedItem as string]; if ((bool)ckbUseEl.IsChecked) { List <ELData> output = new List <ELData>(); OpenFileDialog fd = new OpenFileDialog(); if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { output = LoadELData(fd.FileName).ToList(); } if (ReadyProc()) { await Task.Run(() //=> Core.ProcessingStep1_Normal( => Core.ProcessingStep1_Version2_WithEL( thresvalue , Core.SelectedSample // automated , (int)Core.PData.ChipHNum , (int)Core.PData.ChipWNum , gridstyle , output , needdebug) ( Core.OriginImg, Core.ColorOriImg )); } } else { if (ReadyProc()) { await Task.Run(() //=> Core.ProcessingStep1_Normal( => Core.ProcessingStep1_Version2( thresvalue , Core.SelectedSample // automated , (int)Core.PData.ChipHNum , (int)Core.PData.ChipWNum , gridstyle , needdebug) ( Core.OriginImg, Core.ColorOriImg )); } } this.BeginInvoke(() => { imgPro.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.ProcedImg); imgIndex.ImageSource = BitmapSrcConvert.ToBitmapSource(Core.IndexViewImg); Mouse.OverrideCursor = null; }); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show("Main Processing Error : " + ex.ToString()); } }