0
votes

This is the exception im getting

CvException [org.opencv.core.CvException: cv::Exception: /hdd2/buildbot/slaves/slave_ardbeg1/50-SDK/opencv/modules/imgproc/src/hough.cpp:712: error: (-5) The source image must be 8-bit, single-channel in function CvSeq* cvHoughLines2(CvArr*, void*, int, double, double, int, double, double)

    mat = new Mat();
    edges = new Mat();
    lines = new Mat();
    mRgba = new Mat(612, 816, CvType.CV_8UC1);
    Utils.bitmapToMat(bitmap, mat);
    Imgproc.Canny(mat, edges, 50, 90);
    int threshold = 50;
    int minLineSize = 20;

    int lineGap = 20;
    try {

        Imgproc.HoughLines(mat, lines, 1, Math.PI / 180, threshold, minLineSize, lineGap);
        for (int x = 0; x < lines.cols(); x++) {
            double[] vec = lines.get(0, x);
            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);
            Core.line(mRgba, start, end, new Scalar(255, 0, 0), 3);
        }
        Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
        Utils.matToBitmap(mRgba, bmp);
        bitmap = bmp;




    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("e = " + e);
    }
1
your opencv version? explain what you doing and what you want.Lingeshwaran
openCV version 2.4.3 Im trying to detect the lines in a imageSan
some one help meSan

1 Answers

0
votes

Your image in function HoughLines isn't right. You're not formatting it right before putting it into the function.

Try prepare image like this:

https://stackoverflow.com/a/7975315/5577679