title: CIDetector not detecting proper Rectangle in iOS?
body: <p>I am trying to detect a <code>Rectangle</code> using <code>CIDetector</code>.</p>
  
  <p>I am using code from this: <a href="https://www.cocoacontrols.com/controls/vnimagescanner" rel="nofollow noreferrer">https://www.cocoacontrols.com/controls/vnimagescanner</a></p>
  
  <p>My problem is when I am trying to detect any <code>Rectangle</code> object, sometimes it's detecting or sometimes it's detecting <code>Odd Rectangle</code> (please see below images). I tried to search this Google but didn't find any solution of this.</p>
  
  <blockquote>
    <p>Normal case:</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/0MXuP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0MXuP.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/hOXow.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hOXow.png" alt="enter image description here"></a></p>
  
  <blockquote>
    <p>Some bad case:</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/YCuee.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YCuee.png" alt="enter image description here"></a></p>
  
  <p>Here is my code to set the <code>CIDetector Accuracy</code> :</p>
  
  <pre><code>func highAccuracyRectangleDetector() -&gt; CIDetector? {
     var detector: CIDetector? = nil
     detector = CIDetector(ofType: CIDetectorTypeRectangle, context: nil, options: [CIDetectorAccuracy: CIDetectorAccuracyHigh, CIDetectorAspectRatio: 1.43, CIDetectorMaxFeatureCount: 5])
  
     return detector
  }
  </code></pre>
  
  <p>If you will look into third image, it's highlighting without <code>Rectangle</code> object. </p>
  
  <p>Is it possible to detect or to display the highlighted green overlay when there will be a proper <code>Rectangle</code>? Please suggest me.</p>