Example #1
0
def test_one_face(target):
    # prófum þetta, finnst andlit í einfaldri mynd?
    # path = '/Users/matti/Documents/forritun/andlit2/s41'
    # path = '/Volumes/MacSarpur/Downloads/colorferet/colorferet/dvd1/data/images/s/s00001'
    path = '/Users/matti/Dropbox/Skjöl/Meistaraverkefni/server/sull'
    #path = '/Users/matti/Pictures/'
    # img = cv2.imread(path + "matti.bmp")
    # target = "ég2.jpg"
    image = cv2.imread(os.path.join(path, target))
    if image is None:
        print "Gat ekki lesið mynd"
        return
    # print image.shape
    image = utils.check_size_and_resize(image)

    df = utils.FaceDetector()
    face, eyes = df.detectFace(image)
    if face is None or len(face) == 0:
        print "Fann ekkert andlit í mynd: ", target
        utils.show_image_and_wait_for_input(image)
        return

    face = face[0]
    print "f:", face, "e:", eyes
    image2 = image.copy()
    utils.draw_face(image2, face, eyes)
    utils.show_image_and_wait_for_input(image2)
    fp = utils.FaceProcessor()
    image2 = fp.process_image(image)
    assert image2 is not None, "Mynd á ekki að vera null"
    utils.show_image_and_wait_for_input(image2)
    print "done"
    return image2
Example #2
0
def check_unprocessed_image():
    image = utils.read_image(
        "/Users/matti/Documents/forritun/att_faces/10.bmp")
    fp = utils.FaceProcessor()
    image2 = fp.process_image(image)
    print "unprocessed: ",
    print_dimension(image2)
Example #3
0
def check_histogram():
    image = utils.read_image(
        "/Users/matti/Documents/forritun/att_faces/matti2.jpg")
    utils.show_image_and_wait_for_input(image)
    fp = utils.FaceProcessor()
    image2 = fp.process_image(image)
    utils.show_image_and_wait_for_input(image2)
    utils.equalize_histogram(image2)
    utils.show_image_and_wait_for_input(image2)
Example #4
0
def test_compare_images(img1_filename, img2_filename):
    fp = utils.FaceProcessor()
    img1 = fp.process_image(utils.read_image(img1_filename))
    img2 = utils.read_image(img2_filename)

    print img1
    print "---"
    print img2

    print img1.shape, ", ", img2.shape

    img3 = img1 - img2
    print img3.sum()  # allt núll, nákvæmlega eins
    img3 = img2 - img1
    print img3.sum()  # allt núll, nákvæmlega eins
Example #5
0
    # show random image
    # utils.show_image_and_wait_for_input(face_list[len(face_list)/2])

    print "Train the model"
    start = time.clock()
    # model.compute(X, y)
    model.compute(face_list, id_list)
    stop = time.clock()
    print "Training done in", stop - start, " next...find a face"

    target = "10.bmp"
    if len(sys.argv) > 3:
        target = sys.argv[3]

    fp = utils.FaceProcessor()

    while target != "quit":
        # prufu_mynd = Image.open(os.path.join(path, target))
        prufu_mynd = cv2.imread(os.path.join(path, target))
        print "Nota mynd: ", os.path.join(path, target)
        if prufu_mynd is not None:
            prufu_mynd = fp.process_image(prufu_mynd)
            if prufu_mynd is None:
                print "fann ekkert andlit!"
            else:
                start = time.clock()
                # res = model.predict(td)
                res = model.predict(prufu_mynd)
                stop = time.clock()
                print res