-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_person.py
84 lines (78 loc) · 2.77 KB
/
create_person.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import sqlite3
import asyncio
import io
import glob
import os
import asyncio
import io
import glob
import os
import sys
import time
import json
import uuid
import http
import http.client
import urllib.request
import urllib.parse
import urllib.error
import base64
import requests
from urllib.parse import urlparse
from io import BytesIO
from PIL import Image, ImageDraw
from azure.cognitiveservices.vision.face import FaceClient
from msrest.authentication import CognitiveServicesCredentials
from azure.cognitiveservices.vision.face.models import TrainingStatusType, Person, SnapshotObjectType, OperationStatusType
from global_variables import personGroupId
import sys
import time
import uuid
import requests
from urllib.parse import urlparse
from io import BytesIO
from PIL import Image, ImageDraw
from azure.cognitiveservices.vision.face import FaceClient
from msrest.authentication import CognitiveServicesCredentials
from azure.cognitiveservices.vision.face.models import TrainingStatusType, Person, SnapshotObjectType, OperationStatusType
from global_variables import personGroupId
# KEY = '2cfe4243d20342c2b49aeda55a4647f8'
# ENDPOINT = 'https://faceapi0811.cognitiveservices.azure.com/' # Replace with your regional Base URL
# face_client = FaceClient(ENDPOINT, CognitiveServicesCredentials(KEY))
if len(sys.argv) is not 1:
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '2698a28d0b3a47be9a0177011b4fca38',
}
body = {}
body['name'] = 'Person1'
params = urllib.parse.urlencode({
})
conn = http.client.HTTPSConnection(
'southeastasia.api.cognitive.microsoft.com')
# conn.request("POST", "/face/v1.0/persongroups/test1/persons?%s" % params, payload, headers)
conn.request("POST", "/face/v1.0/persongroups/test2/persons",
json.dumps(body), headers)
response = conn.getresponse()
resp = response.read()
res = json.loads(resp)
print(res)
extractId = str(sys.argv[1])[-2:]
publickey = input('Enter the public key')
privatekey = input('Enter the private key')
# print(res['personId'])
connect = sqlite3.connect("Face-DataBase")
cmd = "SELECT * FROM Students WHERE ID = " + extractId
cursor = connect.execute(cmd)
isRecordExist = 0
# checking wheather the id exist or not
for row in cursor:
isRecordExist = 1
if isRecordExist == 1: # updating name and roll no
connect.execute("UPDATE Students SET personID = ?, Publickey = ?, Privatekey = ? WHERE ID = ?",
(res['personId'], publickey, privatekey, extractId))
# commiting into the database
connect.commit()
connect.close()
print("Person ID successfully added to the database")