@@ -49,8 +49,6 @@ class AipFace(AipBase):
49
49
50
50
__personVerifyUrl = 'https://aip.baidubce.com/rest/2.0/face/v3/person/verify'
51
51
52
- __faceverifyUrl = 'https://aip.baidubce.com/rest/2.0/face/v3/faceverify'
53
-
54
52
__videoSessioncodeUrl = 'https://aip.baidubce.com/rest/2.0/face/v1/faceliveness/sessioncode'
55
53
56
54
__videoFacelivenessUrl = 'https://aip.baidubce.com/rest/2.0/face/v1/faceliveness/verify'
@@ -67,10 +65,11 @@ def detect(self, image, image_type, options=None):
67
65
data ['image_type' ] = image_type
68
66
69
67
data .update (options )
70
-
71
- return self ._request (self .__detectUrl , data )
68
+ return self ._request (self .__detectUrl , json .dumps (data , ensure_ascii = False ), {
69
+ 'Content-Type' : 'application/json' ,
70
+ })
72
71
73
- def search (self , image , image_type , options = None ):
72
+ def search (self , image , image_type , group_id_list , options = None ):
74
73
"""
75
74
人脸搜索
76
75
"""
@@ -79,10 +78,12 @@ def search(self, image, image_type, options=None):
79
78
data = {}
80
79
data ['image' ] = image
81
80
data ['image_type' ] = image_type
81
+ data ['group_id_list' ] = group_id_list
82
82
83
83
data .update (options )
84
-
85
- return self ._request (self .__searchUrl , data )
84
+ return self ._request (self .__searchUrl , json .dumps (data , ensure_ascii = False ), {
85
+ 'Content-Type' : 'application/json' ,
86
+ })
86
87
87
88
def addUser (self , image , image_type , group_id , user_id , options = None ):
88
89
"""
@@ -97,8 +98,9 @@ def addUser(self, image, image_type, group_id, user_id, options=None):
97
98
data ['user_id' ] = user_id
98
99
99
100
data .update (options )
100
-
101
- return self ._request (self .__userAddUrl , data )
101
+ return self ._request (self .__userAddUrl , json .dumps (data , ensure_ascii = False ), {
102
+ 'Content-Type' : 'application/json' ,
103
+ })
102
104
103
105
def updateUser (self , image , image_type , group_id , user_id , options = None ):
104
106
"""
@@ -113,8 +115,9 @@ def updateUser(self, image, image_type, group_id, user_id, options=None):
113
115
data ['user_id' ] = user_id
114
116
115
117
data .update (options )
116
-
117
- return self ._request (self .__userUpdateUrl , data )
118
+ return self ._request (self .__userUpdateUrl , json .dumps (data , ensure_ascii = False ), {
119
+ 'Content-Type' : 'application/json' ,
120
+ })
118
121
119
122
def faceDelete (self , user_id , group_id , face_token , options = None ):
120
123
"""
@@ -128,8 +131,9 @@ def faceDelete(self, user_id, group_id, face_token, options=None):
128
131
data ['face_token' ] = face_token
129
132
130
133
data .update (options )
131
-
132
- return self ._request (self .__faceDeleteUrl , data )
134
+ return self ._request (self .__faceDeleteUrl , json .dumps (data , ensure_ascii = False ), {
135
+ 'Content-Type' : 'application/json' ,
136
+ })
133
137
134
138
def getUser (self , user_id , group_id , options = None ):
135
139
"""
@@ -142,8 +146,9 @@ def getUser(self, user_id, group_id, options=None):
142
146
data ['group_id' ] = group_id
143
147
144
148
data .update (options )
145
-
146
- return self ._request (self .__userGetUrl , data )
149
+ return self ._request (self .__userGetUrl , json .dumps (data , ensure_ascii = False ), {
150
+ 'Content-Type' : 'application/json' ,
151
+ })
147
152
148
153
def faceGetlist (self , user_id , group_id , options = None ):
149
154
"""
@@ -156,8 +161,9 @@ def faceGetlist(self, user_id, group_id, options=None):
156
161
data ['group_id' ] = group_id
157
162
158
163
data .update (options )
159
-
160
- return self ._request (self .__faceGetlistUrl , data )
164
+ return self ._request (self .__faceGetlistUrl , json .dumps (data , ensure_ascii = False ), {
165
+ 'Content-Type' : 'application/json' ,
166
+ })
161
167
162
168
def getGroupUsers (self , group_id , options = None ):
163
169
"""
@@ -169,8 +175,9 @@ def getGroupUsers(self, group_id, options=None):
169
175
data ['group_id' ] = group_id
170
176
171
177
data .update (options )
172
-
173
- return self ._request (self .__groupGetusersUrl , data )
178
+ return self ._request (self .__groupGetusersUrl , json .dumps (data , ensure_ascii = False ), {
179
+ 'Content-Type' : 'application/json' ,
180
+ })
174
181
175
182
def userCopy (self , user_id , options = None ):
176
183
"""
@@ -182,8 +189,9 @@ def userCopy(self, user_id, options=None):
182
189
data ['user_id' ] = user_id
183
190
184
191
data .update (options )
185
-
186
- return self ._request (self .__userCopyUrl , data )
192
+ return self ._request (self .__userCopyUrl , json .dumps (data , ensure_ascii = False ), {
193
+ 'Content-Type' : 'application/json' ,
194
+ })
187
195
188
196
def deleteUser (self , group_id , user_id , options = None ):
189
197
"""
@@ -196,8 +204,9 @@ def deleteUser(self, group_id, user_id, options=None):
196
204
data ['user_id' ] = user_id
197
205
198
206
data .update (options )
199
-
200
- return self ._request (self .__userDeleteUrl , data )
207
+ return self ._request (self .__userDeleteUrl , json .dumps (data , ensure_ascii = False ), {
208
+ 'Content-Type' : 'application/json' ,
209
+ })
201
210
202
211
def groupAdd (self , group_id , options = None ):
203
212
"""
@@ -209,8 +218,9 @@ def groupAdd(self, group_id, options=None):
209
218
data ['group_id' ] = group_id
210
219
211
220
data .update (options )
212
-
213
- return self ._request (self .__groupAddUrl , data )
221
+ return self ._request (self .__groupAddUrl , json .dumps (data , ensure_ascii = False ), {
222
+ 'Content-Type' : 'application/json' ,
223
+ })
214
224
215
225
def groupDelete (self , group_id , options = None ):
216
226
"""
@@ -222,8 +232,9 @@ def groupDelete(self, group_id, options=None):
222
232
data ['group_id' ] = group_id
223
233
224
234
data .update (options )
225
-
226
- return self ._request (self .__groupDeleteUrl , data )
235
+ return self ._request (self .__groupDeleteUrl , json .dumps (data , ensure_ascii = False ), {
236
+ 'Content-Type' : 'application/json' ,
237
+ })
227
238
228
239
def getGroupList (self , options = None ):
229
240
"""
@@ -234,8 +245,9 @@ def getGroupList(self, options=None):
234
245
data = {}
235
246
236
247
data .update (options )
237
-
238
- return self ._request (self .__groupGetlistUrl , data )
248
+ return self ._request (self .__groupGetlistUrl , json .dumps (data , ensure_ascii = False ), {
249
+ 'Content-Type' : 'application/json' ,
250
+ })
239
251
240
252
def personVerify (self , image , image_type , id_card_number , name , options = None ):
241
253
"""
@@ -250,22 +262,9 @@ def personVerify(self, image, image_type, id_card_number, name, options=None):
250
262
data ['name' ] = name
251
263
252
264
data .update (options )
253
-
254
- return self ._request (self .__personVerifyUrl , data )
255
-
256
- def faceverify (self , image , image_type , options = None ):
257
- """
258
- 在线活体检测
259
- """
260
- options = options or {}
261
-
262
- data = {}
263
- data ['image' ] = image
264
- data ['image_type' ] = image_type
265
-
266
- data .update (options )
267
-
268
- return self ._request (self .__faceverifyUrl , data )
265
+ return self ._request (self .__personVerifyUrl , json .dumps (data , ensure_ascii = False ), {
266
+ 'Content-Type' : 'application/json' ,
267
+ })
269
268
270
269
def videoSessioncode (self , options = None ):
271
270
"""
@@ -276,8 +275,9 @@ def videoSessioncode(self, options=None):
276
275
data = {}
277
276
278
277
data .update (options )
279
-
280
- return self ._request (self .__videoSessioncodeUrl , data )
278
+ return self ._request (self .__videoSessioncodeUrl , json .dumps (data , ensure_ascii = False ), {
279
+ 'Content-Type' : 'application/json' ,
280
+ })
281
281
282
282
def videoFaceliveness (self , session_id , video_base64 , options = None ):
283
283
"""
@@ -290,17 +290,29 @@ def videoFaceliveness(self, session_id, video_base64, options=None):
290
290
data ['video_base64' ] = video_base64
291
291
292
292
data .update (options )
293
-
294
- return self ._request (self .__videoFacelivenessUrl , data )
293
+ return self ._request (self .__videoFacelivenessUrl , json .dumps (data , ensure_ascii = False ), {
294
+ 'Content-Type' : 'application/json' ,
295
+ })
295
296
296
297
298
+ __faceverifyUrl = 'https://aip.baidubce.com/rest/2.0/face/v3/faceverify'
299
+
300
+ def faceverify (self , images ):
301
+ """
302
+ 在线活体检测
303
+ """
304
+
305
+ return self ._request (self .__faceverifyUrl , json .dumps (images , ensure_ascii = False ), {
306
+ 'Content-Type' : 'application/json' ,
307
+ })
308
+
297
309
__matchUrl = 'https://aip.baidubce.com/rest/2.0/face/v3/match'
298
310
299
311
def match (self , images ):
300
312
"""
301
313
人脸比对
302
314
"""
303
315
304
- return self ._request (self .__matchUrl , json .dumps (images ), {
316
+ return self ._request (self .__matchUrl , json .dumps (images , ensure_ascii = False ), {
305
317
'Content-Type' : 'application/json' ,
306
318
})
0 commit comments