title: trace patterns such that each node is visited only once(eulerian path) using opencv
body: <p>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. </p>
  
  <p><strong>My problem statement:</strong></p>
  
  <p>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).</p>
  
  <p><strong>What I wanna achieve:</strong></p>
  
  <p>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.  </p>
  
  <p><strong>Thing to be noted in the animation:</strong></p>
  
  <p>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)</p>
  
  <p><strong>Here are the 15 unique shapes which I used to build the patterns with:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/2tsYd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2tsYd.png" alt="enter image description here"></a> </p>
  
  <p>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. <strong>I have manually got the x y coordinates of the patterns and placed it in sequence</strong>. But that is not at all scalable.</p>
  
  <p><strong>How to trace the patterns such that each node is visited only once ?</strong>:</p>
  
  <p><strong>1st kind of pattern and the way it should be drawn:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/9kES9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9kES9.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/Osq5H.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Osq5H.gif" alt="enter image description here"></a></p>
  
  <p><strong>2nd kind of pattern and the way it should be drawn:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/FtC77.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FtC77.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/BUK6m.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BUK6m.gif" alt="enter image description here"></a></p>
  
  <p><strong>3rd kind of pattern and the way it should be drawn:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/u0DKM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/u0DKM.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/7DroC.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7DroC.gif" alt="enter image description here"></a></p>