コード例 #1
0
 public double HorizontalDistance(OCVLineData line2)
 {
     if (this.IsVertical() && line2.IsVertical())
     {
         return(Math.Abs(GetX() - line2.GetX()));
     }
     else
     {
         return(-1);
     }
 }
コード例 #2
0
 protected override double GetLocation(OCVLineData line)
 {
     return(line.GetX());
 }
コード例 #3
0
        public OCVGridDefinition Analyze(double threshold)
        {
            double left = OCVConst.REALLYLARGE, top = OCVConst.REALLYLARGE, right = -OCVConst.REALLYLARGE, bottom = -OCVConst.REALLYLARGE;

            // remove lines that are too small
            RemoveSmallLines(threshold);
            // analyze horizontal lines
            int rows = -1;

            foreach (OCVCombinedLinesData linesGroup in HorizontalLines)
            {
                rows++;
                OCVLineData summaryLine = linesGroup.GetSummaryLine();
                if (summaryLine.GetMinValue() < left)
                {
                    left = summaryLine.GetMinValue();
                }
                if (summaryLine.GetMaxValue() > right)
                {
                    right = summaryLine.GetMaxValue();
                }
                if (summaryLine.GetY() > top)
                {
                    top = summaryLine.GetY();
                }
                if (summaryLine.GetY() < bottom)
                {
                    bottom = summaryLine.GetY();
                }
            }

            // analyze vertical lines
            int cols = -1;

            foreach (OCVCombinedLinesData linesGroup in VerticalLines)
            {
                cols++;
                OCVLineData summaryLine = linesGroup.GetSummaryLine();
                if (summaryLine.GetX() < left)
                {
                    left = summaryLine.GetX();
                }
                if (summaryLine.GetX() > right)
                {
                    right = summaryLine.GetX();
                }
                if (summaryLine.GetMinValue() < top)
                {
                    top = summaryLine.GetMinValue();
                }
                if (summaryLine.GetMaxValue() > bottom)
                {
                    bottom = summaryLine.GetMaxValue();
                }
            }
            OCVGridDefinition result = new OCVGridDefinition(new Point((int)left, (int)top),
                                                             new Point((int)right, (int)bottom),
                                                             rows, cols
                                                             );

            return(result);
        }