trace patterns such that each node is visited only once(eulerian path) using opencv

荒凉一梦 提交于 2019-12-04 14:38:36

问题


Here is my problem which I am trying to solve since one complete year. With no success till end of the year. I have to seek help and a concrete solutions from the stackoverflow experts.

My problem statement:

I have been working with some design patterns which I want to trace if eulerian path exist(as shown in below gifs), programmatically. Below are the patterns and the way I wanna draw them(gifs).

What I wanna achieve:

Give the design pattern images as input. I want trace the design pattern image in a single stroke as shown in the gifs(gifs animations are just examples of how the patterns is drawn in single stroke). Once I get the x and y coordinates of the image in single stroke fashion(eulerian path). I will feed those coordinates to my program to just trace those coordinates.

Thing to be noted in the animation:

1) basically its an undetected graph (the nodes being the vertices of your shapes, the edges if exists being the strokes between 2 vertices). (eulerian path)

Here are the 15 unique shapes which I used to build the patterns with:

I have more then 400 patterns(3 patterns already shown below) and till now I am not able to find a generic solution for this. I have manually got the x y coordinates of the patterns and placed it in sequence. But that is not at all scalable.

How to trace the patterns such that each node is visited only once ?:

1st kind of pattern and the way it should be drawn:

2nd kind of pattern and the way it should be drawn:

3rd kind of pattern and the way it should be drawn:


回答1:


Perhaps you can look into the traveling salesman problem if your still struggling with the above. TSP visits cities only once. And if in your case each node is a crossing for your strike-through then this might help.

Check here for the python code to look at. I've checked and the print statement looks nice and structured. Well done cMinor!

Edit based on discussion: file 1, file2, file3.



来源:https://stackoverflow.com/questions/47164127/trace-patterns-such-that-each-node-is-visited-only-onceeulerian-path-using-ope

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!