0
$\begingroup$

For the last 3 months I have been working on a CNC drawing machine but to this day I can't get the algorithm for line detection so I came here.

I can't understand only one part and it is CAM the (image to G-code) so I'd be grateful if someone could help.

(I want to create my own software not use any modules)

$\endgroup$
2
  • 1
    $\begingroup$ If I understand correctly, you want to write software that parses an image to G-code rather than using available software. Maybe you should explain why. $\endgroup$
    – 0scar
    Commented May 22, 2020 at 22:17
  • $\begingroup$ If you slice an image, you will get gcode to create a lithophane. If you slice a 3D model, you will get gcode to create a replica of that model. What is your ultimate goal? $\endgroup$
    – Davo
    Commented May 26, 2020 at 12:25

1 Answer 1

1
$\begingroup$

Generally, movement in a CNC, FDM-Printer, laser cutter, and Plotter has the XY plane decoupled from the Z-axis in most operations. As a result, the path in the XY plane is in 2D. But how to get to a path? Well, we have 2 variants:

Pixel

Most pictures store information as Pixels: each pixel on a grid has a color assigned to it. Scaling the picture does alter the grid size. These pictures are very hard to plot, unless you have your machine interpret each pixel of a given color as a specific movement operation. For example, each pixel of black color in a monochrome picture could be translated as a square-movement of a certain size, using the top-left corner of the square for the operation's reference. In G-code, drawing a line around the Pixel X=10 Y=10 with a grid size of 1 mm looks like this:

G90 ; absolute mode!
G1 X10 Y10
G1 X1 E1
G1 Y1 E1
G1 X-1 E1
G1 Y-1 E1

Vector

proper 2D-Pathes are stored only in Vector graphics. If you can, Vector graphics can contain the exact path you want your machine to follow. A typical format is .svg. It contains already the start position of path and how to follow it. Going from Vector Graphic to G-code just needs you to add G1 before each part of the path instruction and E commands at the end to operate whatever tool you due - be it spinning the drill in a CNC, extruding filament in a printer, turning on a laser or pushing down the printhead in a plotter.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .