title: Can't determine document edges from camera with OpenCV
body: <p>I need find edges of document that in user hands.</p>
  
  <p>1) Original image from camera:</p>
  
  <p><a href="https://i.stack.imgur.com/CXU1wb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CXU1wb.jpg" alt="enter image description here"></a>
  <br/><br/>
  2) Then i convert image to BG:</p>
  
  <p><a href="https://i.stack.imgur.com/71fHSb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/71fHSb.jpg" alt="enter image description here"></a>
  <br/><br/></p>
  
  <p>3) Then i make blur:</p>
  
  <p><a href="https://i.stack.imgur.com/h6g2bb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h6g2bb.jpg" alt="enter image description here"></a>
  <br/><br/></p>
  
  <p>3) Finds edges in an image using the Canny:</p>
  
  <p><a href="https://i.stack.imgur.com/Y9eJsb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y9eJsb.jpg" alt="enter image description here"></a>
  <br/><br/></p>
  
  <p>4) And use dilate :</p>
  
  <p><a href="https://i.stack.imgur.com/LhxqKb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LhxqKb.jpg" alt="enter image description here"></a>
  <br/><br/></p>
  
  <p>As you can see on the last image the contour around the map is torn and the contour is not determined. What is my error and how to solve the problem in order to determine the outline of the document completely?</p>
  
  <p>This is code how i to do it:</p>
  
  <pre><code>final Mat mat = new Mat();
      sourceMat.copyTo(mat);
  
      //convert the image to black and white
      Imgproc.cvtColor(mat, mat, Imgproc.COLOR_BGR2GRAY);
  
      //blur to enhance edge detection
      Imgproc.GaussianBlur(mat, mat, new Size(5, 5), 0);
      if (isClicked) saveImageFromMat(mat, "blur", "blur");
  
      //convert the image to black and white does (8 bit)
      int thresh = 128;
      Imgproc.Canny(mat, mat, thresh, thresh * 2);
  
      //dilate helps to connect nearby line segments
      Imgproc.dilate(mat, mat,
              Imgproc.getStructuringElement(Imgproc.MORPH_RECT, new Size(3, 3)),
              new Point(-1, -1),
              2,
              1,
              new Scalar(1));
  </code></pre>