kinve 4 rokov pred
commit
2c6f3df05c
11 zmenil súbory, kde vykonal 123 pridanie a 0 odobranie
  1. BIN
      pic/1.jpg
  2. BIN
      pic/11.jpg
  3. BIN
      pic/12.jpg
  4. BIN
      pic/2.jpg
  5. 0 0
      pic/base64.txt
  6. BIN
      pic/ll11.jpg
  7. BIN
      pic/ll22.jpg
  8. 69 0
      recg.py
  9. 41 0
      token.py
  10. BIN
      token.pyc
  11. 13 0
      说明.txt

BIN
pic/1.jpg


BIN
pic/11.jpg


BIN
pic/12.jpg


BIN
pic/2.jpg


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 0
pic/base64.txt


BIN
pic/ll11.jpg


BIN
pic/ll22.jpg


+ 69 - 0
recg.py

@@ -0,0 +1,69 @@
+# encoding:utf-8
+import base64
+import urllib
+import urllib2, json
+from token import GetToken
+  
+'''
+人脸对比
+'''
+
+url = "https://aip.baidubce.com/rest/2.0/face/v3/match"
+
+def FaceRecg(face1, face2, token):
+    global url 
+    f = open(face1, 'rb')
+    # 参数images:图像base64编码
+    img1 = base64.b64encode(f.read())
+    # 二进制方式打开图文件
+    f = open(face2, 'rb')
+    # 参数images:图像base64编码
+    img2 = base64.b64encode(f.read())
+
+    params = json.dumps(
+        [{"image": img1, "image_type": "BASE64", "face_type": "LIVE", "quality_control": "LOW"},
+         {"image": img2, "image_type": "BASE64", "face_type": "LIVE", "quality_control": "LOW"}
+         ])
+    '''     
+    params = {"image":img1 + ',' + img2,  
+              "image_type":"BASE64",        
+              "face_type":"LIVE",           
+              "quality_control":"LOW",      
+              "liveness_control":"HIGH"}
+    params = urllib.urlencode(params)
+    '''
+
+    request_url = url + "?access_token=" + token
+    request = urllib2.Request(url=request_url, data=params)
+    request.add_header('Content-Type', 'application/json')
+    #response = urllib2.urlopen(request)
+    response = None
+    try:
+        response = urllib2.urlopen(request)
+    except urllib2.URLError,e:
+        print e.reason
+        print e.reason[0]
+        print e.reason[1]
+    if (response == None):  
+        print "response=null"
+        return None        
+    content = response.read()
+    if content:
+        print content 
+        js = json.loads(content)
+        if (js.has_key('error_msg') and js['error_msg'] == "SUCCESS"):      
+            if (js.has_key('result')):
+                #for item in js['result']:
+                print(u"%2.2f%% " % (float(js['result']['score']))) 
+                if(float(js['result']['score']) >= 80):
+                    print 'OK'
+                else:
+                    print 'FAIL'
+                
+                        
+if __name__ == "__main__":
+    #前面两个参数是图片路径
+    Token = GetToken()   
+    FaceRecg('pic/1.jpg', 'pic/2.jpg', Token)
+
+

+ 41 - 0
token.py

@@ -0,0 +1,41 @@
+# encoding:utf-8
+import urllib, urllib2, sys
+import ssl, json
+ssl._create_default_https_context = ssl._create_unverified_context
+
+AK = "fUHVCDeAmuCXPiLuur8rIc34"
+SK = "sauIRA98VaWUDqx2ejV9bS39RyXLCoSN"
+
+# token 请求 url 与图片不一样
+host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials'\
+       '&client_id=%s'\
+       '&client_secret=%s' % (AK, SK)
+
+
+def GetToken():
+    global host 
+    request = urllib2.Request(host)
+    request.add_header('Content-Type', 'application/json; charset=UTF-8')
+    #response = urllib2.urlopen(request)
+    response = None
+    try:
+        response = urllib2.urlopen(request)
+    except urllib2.URLError,e:
+        print e.reason
+        print e.reason[0]
+        print e.reason[1]
+    if (response == None):  
+        print "response=null"
+        return None
+    content = response.read()
+    if (content):
+        js = json.loads(content)
+        # return js['refresh_token']
+        if (js.has_key('access_token')):
+            return js['access_token']
+    return None
+
+if __name__ == "__main__":
+    #前面两个参数是图片路径
+    Token = GetToken()   
+    print Token

BIN
token.pyc


+ 13 - 0
说明.txt

@@ -0,0 +1,13 @@
+openwrt:
+人脸识别:
+
+1.注册  ./face.py -add  1mm  1.jpg
+2.识别 ./face.py -id  xx.jpg
+
+3.获取access_token
+#!/bin/bash
+curl -i -k 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=【百度云应用的AK】&client_secret=【百度云应用的SK】'
+
+
+语音识别:
+http://yuyin.baidu.com/ 

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov