The service processes input image and responds with bounding boxes of detected objects, their classes and confidence.
Bounding boxes define location of objects in normalized coordinates (0.0
– left/top, 1.0
– right/bottom) in the following notations: [x, y, width, height]
.
METHOD | URL | DESCRIPTION |
---|---|---|
GET | https://brand-recognition.p.rapidapi.com/v1/version |
Get service version. |
POST | https://brand-recognition.p.rapidapi.com/v1/results |
Perform image analysis and get results. |
Returns an actual version of the service in format vX.Y.Z
where X is the version of API.
PROPERTY | DESCRIPTION |
---|---|
Endpoint | https://brand-recognition.p.rapidapi.com/v1/version |
Method | GET |
Query parameters | – |
POST parameters | – |
Examples
Request:
$ curl -X 'GET' 'https://brand-recognition.p.rapidapi.com/v1/version'
Response:
v1.5.0
Performs actual image analysis and responds with results.
PROPERTY | DESCRIPTION |
---|---|
Endpoint | https://brand-recognition.p.rapidapi.com/v1/results |
Method | POST |
Query parameters | threshold |
POST parameters | image , url |
Query parameter threshold
is optional and may be used to filter detections depending on the confidence.
For example, if threshold
is 0.1
(default), results will contain only detections with the confidence more than 0.1
.
Response schema
For responses with 200
HTTP code the type of response is JSON object with the following schema:
{
"results": [
{
"status": {
"code": ...,
"message": ...
},
"name": ...,
"md5": ...,
"page": ...,
"width": ...,
"height": ...,
"entities": [
{
"kind": "classes",
"name": "logo-detector",
"objects": [
{
"box": ...,
"entities": [
{
"kind": "classes",
"name": "classes",
"classes": {
...
}
}
]
}
]
}
]
}
]
}
Primary fields:
Name | Type | Description |
---|---|---|
results[].status.code |
string |
Status code of image processing: ok or failure . |
results[].status.message |
string |
Human readable explanation for status of image processing. |
results[].name |
string |
Original image name passed in request (e.g. my_image.jpg ). |
results[].md5 |
string |
MD5 sum of original image passed in request. |
results[].page |
int |
Optinal page number (presented for multipage inputs only). |
results[].width |
int |
Optinal image width (presented for valid inputs only). |
results[].height |
int |
Optinal image height (presented for valid inputs only). |
results[].entities[].objects |
array |
Array of detected object. |
results[].entities[].objects[].box |
array |
Object’s bounding box defined by 4 float values. |
results[].entities[].objects[].entities[].classes |
object |
Object’s classes and confidence of recognition. |
Some details:
0.0
– left/top, 1.0
– right/bottom) in the following notations: [x, y, width, height]
.0.0
to 1.0
).Other fields that are not described above always have the same values.
Passing image
Image can be passed by posting regular “multipart form data” in two alternative ways:
image
fieldurl
fieldImage must be a regular JPEG or PNG image (with or without transparency) or PDF file.
Usually such images have extensions: .jpg
, .jpeg
, .png
, .pdf
. In case of PDF
each page will be converted to PNG image and processed separately.
The service checks input file by MIME type and accepts the following types:
image/jpeg
image/png
application/pdf
The size of image file must be less than 16Mb
.
Examples
Request:
curl -X 'POST' 'https://brand-recognition.p.rapidapi.com/v1/results' -F 'image=@image.jpg'
Response:
{
"results": [
{
"status": {
"code": "ok",
"message": "Success"
},
"name": "image.jpg",
"md5": "a447c0aa2b2b89aa6ffb488317c0ab1e",
"width": 1024,
"height": 768,
"entities": [
{
"kind": "objects",
"name": "logo-detector",
"objects": [
{
"box": [
0.5650924444198608,
0.1460374891757965,
0.15659332275390625,
0.1803402304649353
],
"entities": [
{
"kind": "classes",
"name": "classes",
"classes": {
"McDonalds": 0.3759486973285675
}
}
]
}
]
}
]
}
]
}
When client sends an image that can not be processed for some reason(s), the service responds with 200
code and returns JSON object in the same format as the format for successful analysis. In this case, the results[].status.code
will have failure
value and results[].status.message
will contain relevant explanation.
Example of possible reasons for the issue:
Example response for corrupted image:
{
"results": [
{
"status": {
"code": "failure",
"message": "Can not load image."
},
"name": "file.jpg",
"md5": "d41d8cd98f00b204e9800998ecf8427e",
"entities": []
}
]
}
Request size is limited by approximately 32Mb
.
When client sends request that exceeds this limit, the service responds with 413
code.
The typical reason for exceeding this limit is overly large image.
Taking into account additional HTTP overhead, we strongly recommend to not pass image files of size more than 16Mb
.
Example response for too big request:
Error: Request Entity Too Large
Your client issued a request that was too large.
When client sends a request without an image and url, the service responds with 422
code and returns JSON object.
Example response for request without image or url:
{"detail": "Missing image or url field."}