Ejemplo n.º 1
0
def signup():
    if request.method == 'POST':
        name = request.form['name']
        tel = request.form['tel']
        face = request.files['face']
        user = User.query.filter_by(tel = tel).first()
        if(user):
            return "-2" # already exists
        result = engine.execute("select idcode from users order by idcode desc")
        idcode = result.fetchone()
        if(idcode == None):
            _id = 0
        else:
            _id = idcode['idcode'] + 1
        result.close()
        
        pn = os.path.join(app.config['FACE_FOLDER'], str(_id) + ".jpg")
        face.save(pn)
        ha = HairAnalyzer.HairAnalyzer(pn)
        img = ha.getImage()
        print(img.shape)
        face, eyes = ha.detectFace()
        if (len(eyes)<2):
            os.remove(pn)
            return "-3"

        area = ha.getHairArea(face)
        face_color=ha.getFaceColor(face,eyes)
        for i in range(img.shape[0]):
            for j in range(img.shape[1]):
                if area[i][j] == 1:
                    img[i][j]=face_color
        cv2.imwrite(os.path.join(app.config['FACE_FOLDER'], str(_id) + '_face.jpg'), img)

        facedata = img_face(_id, str(_id) +"_face.jpg")
        user = User(name,_id,tel)
        db_session.add(user)
        db_session.add(facedata)
        db_session.commit() 
        CF.add_user(str(_id), [], [])
        CF.show_DB()
        return str(_id)
    else:
        return "-1"
Ejemplo n.º 2
0
import Make_DB
import CF
import Main

Make_DB.make_DB()
L = [1,4,5,6,14,17,19,22,23,24,28,35,36,40,43,46,48,50,51,56,57,58,60,61,62,63,64,68,69,70,74,75,77,78,80,83,84,85]

for i in L:
    d = Main.check_hair_front("imgs_rec/" + "t" + str(i) +".jpg")
    print d
    CF.add_item("t"+ str(i) + ".jpg", d)

CF.show_DB()