sew some random twenty lines into faces

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: sew some random twenty lines into faces

Post by microelly2 »

lots of questions ...

my viewpoint :
photos and 3D scans are not exact, so methods are needed to approximate useful details.
3D scans are often the result of a computation of two different views of the world. So having two photos of the same object you can calculate the skin of the object.
I use for my work real photos of buildings, and for tests screenshots of well known models to check my results against them.
When I'm able to find straight lines, segments of circles, parabolas and ellipses in images I have information to recreate planes, spheres, cones and cylinders.
My first task is to find these structures, then I can create a parametric FreeCAD object on top of a skech an an extrusion or revolution. The designer can easily change the parameters of the model if the scan ist not exact.

why ransac - in my last example video I can discover some of the arcs with an error less than 1 % on base fo the canny edge detection. I expect similar results for straight lines. I trust the power of large datasets.
As said 3D is only the sum of two 2D images. So I'm optimistic.

My workbench is very experimental and of course not part of FreeCAD. I think I need at least one month to get a first usable version.
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: sew some random twenty lines into faces

Post by teobo »

My workbench is very experimental and of course not part of FreeCAD. I think I need at least one month to get a
-first usable version.
The latter is a house number. Thanks therefore.
Me too I could do other works between, then on top of your code I could tackle the image processing distance in the present cases' tool chain.
Is not that a good plan?

Is it _possible to install however earlier? Yes or not no? "first usable " What does that mean: "Not before allowed?"

I would then be a first user of your new work bench, right? tatatata
As well you could drop out my case as an implemented Demo-Testcase- Regression-Test. One could. :mrgreen:
(Edit:On the other hand if we both profit from the current case implementation code, you besides as an owner of a regression test kind, demo function for your Code: then it could be just that you looked half way to get it going, - right. Too say it clear: I am really not against that you apply my regression test designs for your code. :?: If you think it is a good idea, let me now! :) )
Edit:+ was not that a part of your story where you brought teobo's "heatbridge" piggy pack, and working in two crossing fc projects at a time; it is worth mentioning, no? :)


Good luck however for it!
Ps:
-please let me know if there is a monetary profit ("work") after which you are with "reconstruction". Cause I assume : default None. ,right?
-furthermore I note that there is seemingly no free software implementation of "image recognized face or solid" outside freecad. So you were the first, the pioneer :? , one who tackles it.(?) At least the topic of delivering faces and solids to the user interface seems to be excluded in dominant teachings using matlab :? toolbox I found, am I wrong? :? Strange so. Not even here https://de.wikipedia.org/wiki/Darstellende_Geometrie find some hints for the "to-face-gap", the "to-solid-gap". :?

@all
-If anyone knows where this is explained, thanks.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: sew some random twenty lines into faces

Post by microelly2 »

For very alpha testing - https://github.com/microelly2/reconstruction
https://www.youtube.com/watch?v=v-yzs2LukjE
I will write an introduction this evening 8-)
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: sew some random twenty lines into faces

Post by cox »

Wow, this certainly seams to have enormous potential :D Way to go microelly2 :D
Need help? Feel free to ask, but please read the guidelines first
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: sew some random twenty lines into faces

Post by teobo »

I was surprised about the good quality of the image processing tools in opencv.
At the moment I lack a clear concept of "image processing". So you say it ran even better than other tools you know for it, rigth?
-Testing exactly what?
Well, so what is to say. This:
https://github.com/microelly2/reconstru ... ls.py#L335
def drawface():
# auswertuing verbessern: punkte /kanten in reihenfolge
sels=Gui.Selection.getSelection()
points=[]
for e in sels:
points.append(e.Shape.Vertexes[0].Point)
#print e
#print e.Point

w=Draft.makeWire(points,closed=True,face=True,support=None)
return w

[/code]

I see how you combine non-automatedly the as FC-Lines houghlines, but I do not find, how houghlines could be combined automatedly. I do not find these things in your stuff, I do not find it in the literature of "image processing courses", but I can assume some combining logic in your video.
https://youtu.be/4p3oD7limjU 1:55
So:
def Test_FC_houghlines_To_best_bet_topofaces();
def Test_best_bet_topofaces_and_FC_houghlines_To_best_bet_topocompound_();
Having the test run, describes our aim. (ok?)
I would like to know if there are any strategies available how to arrange this, cause here is where I really loose track in concluding if that will be a solution for: the "present case".

Anything that one could comment. I feel that the discussion get a little "black spotted" around matlab domains, affected, there for I opt for this special affair: noise?--verbous
Tia
PS1: if you probably might not find any -open- source, others with other capabilities might find. Well: I have difficulties to imagine that there are no maintained open source solutions within this black spot these days?
And Last but not Least: Is that seriously the believe? We are pioneers?
PS:2:Is not such a "Dark magic" annoying? I am glad if once this situation passed into being obvious. Really!
PS:3: btw: do you bother in using such unit tests actually? :P
Last edited by teobo on Mon Mar 14, 2016 2:41 pm, edited 1 time in total.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: sew some random twenty lines into faces

Post by ickby »

It is a rather hard problem you have here. There exists no algorithm in freecad yet for this. A solution for your problem would be a graph theoretical approach. Build up a planar graph from your problem, the graph nodes being the vertices which connect the lines and the graph edges beeing your lines. For a picture as you have shown it it will automatically be a planar graph. Then find the minimal cycle basis of the graph. Each cycle then can be used to create a face from it.

http://www.geometrictools.com/Documenta ... eBasis.pdf
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: sew some random twenty lines into faces

Post by teobo »

ickby wrote:It is a rather hard problem you have here. There exists no algorithm in freecad yet for this. A solution for your problem would be a graph theoretical approach. Build up a planar graph from your problem, the graph nodes being the vertices which connect the lines and the graph edges beeing your lines. For a picture as you have shown it it will automatically be a planar graph. Then find the minimal cycle basis of the graph. Each cycle then can be used to create a face from it.

http://www.geometrictools.com/Documenta ... eBasis.pdf


"minimal cycle basis of the graph"
"Each cycle"
do not understand not a word.(; One needs graph theory to wrestle this you say?

What happens when "cycle basis of the graph" is minimal? How to profit from it? What is a "circle"? I still lack the big picture...
Tia
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: sew some random twenty lines into faces

Post by teobo »

Thanks btw
User avatar
teobo
Posts: 410
Joined: Fri Feb 21, 2014 11:23 am

Re: sew some random twenty lines into faces

Post by teobo »

from "dark magic" to "theoretical dark magic" ... circles :roll:
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: sew some random twenty lines into faces

Post by ickby »

One needs graph theory to wrestle this you say?
IMHO yes, I do not know annother approach than graph based to this problem.
What is a "circle"?
What you need to create a face is a set of connected, closed edges which form an "area". Such a set of edges form a circle: Each edge connects to the next via a vertices and then last edge connects back to the first vertex. minimal circle basis means in this context all the smallest possible circles (without any inner edges) from which the larger ones can be build.

The linked paper describes this in detail and also gives algorithms. Also googling reveals some possible implementations.
Post Reply