跟踪模式,从而使用opencv仅对每个节点进行一次访问(欧拉路径) [英] trace patterns such that each node is visited only once(eulerian path) using opencv

查看:119
本文介绍了跟踪模式,从而使用opencv仅对每个节点进行一次访问(欧拉路径)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我整整一年以来一直在努力解决的问题.直到年底都没有成功.我必须寻求stackoverflow专家的帮助和具体解决方案.

我的问题陈述:

我一直在研究一些设计模式,我想以编程方式跟踪是否存在欧拉路径(如下图gif所示).下面是图案和我想要绘制它们的方式.

我想要实现的目标:

提供设计图案图像作为输入.我想在一个笔触中跟踪设计图案图像,如gifs中所示(gifs动画只是如何在单个笔触中绘制图案的示例).一旦我以单笔画方式(欧拉路径)获得图像的x和y坐标.我会将那些坐标输入到程序中以仅跟踪那些坐标.

动画中需要注意的地方:

1)基本上是一个未被检测到的图形(节点是形状的顶点,如果存在,则边缘是2个顶点之间的笔触). (欧拉路径)

以下是我用来构建图案的15种独特形状:

我有400多个模式(下面已经显示3个模式),到目前为止,我还没有找到通用的解决方案. 我已经手动获取了图案的x y坐标并将其依次放置.但这根本不是可扩展的.

如何跟踪模式,以便每个节点只能访问一次?:

第一种图案及其绘制方式:

第二种图案及其绘制方式:

第三种图案及其绘制方式:

解决方案

如果您仍在努力解决上述问题,也许您可​​以研究旅行商的问题. TSP只能访问城市一次.而且,如果您的情况是每个节点都是删除线的交叉点,那么这可能会有所帮助.

此处中查看要查找的python代码.我已经检查过了,打印语句看起来很好而且结构清晰. cMinor做得好!

根据讨论进行文件1 文件3 .

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:

解决方案

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.

这篇关于跟踪模式,从而使用opencv仅对每个节点进行一次访问(欧拉路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