Houghlines in android with opencv

牧云@^-^@ 提交于 2019-12-04 13:01:11

I finally managed to get the houghlines. The houghlines was not showing in the grey images and I extracted the houghlines in grey image but plotted the lines in color image and it worked.

Imgproc.HoughLinesP(greyImg, lines, 1, Math.PI/180, threshold,
                minLineSize, lineGap);

        for (int x = 0; x < lines.rows(); x++)
        {
            double[] vec = lines.get(x, 0);
            double x1 = vec[0],
                    y1 = vec[1],
                    x2 = vec[2],
                    y2 = vec[3];
            Point start = new Point(x1, y1);
            Point end = new Point(x2, y2);
            double dx = x1 - x2;
            double dy = y1 - y2;

            double dist = Math.sqrt (dx*dx + dy*dy);

            if(dist>300.d)  // show those lines that have length greater than 300
                Imgproc.line(initImg, start, end, new Scalar(0,255, 0, 255),5);// here initimg is the original image.

        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!