title: Connect groups of contours and keep track of contours in a set
body: <p>I want to group a different number of contours found with opencv to a set:</p>
  
  <p><img src="https://i.stack.imgur.com/3APKy.jpg" alt="Contours"></p>
  
  <p><img src="https://i.stack.imgur.com/2Rp7p.jpg" alt="Sets of contours"></p>
  
  <p>I also want to keep track of the indexes for every contour in every set,
  e.g. in Set 1 you can find contour 10,11,12,13,14.
  My contours are stored in a <code>vector&lt;vector&lt;Point&gt;&gt;</code>.<br>
  I already tried the function <code>cv::approxPolyDP</code> but the polygon will be drawn around all contours.<br>
  I know I can calculate the distance between every single contour pair but how can I use the distance to group them to a new contour?</p>