0

I am trying to build a python application that inspects a part that consists of a straight line followed by a curved arc (as seen in picture). The goal is to find the curvature and arc length of the curved section. My approach so far has been to threshold and skelotinze to produce a series of points. I then use least squares fitting to fit a piecewise mathematical function that is composed of a line and an arc. This works great for level parts.

However, if the parts are placed such that the straight section is not flat (parallel with horizontal axis) I run into problems. My solution thus far has been to fit a line to the left quarter of the image to detect the slope of the straight section. When doing my least squares fitting I then add in this factor (ie. add mx + b to the piecewise function). This produces a result that is close.

The error I found in this is approach is actually kind of interesting. Least squares fitting tries to minimize error in the y-axis for both flat and rotated parts. This is fine for level parts, but for rotated parts the error should really be defined as the distance between the data and the curve in a line perpendicular to the straight section so that the error is measured the same in both circumstances.

Any help in overall design of this problem would be greatly appreciated. I didn't think template matching was a good solution as my parts have different parameters (ie. curvature, arc length).

Here is an example where the straight section is a horizontal line:

enter image description here

CT Zhu
  • 52,648
  • 17
  • 120
  • 133
tesla
  • 51
  • 1
  • 4
  • Would be helpful if you provides a numerical example, such as the `(x,y)` coordinates of a 'bad case' where the straight section is not a horizontal line. – CT Zhu Mar 27 '14 at 15:29
  • @tesla If you know the angle of straight section you could rotate your image as explained here http://stackoverflow.com/questions/22041699/rotate-an-image-without-cropping-in-opencv-in-c/22042434#22042434 – Haris Mar 27 '14 at 15:43
  • This can be accomplished with orthogonal distance regression. Have a look at scip.optimize.odr – Christian K. Mar 27 '14 at 17:08
  • It is actually scipy.odr: http://docs.scipy.org/doc/scipy/reference/odr.html – Christian K. Mar 27 '14 at 17:16

0 Answers0