Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

why Hough transform output is a textfile ?

    i am not sure how but the output i keep getting is an empty textfile

here is the code:

        Mat mRgba = new Mat();
        Imgproc.cvtColor(roi_image, roi_image, Imgproc.COLOR_BGR2GRAY);
        Imgproc.equalizeHist(roi_image, roi_histo);

/////////////////edge detection/////////////////////////////////////////////////////////////////
        Imgproc.Canny(roi_histo, roi_canny, 250, 250);
/////////////////HoughLine Transform/////////////////////////////////////////////////////////////////
        Imgproc.HoughLines(roi_canny, roi_lines, 1, Math.PI / 180, 100);
        for (int i = 0; i < roi_lines.cols(); i++) {
            double vec[] = roi_lines.get(0, i);
            double rho1 = vec[0];
            double theta1 = vec[1];
            double cosTheta = Math.cos(theta1);
            double sinTheta = Math.sin(theta1);
            double x0 = cosTheta * rho1;
            double y0 = sinTheta * rho1;
            Point pt1 = new Point(x0 + 10000 * (-sinTheta), y0 + 10000 * cosTheta);
            Point pt2 = new Point(x0 - 10000 * (-sinTheta), y0 - 10000 * cosTheta);

            Imgproc.line(mRgba, pt1, pt2, new Scalar(0, 0, 255), 2);
        }
        Imgcodecs.imwrite("the path goes here", mRgba);