Author Topic: Auto-tracing a captured image  (Read 26203 times)

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 9075
    • View Profile
Auto-tracing a captured image
« on: January 03, 2025, 01:26:37 am »
This latest X-Acto blade holder project made me realize that I have no good way to capture the outline of a complex shape, and translate that into a CamBam drawing.

Do any of you have any favorite methods, like an auto-tracing algorithm, that would do that?

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline tau

  • Storm Trooper
  • ***
  • Posts: 178
    • View Profile
Re: Auto-tracing a captured image
« Reply #1 on: January 03, 2025, 11:43:10 am »
Lloyd,

first of all happy new year!

Tracing is available on various occasions, depending on your drawing preference.

Starting off with something like the free inkscape drawing continued by almost any version of Coreldraw, Adobe Illustrator and so on and on.... it is available on these systems (including export capability to exportin various formats). I am pretty sure there are  a bunch of free online services as well.

But what about using the built-in tracing functionality of CamBam?!

My preference is using also Lightburns tracing functionlity, which is quite fast and reliable. But usually you a license of it when using a laser engraver.

Regards

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 9075
    • View Profile
Re: Auto-tracing a captured image
« Reply #2 on: January 03, 2025, 12:46:07 pm »
Tau,
If you're talking about the bitmap smoothing and 'edge detection' function... heh!  That's why I was asking for 'other help'. :D

It really does not do a decent job, unless your bitmap is quite-nearly a perfect outline to begin with.  It just cannot follow edges unless the contrast ratio between object and background is nearly 100%, and there are zero shadows to contend with; even 'grey' shadows.

What you get is a rough, jagged line of dots with lots of points outside and inside the real line.  There's no real smoothing going on.

Lloyd
« Last Edit: January 03, 2025, 17:57:39 pm by lloydsp »
"Pyro for Fun and Profit for More Than Fifty Years"

Offline tau

  • Storm Trooper
  • ***
  • Posts: 178
    • View Profile
Re: Auto-tracing a captured image
« Reply #3 on: January 03, 2025, 18:07:40 pm »
Lloyd,

i got you...

Since i do own a LightBurn license for my laser engraver and it is working quite well, i usually go with it.

Before that i used to used also the services of vectorizer.ai (until they became paid services... but still affordable), since their results were also excellent (or even better than that of  LightBurn).

So it depends really how much effort you are willing to invest in finessing your vectorization results, but IMO both do a great job.

If you want to get an impression how well the results of LightBurn are, you can provide an example of yours that i can gladly vectorize it and return.

Tunc (tau)

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 9075
    • View Profile
Re: Auto-tracing a captured image
« Reply #4 on: January 03, 2025, 19:40:32 pm »
Tunc,
I would be interested in seeing how a 'good' capture looks.  I have two .jpg files, one captured in 'document' format, and the other as a photo.  How can I get those to you?

Lloyd
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dh42

  • Administrator
  • CNC Jedi
  • *****
  • Posts: 7564
    • View Profile
    • Cambam V1.0 French Doc
Re: Auto-tracing a captured image
« Reply #5 on: January 03, 2025, 20:02:01 pm »
Hello

A post about AI vectorization

https://cambamcnc.com/forum/index.php?topic=4935.0

++
David

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5320
  • Made in England
    • View Profile
Re: Auto-tracing a captured image
« Reply #6 on: January 03, 2025, 20:40:50 pm »
For a physical object, this works well for me.

1. Take a photo zoomed in at a distance to remove fisheye distortion, ensure camera is central and perpendicular to the object.
2. Import into Rhino CAD and manually trace the object.
3. Export to dxf and import into CamBam
4. Cut a test piece in scrap material then adjust drawing in Rhino if required.

Sometimes using a flatbed scanner works if the item if fairly flat.

It's not a big task so auto trace does not matter to me.
« Last Edit: January 03, 2025, 20:42:53 pm by EddyCurrent »
Filmed in Supermarionation

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1889
    • View Profile
Re: Auto-tracing a captured image
« Reply #7 on: January 04, 2025, 00:04:13 am »
I tried to reply to this post twice yesterday, both times the website crashed.
As the post has moved on since, I'll just say that I do what Eddy does with Freecad.
I use this to great effect with 2d gaskets either for the laser or drag knife.

With Freecad I take the shot with a 6\150 mm  inch machinists rule you can then get
Freecad to scale the image, this works nicely even for the smaller carb gaskets.
It's not perfect though, and I try to use a known dimension on the drawing for example a
bolt hole diameter.

For 3D stuff its more difficult, a couple of weeks ago I reversed engineered The Y axis
drive dog (I wanted to know its length) so snipped an image from the video I posted , which
was  tilted in X Y and it helped a lot that I knew the bolt hole and bolt circle diameter.

Dave

Offline EddyCurrent

  • CNC Jedi
  • *****
  • Posts: 5320
  • Made in England
    • View Profile
Re: Auto-tracing a captured image
« Reply #8 on: January 04, 2025, 10:58:43 am »
There is Potrace, "Potrace(TM) is a tool for tracing a bitmap, which means, transforming a bitmap into a smooth, scalable image"

https://potrace.sourceforge.net/
Filmed in Supermarionation

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1889
    • View Profile
Re: Auto-tracing a captured image
« Reply #9 on: January 05, 2025, 01:19:47 am »
There are some really good resources for engineering files on the web Grabcad being
one (there are many), This is one from grabcad its dimensionally correct.
You do have to check the files, though as a stepper motor I downloaded a while ago was
otherwise a well executed file but was out of spec by 3mm.
this is the sixth attempt to post to this thread.
can not post attachments.

