title: Python - Face Recognition TypeError: 'int' object is not iterable
body: <p>I am trying to implement a magic mirror facial recognition module for a project. When I run the tester on the file I am getting an error, I cannot seem to resolve it. </p>
  
  <p>This is what displays in terminal: </p>
  
  <pre><code>Loading training data...
  
  ALGORITHM: LBPH
  
  Training data loaded!
  
  Picam selected...
  
  Traceback (most recent call last):
  
  File "facerecognition.py", line 61, in &lt;module&gt;
  
  label, confidence = model.predict(crop)
  
  TypeError: 'int' object is not iterable
  </code></pre>
  
  <p>My picamera stays active but i can see another image which is my face in the background, Below is my code</p>
  
  <pre><code>import cv2  # OpenCV Library
  import lib.face as face
  import lib.config as config
  import time
  import os
  
  # Load training data into model
  print('Loading training data...')
  
  if config.RECOGNITION_ALGORITHM == 1:
     print "ALGORITHM: LBPH"
     model = cv2.face.createLBPHFaceRecognizer(threshold=config.POSITIVE_THRESHOLD)
  elif config.RECOGNITION_ALGORITHM == 2:
     print "ALGORITHM: Fisher"
     model = cv2.createFisherFaceRecognizer(threshold=config.POSITIVE_THRESHOLD)
  else:
     print "ALGORITHM: Eigen"
     model =     cv2.createEigenFaceRecognizer(threshold=config.POSITIVE_THRESHOLD)
  
  model.load("training.xml")
  print('Training data loaded!')
  
  camera = config.get_camera()
  
  time.sleep(1)   # give the camera a second to warm up
  while True:
      # camera video feed
      frame = camera.read()
  
      image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
  
      faces = face.detect_face(image)
      if faces is not None:
          for i in range(0, len(faces)):
              x, y, w, h = faces[i]
              x_face = x
              y_face = y
              if config.RECOGNITION_ALGORITHM == 1:
              crop = face.crop(image, x, y, w, h)
      else:
              crop = face.resize(face.crop(image, x, y, w, h))
  
  
      label, confidence = model.predict(crop)
      cv2.rectangle(frame, (x, y), (x + w, y + h), 255)
      cv2.putText(frame, str(h), (x + w, y + h + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
      if (label != -1 and label != 0):
          # If person is close to the camera use smaller POSITIVE_THRESHOLD
          if h &gt; 190 and confidence &lt; config.POSITIVE_THRESHOLD:
              cv2.putText(frame, config.users[label - 1], (x - 3, y - 8), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)
              cv2.putText(frame, str(confidence), (x - 2, y + h + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
              print('User:' + config.users[label - 1])    
          # If person is further away from the camera but POSITIVE_THRESHOLD is still under 40 assume it is the person
          elif h &lt;= 190 and confidence &lt; config.POSITIVE_THRESHOLD:
              cv2.putText(frame, config.users[label - 1], (x - 3, y - 8), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)
              cv2.putText(frame, str(confidence), (x - 2, y + h + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
              print('User:' + config.users[label - 1])
          # If person is further away from the camera be a bit more generous with the POSITIVE_THRESHOLD and add a not sure statement
          elif h &lt; 190:
              cv2.putText(frame, "Guess: " + config.users[label - 1], (x - 3, y - 8), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 1)
              cv2.putText(frame, str(confidence), (x - 2, y + h + 15), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
              print('Guess:' + config.users[label - 1])
          else:
              cv2.putText(frame, "Unknown", (x, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)
              print('Unknown face')
      else:
          cv2.putText(frame, "Unknown", (x, y - 5),     cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)
          print('Unknown face')
  
       # If person is close enough
       if h &gt; 250:
           eyes = face.detect_eyes(face.crop(image, x, y, w, h))
           for i in range(0, len(eyes)):
               x, y, w, h = eyes[i]
               cv2.rectangle(frame, (x + x_face, y + y_face - 30), (x +  x_face + w + 10, y + y_face + h - 40), (94, 255, 0))
               cv2.putText(frame, "Eye " + str(i), (x + x_face, y +         y_face - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
  
       if ('DISPLAY' in os.environ):
           # Display Image
           cv2.imshow('Facial recognition', frame)
           k = cv2.waitKey(1) &amp; 0xFF
           if k == ord('q'):
               break
       else:
           print('writing face.jpg image')
           cv2.imwrite('face.jpg',frame)
           camera.stop()
           break
  
  # Release camera and close windows
  camera.stop()
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>Any help would be appreciated, Can anyone help with this, I am really stuck.</p>