3

I'm trying to detect lines on an image which contains a road. Using gaussian smoothing and Canny edge detection, I reached a wall while trying to implement RANSAC. I basically don't know a single step as to how to go about it. Can I get a rough idea or a working code with a random image 'foo.png' that implements RANSAC?

zyrkor
  • 73
  • 2
  • 5
  • Few related answers: http://stackoverflow.com/a/40142233/798093 http://stackoverflow.com/questions/7227074/horizontal-line-detection-with-opencv/7228823#7228823 – masad Nov 02 '16 at 13:07
  • Line detection is normally approached using Hough Transform. However if you are still interested in using Ransac then OpenCV function `fitLine` already does that http://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html#fitline – masad Nov 02 '16 at 13:10
  • @masad fitLine uses m-estimation. – Micka Nov 02 '16 at 13:22
  • @zyrkor RANSAC line fitting: 1. draw randomly 2 of your edges. 2. evaluate for each edge, whether it is close enough to the line forned by those 2 samples and count it to be an inlier or an outlier. 3. do this many times until you are sure you've found the line with most inliers. 4. compute the final line with fitLine (or line regression) function using only all the inlier. But for your task I'd recommend to use LineSegmentDetector from openCV – Micka Nov 02 '16 at 13:27
  • 1
    @Micka Have a look at this: http://stackoverflow.com/a/15184899/798093 . "If one of the other distTypes is used (CV_DIST_L1, CV_DIST_L12, CV_DIST_FAIR, CV_DIST_WELSCH, CV_DIST_HUBER) then the procedure is some sort of RANSAC fit" – masad Nov 02 '16 at 13:33

0 Answers0