Exemplo n.º 1
0
        private int AnalyzeLinesGroup(List <OCVCombinedLinesData> lines, ref double a1, ref double a2, ref double b1, ref double b2)
        {
            int result = -1;

            foreach (OCVCombinedLinesData linesGroup in lines)
            {
                result++;
                OCVLineData summaryLine = linesGroup.GetSummaryLine();
                if (summaryLine.GetMinValue() < a1)
                {
                    a1 = summaryLine.GetMinValue();
                }
                if (summaryLine.GetMaxValue() > a2)
                {
                    a2 = summaryLine.GetMaxValue();
                }
                if (summaryLine.GetLocation() < b1)
                {
                    b1 = summaryLine.GetLocation();
                }
                if (summaryLine.GetLocation() > b2)
                {
                    b2 = summaryLine.GetLocation();
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 public bool AddLine(OCVLineData line)
 {
     if (!IsInRange(line))
     {
         return(false);
     }
     Lines.Add(line);
     ReCompute();
     Sort();
     return(true);
 }
Exemplo n.º 3
0
 public bool IsInRange(OCVLineData line)
 {
     if (!OCVConst.IsEqualValue(line.Line.Direction.X, Direction.X) && OCVConst.IsEqualValue(line.Line.Direction.Y, Direction.Y))
     {
         return(false);
     }
     else
     {
         return(GetLocation(line) <= maxRange && GetLocation(line) >= minRange);
     }
 }
Exemplo n.º 4
0
 public double VerticalDistance(OCVLineData line2)
 {
     if (this.IsHorizontal() && line2.IsHorizontal())
     {
         return(Math.Abs(GetY() - line2.GetY()));
     }
     else
     {
         return(-1);
     }
 }
Exemplo n.º 5
0
        private void button2_Click(object sender, EventArgs e)
        {
            GridAnalyzer  = new TekGridAnalyzer(imgOriginal);
            pbGray.Image  = GridAnalyzer.matGrayScaleImage.Bitmap;
            pbEdges.Image = GridAnalyzer.cannyEdges.Bitmap;

            lineImage = imgOriginal.CopyBlank();
            foreach (LineSegment2D line in GridAnalyzer.Lines)
            {
                lineImage.Draw(line, new Bgr(Color.LightGreen), 2);
            }
            pbLines.Image = lineImage.Bitmap;

            Image <Bgr, Byte> image3 = lineImage.CopyBlank();

            foreach (OCVCombinedLinesData line in GridAnalyzer.Grid.HorizontalLines)
            {
                OCVLineData summ = line.GetSummaryLine();
                image3.Draw(summ.Line, new Bgr(Color.Azure), 2);
            }
            foreach (OCVCombinedLinesData line in GridAnalyzer.Grid.VerticalLines)
            {
                OCVLineData summ = line.GetSummaryLine();
                if (summ.Length > 35)
                {
                    image3.Draw(summ.Line, new Bgr(Color.LightPink), 2);
                }
            }
            pbAnalyzed.Image = image3.Bitmap;


            using (GridSizeForm gridForm = new GridSizeForm())
            {
                gridForm.GridAnalyzer = GridAnalyzer;
                gridForm.LoadImage(imgOriginal);
                gridForm.SetGridDef(GridAnalyzer.gridDef);
                if (gridForm.ShowDialog() == DialogResult.OK)
                {
                    GridAnalyzer.gridDef = gridForm.GetGridDef();
                }
            }

            Image <Bgr, Byte> lineImage2 = imgOriginal.CopyBlank();

            DrawGrid(lineImage2, GridAnalyzer.gridDef, new Bgr(Color.White));
            pbGrid.Image = lineImage2.Bitmap;

            Image <Bgr, Byte> lineImage4 = imgOriginal.Copy();

            DrawGrid(lineImage4, GridAnalyzer.gridDef, new Bgr(Color.Purple));
            pbCombi.Image = lineImage4.Bitmap;

            tabControl1.SelectedTab = tbCombi;
        }
Exemplo n.º 6
0
 public OCVGridData(LineSegment2D[] lines)
 {
     HorizontalLines = new List <OCVLineData>();
     VerticalLines   = new List <OCVLineData>();
     foreach (LineSegment2D line in lines)
     {
         if (line.Length < OCVConst.MinimalLineLength)
         {
             continue;
         }
         OCVLineData newData = new OCVLineData(line);
         if (newData.IsHorizontal())
         {
             HorizontalLines.Add(newData);
         }
         else if (newData.IsVertical())
         {
             VerticalLines.Add(newData);
         }
     }
     HorizontalLines.Sort(new OCVHorizontalLineDataSorter());
     VerticalLines.Sort(new OCVVerticalLineDataSorter());
 }
Exemplo n.º 7
0
 protected override double GetLocation(OCVLineData line)
 {
     return(line.GetX());
 }
Exemplo n.º 8
0
 private void RemoveLine(OCVLineData line)
 {
     Lines.Remove(line);
     ReCompute();
 }
Exemplo n.º 9
0
 protected abstract double GetLocation(OCVLineData line);