I am trying to make a thing that accesses photos and compares them with a photo taken by a camera.
It keeps saying PermissionError: [Errno 13] Permission denied: 'C:\\Users\\monik\\Pictures'
.
What does that mean and why is the permission denied?
The code:
#!/usr/bin/python
import base64, json, re
import http.client as httplib
from urllib import parse
# CHANGE {MS_API_KEY} BELOW WITH YOUR MICROSOFT VISION API KEY
ms_api_key = "{MS_API_KEY}"
# setup vision API
headers = {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': ms_api_key,
}
params = parse.urlencode({
'visualFeatures': 'Description',
})
# read image
body = open(r'C:\Users\monik\Pictures', "rb").read()
# submit request to API and print description if successful or error otherwise
try:
conn = HTTPSConnection('westcentralus.api.cognitive.microsoft.com')
conn.request("POST", "/vision/v1.0/analyze?%s"%params, body, headers)
response = conn.getresponse()
analysis=json.loads(response.read())
image_caption = analysis["description"]["captions"][0]["text"].capitalize()
conn.close()
print (image_caption)
except Exception as e:
print (e.args)