i’m trying to build face recognition in real time in neural network(facenet network) using pytorch and face detection using MTCNN i’ve tried this but doesnt work
import cv2
capture = cv2.VideoCapture(0)
while(True):
ret, frame = capture.read()
frames_tracked = []
print('\rTracking frame: {}'.format(i + 1), end='')
boxes,_ = mtcnn.detect(frame)
frame_draw = frame.copy()
draw = ImageDraw.Draw(frame_draw)
for box in boxes:
draw.rectangle(box.tolist(), outline=(255, 0, 0), width=6)
frames_tracked.append(frame_draw.resize((640, 360), Image.BILINEAR))
d = display.display(frames_tracked[0], display_id=True)
i = 1
try:
while True:
d.update(frames_tracked[i % len(frames_tracked)])
i += 1
except KeyboardInterrupt:
pass
if cv2.waitKey('q') == 27:
break
capture.release()
cv2.destroyAllWindows()
AttributeError: ‘NoneType’ object has no attribute ‘size’ thanks for any advice
if it detect a face in the first frame it will raise this error
ValueError Traceback (most recent call last)
in
13 frame_draw = frame_pil.copy()
14 draw = ImageDraw.Draw(frame_draw)
—> 15 if boxes:
16 for box in boxes:
17 draw.rectangle(box.tolist(), outline=(255, 0, 0), width=6)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
if there wasnt a face in the first frame it will raise this error
IndexError Traceback (most recent call last)
in
18 frames_tracked.append(frame_draw.resize((640, 360), Image.BILINEAR))
19 clear_output(wait=True)
—> 20 d = display.display(frames_tracked[0], display_id=True)
21 i = 1
22 try: