I am making a real-time facial recognizer and the function I have to train the model is giving me an error and I have looked everywhere for a fix but none have worked. Ant help is much appreciated. The error is on the 5th to last line. see error message under the code
CODE:
def train_model(): name_gotten3 = name_box.get() people = [f'{name_gotten3}'] DIR = r'C:/OCV/real-time-FR/pictures' haar_cascade = cv.CascadeClassifier('haar_face.xml') features = [] labels = [] def create_train(): for person in people: path = os.path.join(DIR, person) label = people.index(person) for img in os.listdir(path): img_path = os.path.join(path,img) img_array = cv.imread(img_path) gray = cv.cvtColor(img_array, cv.COLOR_BGR2GRAY) faces_rect = haar_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=12) for (x,y,w,h) in faces_rect: faces_roi = gray[y:y+h, x:x+w] features.append(faces_roi) labels.append(label) create_train() features = np.array(features, dtype='object') labels = np.array(labels) face_recognizer = cv.face.LBPHFaceRecognizer_create() # training on features and labels list face_recognizer.train(features, labels) face_recognizer.write('face-trainedreal.yml') np.save('featuresreal.npy', features) np.save('labelsreal.npy', labels) print('Done training the model') ``` ERROR: File "C:\OCV\real-time-FR\testforrealtimefd.py", line 81, in train_model face_recognizer.train(features, labels) TypeError: Expected Ptr<cv::UMat> for argument 'src'
https://stackoverflow.com/questions/67444042/typeerror-expected-ptrcvumat-for-argument-src-opencv May 08, 2021 at 12:16PM
没有评论:
发表评论