title: How to merge contours in opencv?
body: <p>Ok guys I have been working on this project for quite some time now. </p>
  
  <p>I am building this bot that plays the chrome dinosaur game. So I tried other methods to detect the characters like matchTemplate and even made my own algorithm to locate the objects, but I like this one (findcontours) the most.</p>
  
  <p>Here's what I have:</p>
  
  <p><a href="https://i.stack.imgur.com/inqXG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/inqXG.png" alt="What my program sees"></a></p>
  
  <p>Can anyone help me find out how I should merge the two rectangles of the cacti?</p>
  
  <pre><code>img = screen_cap()
  roi = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  ret, thresh = cv2.threshold(roi,127, 255, 0)
  im2, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  first = True
  for cnt in contours:
      area = cv2.contourArea(cnt)
      if area &gt; 200: #filtering contours
          x,y,w,h = cv2.boundingRect(cnt)
          if w/h &lt; 4: # filtering even more
              cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
  </code></pre>