Reputation: 1
I am trying to run this using VSCode. The first script add_student.py works fine. However the second script, create_person.py gives me the following error:
> > `Traceback (most recent call last):
File "C:\xampp\htdocs\Face Recognition and RFID\create_person.py", line 13, in <module>
res = CF.person.create(personGroupId, str(sys.argv[1]))
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vkurt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\cognitive_face\person.py", line 71, in create
return util.request('POST', url, json=json)
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\vkurt\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\cognitive_face\util.py", line 103, in request
raise CognitiveFaceException(response.status_code,
cognitive_face.util.CognitiveFaceException: Error when calling Cognitive Face API:
status_code: 401
code: 401
message: Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.`
I am trying to record face_recognition, I tried other replies about this problem on other posters but can't figure how to solve. This is the code:
import sys
import cognitive_face as CF
from global_variables import personGroupId, Key, endpoint
import sqlite3
personGroupId = 'user'
CF.BaseUrl.set(endpoint)
CF.Key.set(Key)
if len(sys.argv) != 1:
res = CF.person.create(personGroupId, str(sys.argv[1]))
print(res)
extractId = str(sys.argv[1])[-2:]
connect = sqlite3.connect("Face-DataBase")
cmd = "SELECT * FROM Students WHERE ID = " + extractId
cursor = connect.execute(cmd)
isRecordExist = 0
for row in cursor:
isRecordExist = 1
if isRecordExist == 1:
connect.execute("UPDATE Students SET personID = ? WHERE ID = ?",(res['personId'], extractId))
connect.commit()
connect.close()
print("Person ID successfully added to the database")
Upvotes: 0
Views: 32