I inserted the code into visual studio and changed:
if name == ‘cascade.xml’:
main()
It run without errors
I placed the cascade.xml in the root of the camera
and run
# Face Recognition
import sensor, image, time, tf
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
net = tf.load("trained.tflite", load_to_fb=True) [b][color=#FF0000]# why is this code used[/color][/b]
labels = [l.rstrip('\n') for l in open("labels.txt")]
while(True):
clock.tick()
# Take a picture and brighten things up for the frontal face detector.
img = sensor.snapshot().gamma_corr(contrast=1.5)
# Returns a list of rects (x, y, w, h) where faces are.
faces = img.find_features(image.HaarCascade("cascade.xml"))
for f in faces:
# Classify a face and get the class scores list
scores = net.classify(img, roi=f)[0].output()
# Find the highest class score and lookup the label for that
label = labels[scores.index(max(scores))]
# Draw a box around the face
img.draw_rectangle(f)
# Draw the label above the face
img.draw_string(f[0]+3, f[1]-1, label, mono_space=False)
print(clock.fps())
it still say there is not enough memory.