Фото еталон в 128Х128 и фото с камеры тоже делаю в 128Х128
for i in range(128): for j in range(128): if roi_gray[i][j]==etalon[i][j]: sgodztvo+=1 print(sgodztvo)
Traceback (most recent call last):
File “C:\Users\Genya\Desktop\INTRESTING\FacialRecognitionProject\TEST\15.10.18\Lico_default.py”, line 30, in <module>
if roi_gray==etalon:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Ну я если надо вот фулл код
import numpy as np import cv2 import time cap = cv2.VideoCapture(0) cap.set(3,640) # set Width cap.set(4,480) # set Height etalon = cv2.imread('./Evgeniy/etalot.png') faceCascade = cv2.CascadeClassifier('lico.xml') while True: ret, img = cap.read() gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = faceCascade.detectMultiScale( gray, scaleFactor=1.2, minNeighbors=5, minSize=(30, 30) ) for (x,y,w,h) in faces: sgodztvo = 0 roi_color = img[y:y+h, x:x+w] roi_gray = gray[y:y+h, x:x+w] roi_gray = cv2.resize(roi_gray,(128,128)) #cv2.imwrite("Evgeniy/etalot.png",roi_gray) cv2.imshow("cut",roi_gray) cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) #roi_gray = gray[y:y+h, x:x+w] for i in range(128): for j in range(128): if roi_gray[i][j]==etalon[i][j]: sgodztvo+=1 print(sgodztvo) cv2.imshow('video',img) k = cv2.waitKey(30) & 0xff if k == 27: # press 'ESC' to quit break cap.release() cv2.destroyAllWindows()