Demo entry 6344542

py

   

Submitted by anonymous on Jan 14, 2017 at 09:38
Language: Python. Code size: 1.1 kB.

# -*- coding: utf-8 -*-
import cv2, numpy, time

from Lib.facepp import *
from Lib.cv2fn import take_picture

def login():
    while True:
        existPersonName = [person['person_name'] for person in get_person_list()]
        print('Here is the list of account:\n' +
            '\n'.join(['* ' + personName for personName in existPersonName]) + '\nEnd of List')
        account = raw_input('Account: ')
        if not account in existPersonName:
            print('账户不存在,请检查输入或者创建新账户。')
        else:
            if login_as(account):
                print('脸部检测通过,登录成功!')
                return True
            else:
                print('脸部检测未通过,登录失败!')
                return False

def login_as(name, timeout = 20):
    personId = get_person_id(name)
    if not os.path.exists('tmp'): os.mkdir('tmp')

    faceCascade = cv2.CascadeClassifier(os.path.join('Lib', 'haarcascade_frontalface_default.xml'))
    capInput = cv2.VideoCapture(0)
    if not capInput.isOpened(): print('Capture failed because of camera')
    endCaptureTime = time.time() + timeout
    success = False

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).