Esempio n. 1
0
    labels = []
    imgs = []

    # for each person grab a training set of images
    # and generate a list of labels.
    for name in names:
        myStr = "Training for : " + name
        iset = get_face_set(cam, myStr)
        imgs += iset
        labels += [name for i in range(0,len(iset))]
        time.sleep(waitTime)

    # Create, train, and save the recognizer.
    t = Trainer()
    t.labels = labels
    t.images = imgs
    f = t.do_the_train()

    # f = FaceRecognizer()
    # print f.train(imgs, labels)
    # f.save("test.csv")

    # show the results
    disp = Display((640,480))
    while disp.isNotDone():
        try:
            img = cam.getImage()
            fs = img.findHaarFeatures('face.xml')
            if fs is not None and fs != []:
                fs = fs.sortArea()
                face = fs[-1].crop().resize(100,100)