title: How to fix OpenCV Numpy Error, object is not iterable
body: <p>I'm following a guide to develop a motion detection security feed and have run into an issue. The author of the tutorial had no issues, but I do.</p>
  
  <p>'''The full code can be found here: <a href="https://github.com/ncorbuk/Python-Motion-Detection-system/blob/master/motion_detection.py" rel="nofollow noreferrer">https://github.com/ncorbuk/Python-Motion-Detection-system/blob/master/motion_detection.py</a> 
  '''</p>
  
  <p>I have already tried the option of adding,</p>
  
  <p>" for c in cnt or []: " - This got me further into running the application where I could see the camera screens, however as soon as motion is detected the application crashes and provides the following numpy error:</p>
  
  <blockquote>
    <p>The truth value of an array with more than one element is ambiguous.
    Use a.any() or a.all()</p>
  </blockquote>
  
  <pre><code>for c in cnt:
          if (cv2.contourArea(c) &gt; 800): 
              (x, y, w, h) = cv2.boundingRect(c)
  
              cv2.rectangle(frame, (x,y), (x+w, y+h), (0, 255, 0), 2) 
  
              text = 'Occupied'
  
          else:
              pass
  </code></pre>
  
  <p>The expected output, if you have a webcam;
  When motion is detected a green rectangle will follow the moving pixels and change the mode from Unoccupied to Occupied, in real time; with no errors.</p>