Пример #1
0
        public static Tuple <List <double>, List <double> > FindLineSubPixel(HImage image, double[] row, double[] col, double[] radian,
                                                                             double[] len1, double[] len2, string transition, int numSubRects, double threshold, string whichEdge, double ignoreFraction, double cannyLow, double cannyHigh, double sigma1, double sigma2,
                                                                             int newWidth, int kernelWidth, HTuple longestOnly, out HObject edges, out HObject findLineRects)
        {
            var length = row.Length;

            findLineRects = new HObject();
            findLineRects.GenEmptyObj();
            edges = new HObject();
            edges.GenEmptyObj();

            var outputXs = new List <double>();
            var outputYs = new List <double>();

            // For each find line rect
            for (int i = 0; i < length; i++)
            {
                HObject findLineRect, edge;
                HTuple  xs, ys, _;
                HalconScripts.VisionProStyleFindLine(image, out findLineRect, transition, row[i], col[i], radian[i],
                                                     len1[i], len2[i], numSubRects, threshold, sigma1, whichEdge, "false", "first", 0, 0, out xs, out ys);


                var lineOnEdge = FitLine2D(xs.DArr.ToList(), ys.DArr.ToList());


                HalconScripts.GetEdgesInSubRect2(image, out findLineRect, out edge, lineOnEdge.XStart, lineOnEdge.YStart, lineOnEdge.XEnd, lineOnEdge.YEnd, radian[i], newWidth, sigma2, cannyLow, cannyHigh, kernelWidth, longestOnly);
                edges.ConcatObj(edge);
                edges         = ConcatAll(edges, edge);
                findLineRects = ConcatAll(findLineRects, findLineRect);


                List <double> contourXs, contourYs;
                GetContoursPoints(edge, out contourXs, out contourYs);
                outputXs.AddRange(contourXs);
                outputYs.AddRange(contourYs);
            }

            return(new Tuple <List <double>, List <double> >(outputXs, outputYs));
        }