title: Image Processing : Border detection of an object on (quite) the same background color
body: <p>I'm working on Python 3.6, with almost only OpenCV.3.
  I'm trying to find automatically the contours of a sheet of paper to crop it at the right size, here is on example :</p>
  
  <p><img src="https://i.stack.imgur.com/eFFzz.jpg" alt="Image"></p>
  
  <p>I've seen a lot of posts about quite the same subject but finally nothing really for me.</p>
  
  <p>So this is the code I use:</p>
  
  <pre><code>orig = cv2.imread("Image.jpg")
  cv2.imshow('result', imutils.resize(orig, height=600))
  cv2.waitKey(0)
  
  img = cv2.cvtColor(orig, cv2.COLOR_BGR2GRAY)
  cv2.GaussianBlur(img, (3,3), 0, img)
  
  
  edges = cv2.Canny(img,10,20,apertureSize = 3)
  cv2.imshow('result', imutils.resize(edges, height=600))
  cv2.waitKey(0)
  </code></pre>
  
  <p>And this is the output: </p>
  
  <p><img src="https://i.stack.imgur.com/lTJWM.png" alt="canny"></p>
  
  <p>So now I try to find the countours Using HougLines or the HougLinesProbabilities.</p>
  
  <pre><code>#minLineLength=100000
  #maxLineGap=50
  #lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
  lines = cv2.HoughLines(edges,1,np.pi/180*10,150,0,0)
  </code></pre>
  
  <p>But I don't have anything usable.. (I would be able to add what I obtain if I have more reputation here)
  I don't know if I don't have to use HoughLines or if I just can't get the right parameters..
  I've already looked at corner detection but it's quite the same problem.</p>
  
  <p>Any ideas ?</p>