Ask Your Question
1

Detect slightly distorted line

asked 2013-09-19 10:32:07 -0600

tofi9 gravatar image

updated 2013-09-19 10:34:53 -0600

Given the following (canny'd) image, I'd like to grab the start/end endpoints of the full upper horizontal line.

I've tried opencv's HoughLineP function, but get segments rather than a full line. I realise that this is due to the camera calibration distortion.

  • Is there some other technique that is more forgiving when it comes to curvy distortions?
  • Alternatively, what would be a good way to join points that close to each other (with somehow similar angle)

Original

Orignal-canny

Code

Mat scene = imread("houghLines.png", 0);

vector<Vec4i> lines;
HoughLinesP(scene, lines, 1, CV_PI/180, 40, 100, 20 );

cvtColor(scene, scene, COLOR_GRAY2BGR); scene *= 0.5; // convert to colour

auto colours = generateColours((int)lines.size());
for(int i = 0; i < lines.size(); i++) {
    auto l = lines[i];
    line(scene, Point(l[0], l[1]), Point(l[2], l[3]), colours[i], 1, CV_AA);
}

imshow("scene", scene);
waitKey();

Result

Result

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-19 13:04:16 -0600

What I suggest is looking at the ratio's of those small segments, look if it is a horizontal or vertical, left or right part and then use the begin and end points of all corresponding points to create a list of points.

Next you can try to fit a line through that pointcloud using the fitLine function.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-09-19 10:32:07 -0600

Seen: 1,054 times

Last updated: Sep 19 '13