Dave

Offline lloydsp

  • CNC Jedi
  • *****
  • Posts: 9075
    • View Profile
Re: Auto-tracing a captured image
« Reply #10 on: January 05, 2025, 02:50:01 am »
Eddy, I tried potrace, but it only traces (well, smooths) and existing bitmap line drawing.  It will not extract outlines from a photo or a scan of a part.

Dave, I haven't been able to post attachments for months, here.  But if you can put it on a repository, you can post a link in the text of a message, either by hand or with the globe button above.   Like:

https://cambamcnc.com

Lloyd
« Last Edit: January 05, 2025, 02:52:26 am by lloydsp »
"Pyro for Fun and Profit for More Than Fifty Years"

Offline dave benson

  • CNC Jedi
  • *****
  • Posts: 1889
    • View Profile
Re: Auto-tracing a captured image
« Reply #11 on: January 05, 2025, 03:37:07 am »
Here you go, that link has both .stp and .stl files.
I loaded them up in freecad and checked the dims and they are ok.
I've found that the search terminology is critical, sometimes the people
doing the drawing are otherwise good at cad, but call the object by a name
that is not what we would call it in the trades.
Sometimes after a fruitless search, I call the object what I think someone might call it
who is not from the industry.  This has worked for me in the past, when that fails I
deliberately miss spell the Objects name. This has worked more often than it should.

The file I posted might not be the exact one your looking for but there are more
there, Thinking about it, maybe McMaster Carr might be worth a look too.

The errors I'm getting now are Error 500 and when I tried to reply to Gary's post (just text)
the browser froze, I closed down the browser and opened a new instance and upon opening
it opened at the cambam site and proceeded to add new CB tabs until it crashed, I had to restart the
computer to get any sense out of it.

Dave

Excel # 22-611 Hobby Blade #11 | 3D CAD Model Library | GrabCAD

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 4563
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: Auto-tracing a captured image
« Reply #12 on: January 14, 2025, 17:24:02 pm »
It depends on what you are trying to do. 

The trace or outline or whatever it is function from Inkscqape is only marginally okay for copying line art. 

Sometimes for organic simple-ish shapes I'll photograph it from several angles and then manually trace it in ViaCAD with a combination of lines, arcs, and splines.  The spline tool in ViaCAD is (in my opinion) a little better than the one in CamBam.  Then I'll set scales (sometimes before) based on physically measuring the object.  Then I'll us all those conglomerations (each one restricted to 2 dimensions) to try and create the 3D shape.  I see lots of failures. 

I recently (several months ago) picked up a 3D laser scanner, but I've been so busy its still in the box. 

For mechanical items like 2D templates, adapter plates, and gaskets a light tablet and stylus can do an amazing job.  Trace, 3 point interpoalte, and locate with the styluis, and the offset of the stylus ibs known.  This would be good for something like a gasket, control panel, etc. 
Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 4563
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: Auto-tracing a captured image
« Reply #13 on: January 14, 2025, 17:26:20 pm »
It depends on what you are trying to do. 

The trace or outline or whatever it is function from Inkscqape is only marginally okay for copying line art. 

Sometimes for organic simple-ish shapes I'll photograph it from several angles and then manually trace it in ViaCAD with a combination of lines, arcs, and splines.  The spline tool in ViaCAD is (in my opinion) a little better than the one in CamBam.  Then I'll set scales (sometimes before) based on physically measuring the object.  Then I'll us all those conglomerations (each one restricted to 2 dimensions) to try and create the 3D shape.  I see lots of failures. 

I recently (several months ago) picked up a 3D laser scanner, but I've been so busy its still in the box. 

For mechanical items like 2D templates, adapter plates, and gaskets a light tablet and stylus can do an amazing job.  Trace, 3 point interpoalte, and locate with the styluis, and the offset of the stylus ibs known.  This would be good for something like a gasket, control panel, etc. 
Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com

Offline Bob La Londe

  • CNC Jedi
  • *****
  • Posts: 4563
  • ^ 8.5 pounds on my own hand poured bait.
    • View Profile
    • CNC Molds N Stuff
Re: Auto-tracing a captured image
« Reply #14 on: January 14, 2025, 17:39:59 pm »
One more try. 

It depends on what you are trying to do. 

The trace or outline or whatever it is function from Inkscqape is only marginally okay for copying line art. 

Sometimes for organic simple-ish shapes I'll photograph it from several angles and then manually trace it in ViaCAD with a combination of lines, arcs, and splines.  The spline tool in ViaCAD is (in my opinion) a little better than the one in CamBam.  Then I'll set scales (sometimes before) based on physically measuring the object.  Then I'll us all those conglomerations (each one restricted to 2 dimensions) to try and create the 3D shape.  I see lots of failures. 

I recently (several months ago) picked up a 3D laser scanner, but I've been so busy its still in the box. 

For mechanical items like 2D templates, adapter plates, and gaskets a light tablet and stylus can do an amazing job.  Trace, 3 point interpolate, and locate with the stylus, and the offset of the stylus is known.  This would be good for something like a gasket, control panel, etc. 
Getting started on CNC?  In or passing through my area?
If I have the time I'll be glad to show you a little in my shop. 

Some Stuff I Make with CamBam
http://www.CNCMOLDS.com