Ask Your Question

DD690's profile - activity

2015-12-14 05:25:18 -0500 answered a question Help with line segment detection in java

Mat lines = new Mat();

should be

MatOfFloat4 lines = new MatOfFloat4();
2015-12-08 12:16:30 -0500 asked a question Help with line segment detection in java

Hi all,

I am having a problem with line segment detection. I am using openCV 3. The output file sometimes has lines in the wrong places and sometimes is blank depending on the input image. I think its something to do with my variable called lines. I have tried to implement this from this example. The problem is I dont know c++ at all so it has been hard to understand. I am doing a project on emotion detection from an image. Am i on the right track with this?

Any help appreciated.

 public void lineSegment(File file) {
        new Event().fireEvent(new EventItem(
              this, 1, "Begining line segmentation . . . \n"));

        new Event().fireEvent(new EventItem(
                this, 1, "File path:\n" + file.getAbsolutePath() + "\n"));

        Mat image = Imgcodecs.imread(file.getAbsolutePath());

        try {
            LineSegmentDetector ls = Imgproc.createLineSegmentDetector();

            double start = Core.getTickCount();

            Mat lines = new Mat();

            ls.detect(image, lines);

            double duration_ms = (Core.getTickCount() - start) * 1000 / Core.getTickFrequency();

            Mat lineImage = Imgcodecs.imread(
             "/Users/DarrylThorne/IdeaProjects/Face Detection Project/pics/blank.jpg");

            ls.drawSegments(lineImage, lines);

            Imgcodecs.imwrite("lineSegImage.jpg", lineImage);
            new Event().fireEvent(new EventItem(this, 1, "Time taken: " + duration_ms + "ms.\n"));

        } catch (CvException e) {