title: OpenCV contours not closing
body: <p>Good day everyone!</p>
  
  <p>I got an issue in regard of creating contours. I tried all configurations and unfortunately it is not possible for me to get one big contour of the object.
  First file is loaded into bitmap and in the end the bitmap is loaded to file.
  (Not shown here as it gives nothing).</p>
  
  <p>Image before:</p>
  
  <p><a href="https://i.stack.imgur.com/iWsqd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iWsqd.jpg" alt="img1"></a></p>
  
  <p>Image after:</p>
  
  <p><a href="https://i.stack.imgur.com/avWDm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/avWDm.jpg" alt="img2"></a></p>
  
  <p>The effect I would like to have is just the outer contour of the whole car or at least some approximation of it. The code I currently have (after looking everywhere) is this:</p>
  
  <pre><code>bitmap = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(filePath), 500, 500);
      Mat src = new Mat();
      Utils.bitmapToMat(bitmap, src);
      Mat gray = new Mat();
      Imgproc.cvtColor(src, gray, Imgproc.COLOR_RGBA2GRAY);
      Imgproc.Canny(gray, gray, 0, 1000);
      List&lt;MatOfPoint&gt; contours = new ArrayList&lt;MatOfPoint&gt;();
      Mat hierarchy = new Mat();
      Imgproc.findContours(gray, contours, hierarchy, Imgproc.CV_RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE);
      for (int contourIdx = 0; contourIdx &lt; contours.size(); contourIdx++) {
          Imgproc.drawContours(src, contours, contourIdx, new Scalar(0, 0, 255), -1);
      }
      Utils.matToBitmap(gray, bitmap);
  </code></pre>