Int object not iterable? (Python) (URGENT, NEEDED BY TONIGHT)
This is really urgent and I need this tomorrow, I cant seem to find a solution anywhere, I have a script that runs a facial recognition script, but for some reason its telling me this exact error:
File "box.py",line 98, in <module>
label,confidence = model.predict(crop)
TypeError: 'int' object is not iterable
My code thats actually important to the problem:
import cv2
-Creates model to be the facerecognizer model = cv2.face.createEigenFaceRecognizer()
-Defines the model as a training image taken previously model.load(config.TRAINING_FILE)
-Initializes the camera as camera camera = config.get_camera()
-Takes a picture using the camera image = camera.read()
-Converts to grayscale image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
-Results if it found a face result = face.detect_single(image)
-Tells you to keep taking a picture until you have a face recognized
if result is None: print 'Could not see face! Retake picture!' continue
-gets dimensions of the face x,y,w,h = result
-resizes the face crop = face.resize(face.crop(image, x, y, w, h))
#Tests face against the previously taken model label, confidence = model.predict(crop) <--- This is where the error is
-Im not 100% as to what this does, I got this part on the internet result = cv2.face.MinDistancePredictCollector() model.predict(crop) label = result.getLabel() confidence = result.getDist()
Sorry about the weird formatting, the thing was being dumb and I couldnt fix it, anyways Thats basically it (Theres obviously some more code set up inside and between but it isnt important or relevant to the issue, at least I dont think, I need this urgently so please somebody respond quick, Im using Python 2.7 with opencv 3.1.0 on a raspbian raspberry pi 3 if you need that information
Sorry, we are not doing some code fixing service here! Please read this http://answers.opencv.org/faq/
there was a (short lived) bug in 3.1, where you only could use
label = model.predict(crop)
either update to latest 3.3, or use the MinDistancePredictCollector