-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.py
More file actions
42 lines (33 loc) · 980 Bytes
/
search.py
File metadata and controls
42 lines (33 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
* Client side code for Face Searching API.
* Call this after adding images to the database.
"""
import requests
import cv2
token = "YOUR_API_KEY"
secret = "YOUR_SECRET_KEY"
folderKey = "default"
distance = 0.5 # Change this value as explained in the Doc.
imageName = "dd.jpg"
img = open(imageName,'rb')
g_url = 'http://api.giscle.ml'
auth = {
'secretKey':secret,
'apiKey':token,
'folderKey':folderKey,
'distance':distance
}
r = requests.post("{}/{}".format(g_url,'face_search'),data=auth, files={'img1':img})
if r.ok:
result = r.json()
print(result)
if result['label'] == 1:
image = cv2.imread(imageName)
for person in result['result']:
t,r,b,l = person['face']
cv2.rectangle(image,(l,t),(r,b),(255,255,255))
cv2.putText(image,person['person'],(l,t-13),cv2.FONT_HERSHEY_SIMPLEX,1,(255,255,255))
cv2.imshow('Image',image)
cv2.waitKey(0)
else:
print(r.status_code)