Sorry, this content is no longer available

Ask Your Question
1

why Hough transform output is a textfile ?

asked May 1 '17

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);
Preview: (hide)

Comments

do you ever allocate mRgba ?

berak gravatar imageberak (May 2 '17)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 (May 2 '17)edit

1 answer

Sort by » oldest newest most voted
1

answered May 2 '17

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));
Preview: (hide)

Comments

ya it worked thank you

Tomna gravatar imageTomna (May 2 '17)edit

Question Tools

1 follower

Stats

Asked: May 1 '17

Seen: 128 times

Last updated: May 01 '17