Ask Your Question
1

why Hough transform output is a textfile ?

asked 2017-05-01 12:55:06 -0600

Tomna gravatar image
    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);
edit retag flag offensive close merge delete

Comments

do you ever allocate mRgba ?

berak gravatar imageberak ( 2017-05-02 00:10:49 -0600 )edit

what do you mean by allocating ? not sure but this the location if your asking about it Imgcodecs.imwrite("/home/user/location/system/src/mainclass/image.jpg", mRgba);

Tomna gravatar imageTomna ( 2017-05-02 03:54:17 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-05-02 04:08:02 -0600

berak gravatar image

you need to allocate space for the pixels, if you want to draw into it:

mRbga = new Mat(roi_canny.size(), CV_8UC3, Scalar.all(0));
edit flag offensive delete link more

Comments

ya it worked thank you

Tomna gravatar imageTomna ( 2017-05-02 04:30:57 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-05-01 12:55:06 -0600

Seen: 125 times

Last updated: May 01 '17