I am working on matching a scanned part to an AutoCAD dxf file, for a CNC-type machine. Currently working with Python. I’m only matching the side profile of the top of the part, meaning I only have a single curved/shaped line I need to match, not a complex 3D object.
For the CAD data, I’m using ezdxf to extract the polyline into a set of segments or vectors like below:
POLYLINE(#100):
LINE(#141):
START: (0.0, 0.0, 0.0)
END: (0.056535, -0.097921, 0.0)
ARC(#142):
START: (0.001108999999999985, -0.340083, 0.0)
END: (0.056535, -0.09792100000000001, 0.0)
CENTER: (-0.10151504858169047, -0.18917047707448414, 0.0)
RADIUS: 0.18250009567954073
START ANGLE: -55.783380656799125
END ANGLE: 29.99979308784541
ARC(#143):
START: (-0.014502999999999988, -0.34987999999999997, 0.0)
END: (0.0011089999999999989, -0.340083, 0.0)
CENTER: (-0.13975611047144998, -0.1329452814963482, 0.0)
RADIUS: 0.25049753247294054
START ANGLE: -59.998852627682936
END ANGLE: -55.78212995237357
ARC(#144):
etc....
The scanned data will be an array of thousands X/Y coordinates that traces the same 2D line. I need to be able to find the best matching CAD file, and be able to correctly “overlap” the two arrays. The CAD file is the tool path I will need to cut, and I need to automatically detect the start location.
I’m considering using OpenCV’s match feature:(https://docs.opencv.org/4.x/d5/d45/tutorial_py_contours_more_functions.html#autotoc_md1357)
However, this means I would need to take each data set, generate an SVG vector file, convert it to a PNG file, import to OpenCV and then perform the manipulations. Is there a more straight forward way to do this that I’m overlooking?
Thanks!