I am currently messing around with the Kairos API and am trying to use Pythonista to take a new photo on my iPad and then upload that photo to the Kairos enroll API. I am able to get this to work fine with a URL image but for the life of me I am unable to get this to work by taking a photo with the photos module. From my understanding the photos module returns a PIL Image and I think I need to base64 encode that before uploading to the Kairos API??
Here is my code without using the photos module:
#import photos
import requests
#img = photos.capture_image()
url = "https://api.kairos.com/enroll"
values = """
{
"image": "https://images.pexels.com/photos/614810/pexels-photo-614810.jpeg?cs=srgb&dl=face-facial-hair-fine-looking-614810.jpg&fm=jpg",
"subject_id": "test",
"gallery_name": "test"
}
"""
headers = {
'Content-Type': 'application/json',
'app_id': '********',
'app_key': '************************'
}
request = requests.post(url, data=values, headers=headers)
response = request.content
print(response)
Im hoping that someone can help me out by showing me what I need to do to be able to accomplish this task. Any help is greatly appreciated.
Thank you in advance,
Colin
I was able to get this to work by converting the PIL Image with BytesIO and then encoding with base64:
Hopefully this helps some in the future.