def __init__(self, api_key, api_secret, group_name='anti ice cream'): self.api = facepp.API(api_key, api_secret) self.group_name = group_name self._snap = ctypes.cdll.LoadLibrary('snap.so') self._snap.init() logging.basicConfig(format='%(asctime)-15s %(message)s', level=logging.NOTSET)
def add_faceset(request): if request.method == 'POST': image_base64 = request.POST.get('dataUrl')[22:] outer_id = request.session['account'] #upload image(image_base64) to facepp api = facepp.API(key='FR2qXQzfPwSzjZNC1KSdQBiJD8h_sVIx', secret='0M7jG1b4nxdp6eBH8nnirkcefUWD91C-') api.faceset.create(outer_id=outer_id) res = api.detect(image_base64=image_base64) api.faceset.addface(outer_id=outer_id, face_tokens=res["faces"][0]["face_token"]) #设置session @2017-8-19 00:14:28目前设置的这个session好像并没有用 request.session['has_faceset'] = True #下面这个其实并没有发挥作用,可能是什么异步的原因,log显示这条虽然执行了,但是页面当时并没有跳转 return HttpResponseRedirect(reverse('faceunlock:index')) return render(request, 'faceunlock/add_faceset.html')
def getShape(landmarks): return [(landmarks[key]['x'], landmarks[key]['y']) for key in landmarks if re.match("contour", key)] ############################################################# # Main execution ############################################################# prediction_service = build('prediction', 'v1.6', developerKey=DEV_KEY) prediction_service.hostedmodels() facepp_api = facepp.API(API_KEY, API_SECRET, srv=API_SERVER) face = facepp_api.detection.detect(img=facepp.File(IMAGE_PATH)) landmark = facepp_api.detection.landmark(face_id=face['face'][0]['face_id'], type='83p') window = pyglet.window.Window() vertex_list_eyes = pyglet.graphics.vertex_list( len(getEyes(landmark["result"][0]["landmark"])), ('v2f', [ value for point in getEyes(landmark["result"][0]["landmark"]) for value in point ])) vertex_list_nose = pyglet.graphics.vertex_list( len(getNose(landmark["result"][0]["landmark"])), ('v2f', [ value for point in getNose(landmark["result"][0]["landmark"])
def __init__(self, group_name): self.api = facepp.API(key=API_KEY, secret=API_SECRET, timeout=3000) self.group_name = group_name