CNC Toolpath Visualisation With OpenCV

[Tony Liechty] has been having a few issues getting into CNC machining — starting with a simple router, he’s tripped over the usual beginners’ problems, you know, things like alignment of the design to the workpiece shape, axis clipping and workpiece/clamp collisions. He did the decent hacker thing, and turned to some other technologies to help out, and came up with a rather neat way of using machine vision with OpenCV to help preview the toolpath against an image of the workpiece in-situ (video, embedded below.)

ChArUco (a combined chessboard and ArUco marker pattern) boards taped to the machine rails were used to give OpenCV a reference of where points in space are with respect to the pattern field, enabling identification of pixel locations within the image of the rails. A homography transformation is then used to link the two side references to an image of the workpiece. This transformation allows the system to determine the physical location of any pixel from the workpiece image, which can then be overlaid with an image of the desired toolpath. Feedback from the user would then enable adjustment of the path, such as shifts, or rotates to be effected in order to counter any issue that can be seen. The reduction of ‘silly’ clamping, positioning and other such issues, means less time wasted and fewer materials in scrap bin, and that can only be a good thing.

[Tony] says this code and setup is just a demo of the concept, but such ‘rough’ code could well be the start of something great, we shall see. Checkout the realWorldGcodeSender GitHub if you want to play along at home!

We’ve seen a few uses of OpenCV for assisting with CNC applications, like this cool you draw it, i’ll cut it hack, and this method for using machine vision to zero-in a CNC mill onto the centre of a large hole.

9 thoughts on “CNC Toolpath Visualisation With OpenCV

  1. I think that is absolutely brilliant. You’ve taken a problem that so many have moaned about, including myself, and found the start of a solution. This would be a perfect addition for the link between the design and manufacture stages of CNC. I am a software engineer by trade and a CNC hobbyist with never enough time to commit fully to it. You and most definitely onto something and I would love to be able to help in whatever way I can.

    1. Thanks! I have the similar problem of time, and think most people too. Would love to see it go into an open source g code sender sometime. The most intuitive one I saw this far to me with a snappy 3d UI seems to be gSender by Sienci labs. It seems to be able to handle images in the 3d viewer well with three.js/node.js/JavaScript. I’m hoping to prototype something that maybe can be polished up further for fun if when time, but certainly welcome anytime to try out too….I think with time hopefully can make it more open source usable. Basically, more polishing and then testing with different folks setup should do the trick. I’ve gotten good excitement and feedback for it, so maybe will become reality sometime.

  2. That’s a really worthwhile piece of work I would love to see this progess as a project. I would definitely use it on my diode laser gantry . Will have to look at your GitHub integration with laserweb4 would add massive value

Leave a Reply to Ewald Cancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.