title: NameError: name 'x1' is not defined in OpenCV Python
body: <p>My OpenCV (Python) code for detecting object:</p>
  
  <pre><code>import ...
  face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
  cap1 = cv2.VideoCapture(1)
  
  while True:
      ret1, img1 = cap1.read()
  
      gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
  
      faces = face_cascade.detectMultiScale(gray, 1.3, 5)
      for (x1, y1, w1, h1) in faces:
              if x1 &gt;0:
              detect_face1 = x1
              print 'face distance Camera 1: ', detect_face1
          else:
              pass
  </code></pre>
  
  <p>Debugger showing that <code>faces</code> is <code>type tuple: ()</code>, probably as a result showing <code>if x1 &gt;0: NameError: name 'x1' is not defined</code>. Because if Face is detected in camera then <code>faces</code> is an array which has a x1 value > 0. I know it may be pretty simple fix, but any help is appreciated.</p>