title: Face Recognition with LBPHFaceRecognizer always predict as same person.Even when anonymous person to face the camera?
body: <p>I have a data set for myself.</p>
  
  <p>My code works perfectly when i go to the camera. But I test again with unknown person the program predicts again as me. It should return -1 or null !!!</p>
  
  <p>I run in python3 and latest version of cv2 from opencv.</p>
  
  <p>->detector.py</p>
  
  <pre><code>import cv2,os
  import numpy as np
  from PIL import Image 
  import pickle,time
  
  # Root directory
  ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
  
  recognizer = cv2.face.LBPHFaceRecognizer_create()#cv2.createLBPHFaceRecognizer()
  recognizer.read('trainer/trainer.yml')
  cascadePath = "Classifiers/face.xml"
  faceCascade = cv2.CascadeClassifier(cascadePath);
  path = 'dataSet'
  
  cam = cv2.VideoCapture(0)
  print(cam.isOpened())
  #font = cv2.InitFont(cv2.CV_FONT_HERSHEY_SIMPLEX, 1, 1, 0, 1, 1)
  
  #Creates a font
  font = cv2.FONT_HERSHEY_SIMPLEX
  
  while True:
      ret, im =cam.read()
      print('im: ',im,' ;ROOT_DIR:',ROOT_DIR)
      print('ret: ',ret)
      gray=cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
      faces=faceCascade.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=5, minSize=(100, 100), flags=cv2.CASCADE_SCALE_IMAGE)
      for(x,y,w,h) in faces:
          nbr_predicted, conf = recognizer.predict(gray[y:y+h,x:x+w])
          cv2.rectangle(im,(x-50,y-50),(x+w+50,y+h+50),(225,0,0),2)
          print("nbr_predicted: ",nbr_predicted)
          if(nbr_predicted==7 or nbr_predicted==8):
               nbr_predicted='Vishesh 1'
          else:
              nbr_predicted="Unknown Person"
          cv2.putText(im,str(nbr_predicted)+"--"+str(conf), (x,y+h),font, 0.8, (0, 255, 0), 2, cv2.LINE_AA) #Draw the text
          cv2.imshow('im',im)
          cv2.waitKey(10)
  </code></pre>
  
  <p>Only the person in middle must be Vishesh. But even my bros are predicted as Vishesh. Where could this be possibly going wrong ??</p>
  
  <p><a href="https://i.stack.imgur.com/KAuYc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KAuYc.jpg" alt="enter image description here"></a></p>