title: Recognizing rectangles in OpenCV Java
body: <p>I'm trying to crop rectangles out of an image using OpenCV/Java.  I've been somewhat successful finding the lines that make up the rectangular sections I want to crop, but I'm having a hard time finding the best way to do the following:</p>
  
  <ol>
  <li>Connect the segmented lines I've found (see screenshot below) into separate rectangles (lines can be shared by multiple adjacent rectangles)</li>
  <li>Determine that a nearly complete rectangle is a rectangle (see broken bottom edge of full rectangle in screenshot, to the left of line #6)</li>
  </ol>
  
  <p>Any guidance is appreciated!</p>
  
  <p><a href="https://i.stack.imgur.com/KKLtR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KKLtR.png" alt="rectangle image"></a></p>