Converting Kids’ Hand-Drawings to G-Code

[Martin Raynsford] wrote a program that converts a black-and-white 2D image to G-code so that his laser printer could then etch the image. Not satisfied with just that, he used his laser printer to make a scanner that consists of a stand for his webcam and a tray below it for positioning the paper just right. The result was something he took to a recent Maker Faire where many kids drew pictures on paper which his system then scanned and laser etched.

Screenshot of Martin's scanning and G-code maker program
Martin’s scanning and G-code maker program

[Martin’s] program, written in C#, does the work of taking the image from the webcam using OpenGL and scanning it line by line looking for pixels that surpass a contrast threshold. For each suitable pixel the program then produces G-code that moves the laser to the corresponding coordinate and burns a hole. Looking at the source code (downloadable from his webpage) it’s clear from commented-out code that he did plenty of experimenting, including varying the laser burn time based on the pixel’s brightness.

While it’s a lot of fun writing this code as [Martin] did, after the break we talk about some off-the-shelf ways of accomplishing the same thing.

One option is to use software such as MeshCAM or VCarve, both of which will take an image, allow you to do some modifications depending on your tool, and output G-Code. In the video below, jewelry is made starting with a paper drawing. A phone camera acts as the scanner and minor tweaks are made in Photoshop. From there the resulting AI file is brought into MeshCAM for more preparation and finally the G-Code. In this example the jewelry is cut out of brass on a CNC machine.

If your CAD program has a tracing feature then another option is to load your image into Adobe Illustrator, save it as an AI file, and then load that into you CAD program. In there you’d trace the 2D image and then use the CAD program to manipulate the result to something appropriate for your tool.

And if you want to see another example a DIY G-Code generator, check out this free 3D-modelling software Blender add-on called Blender CAM.

Thanks [Martin] for the tip!

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *