Text Presence and Optical Character Recognition
CREATED FOR:
- User
The Text Presence/Optical Character Recognition (OCR) service, when given an image, can indicate if text is present in the image. If text is present, OCR can return the text.
The following image was used in the example request shown in this document:
API format
POST /services/v2/predict
Request
The following request checks if text is present based on the input image provided in the payload. See the table below the example payload for more information on the input parameters shown.
Execution with inline image:
curl -w'\n' -i -X POST https://sensei.adobe.io/services/v2/predict \
-H 'Prefer: respond-async, wait=59' \
-H "x-api-key: $API_KEY" \
-H "content-type: multipart/form-data" \
-H "authorization: Bearer $API_TOKEN" \
-F file=@sample_image.png \
-F 'contentAnalyzerRequests={
"sensei:name": "Feature:cintel-object-detection:Service-b9ace8b348b6433e9e7d82371aa16690",
"sensei:invocation_mode": "asynchronous",
"sensei:invocation_batch": false,
"sensei:engines": [
{
"sensei:execution_info": {
"sensei:engine": "Feature:cintel-object-detection:Service-b9ace8b348b6433e9e7d82371aa16690"
},
"sensei:inputs": {
"documents": [
{
"sensei:multipart_field_name": "file",
"dc:format": "image/jpg"
}
]
},
"sensei:params": {
"correct_with_dictionary": true,
"min_probability": 0.2,
"min_relevance": 0.01,
"filter_with_dictionary": true
},
"sensei:outputs":{
"result" : {
"sensei:multipart_field_name" : "result",
"dc:format": "application/json"
}
}
}
]
}'
Response
A successful response returns the text that was detected in the tags
list for each image that was passed in the request. If there is no text in a certain image, is_text_present
is 0 and tags
is an empty list.
[result0, result1, …]: list of responses for each input document. Each result is a dict with keys:
- request_element_id: corresponding index to the input file for this response, 0 for the first image in the request’s documents list, 1 for the next one, and so on.
- tags: list of dictionaries, each dictionary has two keys : text, which is a recognized word from the image, and relevance, which is computed as the fraction of the area of the extracted text’s bounding box in comparison to the full image. 0.01 would translate to a text occupying at least 1% of the image.
- is_text_present: 0 or 1 depending on if text is present in the image. If tags is 0, the list is empty.
{
"contentAnalyzerResponse": {
"statuses": [
{
"sensei:engine": "Feature:cintel-object-detection:Service-b9ace8b348b6433e9e7d82371aa16690",
"invocations": [
{
"sensei:outputs": {
"result": {
"sensei:multipart_field_name": "result",
"dc:format": "application/json"
}
},
"message": null,
"status": "200"
}
]
}
],
"request_id": "dttklFR7DPtMtEmjlRSx5BYP5WGg3tTx"
},
"result": [
{
"is_text_present": 1,
"tags": [
{
"text": "yosemite",
"relevance": 0.06
}
],
"request_element_id": 0
}
]
}
Request
The following request checks if text is present based on the input image provided in the payload. See the table below the example payload for more information on the input parameters shown.
Execution with URL:
curl -w'\n' -i -X POST https://sensei.adobe.io/services/v2/predict \
-H 'Prefer: respond-async, wait=59' \
-H "x-api-key: $API_KEY" \
-H "content-type: multipart/form-data" \
-H "authorization: Bearer $API_TOKEN" \
-F 'contentAnalyzerRequests={
"sensei:name": "Feature:cintel-object-detection:Service-b9ace8b348b6433e9e7d82371aa16690",
"sensei:invocation_mode": "asynchronous",
"sensei:invocation_batch": false,
"sensei:engines": [
{
"sensei:execution_info": {
"sensei:engine": "Feature:cintel-object-detection:Service-b9ace8b348b6433e9e7d82371aa16690"
},
"sensei:inputs": {
"documents": [
{
"repo:path": <IMG_URL_PATH>,
"sensei:repoType": "HTTP",
"dc:format": "image/jpg"
}
]
},
"sensei:params": {
"correct_with_dictionary": true
},
"sensei:outputs":{
"result" : {
"sensei:multipart_field_name" : "result",
"dc:format": "application/json"
}
}
}
]
}'
{
"contentAnalyzerResponse": {
"statuses": [
{
"sensei:engine": "Feature:cintel-object-detection:Service-b9ace8b348b6433e9e7d82371aa16690",
"invocations": [
{
"sensei:outputs": {
"result": {
"sensei:multipart_field_name": "result",
"dc:format": "application/json"
}
},
"message": null,
"status": "200"
}
]
}
],
"request_id": "ZbdhcK0JqS4Wg1wGdlEHGR3JOm530YNn"
},
"result": [
{
"is_text_present": 0,
"tags": [],
"request_element_id": 0
}
]
}
documents
sensei:multipart_field_name
repo:path
sensei:repoType
dc:format
correct_with_dictionary
filter_with_dictionary
min_probability
min_relevance
repo:path
sensei:repoType
sensei:multipart_field_name
dc:format
“image/jpeg”,
“image/png”,
“image/tiff”