Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Help with line segment detection in java

$
0
0
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.](http://docs.opencv.org/3.0-rc1/d8/dd4/lsd_lines_8cpp-example.html#_a1) 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 { Imgproc.Canny(image,image,50,200); 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) { e.printStackTrace(); } }

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>