This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 635
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
a error "Image is too small" occurs when detect face #104
Copy link
Copy link
Open
Description
OK, there is a error "Image is too small" occurs when I try to detect face in image to upload
Here are results returned by API:
{
u'error':
{
u'message': u'Image size is too small.',
u'code': u'InvalidImageSize'
}
}
Actually, all width and height of these images are more than 640px.
These images can be handled when I upload them into your website, so I am so confused about this result. I write Python script as following:
#!/usr/bin/python
#-*- coding: utf-8 -*-
import json
import requests
class FaceAPI:
def __init__(self,secretKey):
self.baseUrl = 'https://westcentralus.api.cognitive.microsoft.com'
self.secretKey = secretKey
def detectFace(self,image):
# Request headers.
headers = {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': self.secretKey,
}
# Request parameters.
params = {
'returnFaceId': 'true',
'returnFaceLandmarks': 'false',
'returnFaceAttributes': 'age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise',
}
# Body. The URL of a JPEG image to analyze.
imgData = open(image).read()
# Call REST API
try:
response = requests.post(
self.baseUrl + '/face/v1.0/detect',
json = None,
data = imgData,
headers = headers,
params = params
)
if(response.status_code == '200'):
data = json.loads(response.text)
return (True,data)
else:
data = json.loads(response.text)
return (False,data)
except Exception as e:
return (False, e.message)
So can you help me to resolve this issue? Thanks you.
Metadata
Metadata
Assignees
Labels
No labels