Exemplo n.º 1
0
 private void btnReset_Click(object sender, EventArgs e)
 {
     rtxLog.AppendText("Reset" + Environment.NewLine);
     WorkingImg = RootImg.Clone();
     HistoryImg.Clear();
     RegistHisroty(WorkingImg);
 }
Exemplo n.º 2
0
        private void btnBoxOnOri_Click(object sender, EventArgs e)
        {
            VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
            var temproot = RootImg.Clone();
            var tempimg1 = WorkingImg.Clone();
            var tempimg2 = WorkingImg.Clone();

            CvInvoke.FindContours(tempimg1, contours, null, RetrType.External, ChainApproxMethod.ChainApproxNone);
            Image <Bgr, byte> colorimg   = tempimg2.Convert <Bgr, byte>();
            Image <Bgr, byte> tempOriImg = temproot.Convert <Bgr, byte>();
            //for ( int i = 0 ; i < contours.Size ; i++ )
            //{
            //    CvInvoke.DrawContours( tempOriImg , contours , i , new MCvScalar( 14 , 200 , 40 ) );
            //}
            List <System.Drawing.Rectangle> PassBoxArr = new List <System.Drawing.Rectangle>();

            List <double> arealist = new List <double>();

            for (int i = 0; i < contours.Size; i++)
            {
                System.Drawing.Rectangle rc = CvInvoke.BoundingRectangle(contours[i]);
                double areasize             = rc.Width * rc.Height;
                //.Act( @ths => arealist.Add(@ths));
                arealist.Add(areasize);

                if (areasize > (double)nudAreaDw.Value || areasize < (double)nudAreaUp.Value)
                {
                    PassBoxArr.Add(rc); // Check Display
                }
            }

            var areaarr   = arealist.ToArray <double>();
            var histodata = areaarr.Map(@ths =>
                                        @ths.ShowHisto(30
                                                       , (int)@ths.Min()
                                                       , (int)@ths.Max()));

            float minv = (float)areaarr.Min();
            float maxv = (float)areaarr.Max();

            Form2 f2 = new Form2();

            f2.boxhisto.ClearHistogram();
            f2.boxhisto.AddHistogram(null, System.Drawing.Color.Black, histodata, 300, new float[] { minv, maxv });
            f2.boxhisto.Refresh();
            f2.Show();

            rtxLog.AppendText("Box on Origin" + Environment.NewLine);
            RegistHisroty(tempOriImg);
        }
Exemplo n.º 3
0
        private void btnCntrOrig_Click(object sender, EventArgs e)
        {
            VectorOfVectorOfPoint contours = new VectorOfVectorOfPoint();
            var tempimg1 = WorkingImg.Clone();
            var tempimg2 = RootImg.Clone();

            CvInvoke.FindContours(tempimg1, contours, null, RetrType.External, ChainApproxMethod.ChainApproxNone);
            Image <Bgr, byte> colorimg = tempimg2.Convert <Bgr, byte>();

            for (int i = 0; i < contours.Size; i++)
            {
                CvInvoke.DrawContours(colorimg, contours, i, new MCvScalar(14, 250, 40), 2);
            }
            rtxLog.AppendText("Contour" + Environment.NewLine);
            RegistHisroty(WorkingImg, false);
            imageBox1.Image = colorimg;
        }
Exemplo n.º 4
0
        private void btnFreak_Click(object sender, EventArgs e)
        {
            var temproot = RootImg.Clone();
            var tempimg1 = WorkingImg.Clone();
            Image <Bgr, byte> colorimg   = tempimg1.Convert <Bgr, byte>();
            Image <Bgr, byte> tempOriImg = temproot.Convert <Bgr, byte>();
            var f2d      = new Freak();
            var keypoint = f2d.Detect(WorkingImg);

            foreach (var point in keypoint)
            {
                System.Drawing.Rectangle rect = new Rectangle();
                rect.X      = (int)point.Point.X;
                rect.Y      = (int)point.Point.Y;
                rect.Width  = (int)point.Size;
                rect.Height = (int)point.Size;
                tempOriImg.Draw(rect, new Bgr(60, 200, 10), 2);
            }
            rtxLog.AppendText("btnFreak_Click" + Environment.NewLine);
            RegistHisroty(tempOriImg);
        }