-
Notifications
You must be signed in to change notification settings - Fork 5.1k
/
Ocr.json
500 lines (500 loc) · 15.3 KB
/
Ocr.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
{
"swagger": "2.0",
"info": {
"version": "3.1-preview.2",
"title": "Computer Vision Client",
"description": "The Computer Vision API provides state-of-the-art algorithms to process images and return information. For example, it can be used to determine if an image contains mature content, or it can be used to find all the faces in an image. It also has other features like estimating dominant and accent colors, categorizing the content of images, and describing an image with complete English sentences. Additionally, it can also intelligently generate images thumbnails for displaying large images effectively."
},
"securityDefinitions": {
"apim_key": {
"type": "apiKey",
"name": "Ocp-Apim-Subscription-Key",
"in": "header"
}
},
"security": [
{
"apim_key": []
}
],
"x-ms-parameterized-host": {
"hostTemplate": "{Endpoint}",
"useSchemePrefix": false,
"parameters": [
{
"$ref": "#/parameters/Endpoint"
}
]
},
"host": "westcentralus.api.cognitive.microsoft.com",
"basePath": "/vision/v3.1-preview.2",
"schemes": [
"https"
],
"paths": {
"/read/analyze": {
"post": {
"description": "Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.",
"operationId": "Read",
"parameters": [
{
"$ref": "#/parameters/OcrDetectionLanguage"
},
{
"$ref": "#/parameters/ImageUrl"
},
{
"$ref": "#/parameters/Pages"
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"responses": {
"202": {
"description": "The service has accepted the request and will start processing later.",
"headers": {
"Operation-Location": {
"description": "URL to query for status of the operation. The operation ID will expire in 48 hours. ",
"type": "string"
}
}
},
"default": {
"description": "Error response.",
"schema": {
"$ref": "#/definitions/ComputerVisionError"
}
}
},
"x-ms-examples": {
"Successful Analyze request": {
"$ref": "./examples/SuccessfulReadWithUrl.json"
}
}
}
},
"/read/analyzeResults/{operationId}": {
"get": {
"description": "This interface is used for getting OCR results of Read operation. The URL to this interface should be retrieved from 'Operation-Location' field returned from Read interface.",
"operationId": "GetReadResult",
"parameters": [
{
"name": "operationId",
"in": "path",
"description": "Id of read operation returned in the response of the 'Read' interface.",
"required": true,
"type": "string",
"format": "uuid"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "Returns the read operation status.",
"schema": {
"$ref": "#/definitions/ReadOperationResult"
}
},
"default": {
"description": "Error response.",
"schema": {
"$ref": "#/definitions/ComputerVisionError"
}
}
},
"x-ms-examples": {
"Successful Get Read Result request": {
"$ref": "./examples/SuccessfulGetReadResult.json"
}
}
}
}
},
"x-ms-paths": {
"/read/analyze?overload=stream": {
"post": {
"description": "Use this interface to get the result of a Read operation, employing the state-of-the-art Optical Character Recognition (OCR) algorithms optimized for text-heavy documents. When you use the Read interface, the response contains a field called 'Operation-Location'. The 'Operation-Location' field contains the URL that you must use for your 'GetReadResult' operation to access OCR results.",
"operationId": "ReadInStream",
"parameters": [
{
"$ref": "#/parameters/OcrDetectionLanguage"
},
{
"$ref": "#/parameters/ImageStream"
},
{
"$ref": "#/parameters/Pages"
}
],
"consumes": [
"application/octet-stream"
],
"produces": [
"application/json"
],
"responses": {
"202": {
"description": "The service has accepted the request and will start processing later.",
"headers": {
"Operation-Location": {
"description": "URL to query for status of the operation. The operation ID will expire in 48 hours. ",
"type": "string"
}
}
},
"default": {
"description": "Error response.",
"schema": {
"$ref": "#/definitions/ComputerVisionError"
}
}
},
"x-ms-examples": {
"Successful Analyze request": {
"$ref": "./examples/SuccessfulReadWithStream.json"
}
}
}
}
},
"definitions": {
"ReadOperationResult": {
"type": "object",
"description": "OCR result of the read operation.",
"properties": {
"status": {
"description": "Status of the read operation.",
"$ref": "#/definitions/OperationStatus"
},
"createdDateTime": {
"type": "string",
"description": "Get UTC date time the batch operation was submitted.",
"x-nullable": false
},
"lastUpdatedDateTime": {
"type": "string",
"description": "Get last updated UTC date time of this batch operation.",
"x-nullable": false
},
"analyzeResult": {
"description": "Analyze batch operation result.",
"type": "object",
"$ref": "#/definitions/analyzeResults"
}
}
},
"OperationStatus": {
"type": "string",
"description": "Status code of the text operation.",
"enum": [
"notStarted",
"running",
"failed",
"succeeded"
],
"x-ms-enum": {
"name": "OperationStatusCodes",
"modelAsString": false
},
"x-nullable": false
},
"ReadResult": {
"description": "Text extracted from a page in the input document.",
"type": "object",
"required": [
"page",
"angle",
"width",
"height",
"unit",
"lines"
],
"properties": {
"page": {
"description": "The 1-based page number of the recognition result.",
"type": "integer"
},
"language": {
"description": "The BCP-47 language code of the recognized text page.",
"type": "string"
},
"angle": {
"description": "The orientation of the image in degrees in the clockwise direction. Range between [-180, 180).",
"type": "number"
},
"width": {
"description": "The width of the image in pixels or the PDF in inches.",
"type": "number"
},
"height": {
"description": "The height of the image in pixels or the PDF in inches.",
"type": "number"
},
"unit": {
"description": "The unit used in the Width, Height and BoundingBox. For images, the unit is 'pixel'. For PDF, the unit is 'inch'.",
"type": "string",
"enum": [
"pixel",
"inch"
],
"x-ms-enum": {
"name": "TextRecognitionResultDimensionUnit",
"modelAsString": false
},
"x-nullable": false
},
"lines": {
"description": "A list of recognized text lines.",
"type": "array",
"items": {
"$ref": "#/definitions/Line"
}
}
}
},
"analyzeResults": {
"description": "Analyze batch operation result.",
"type": "object",
"required": [
"version",
"readResults"
],
"properties": {
"version": {
"description": "Version of schema used for this result.",
"type": "string"
},
"readResults": {
"description": "Text extracted from the input.",
"type": "array",
"items": {
"$ref": "#/definitions/ReadResult"
}
}
}
},
"Line": {
"description": "An object representing a recognized text line.",
"type": "object",
"required": [
"boundingBox",
"text",
"words"
],
"properties": {
"language": {
"description": "The BCP-47 language code of the recognized text line. Only provided where the language of the line differs from the page's.",
"type": "string"
},
"boundingBox": {
"description": "Bounding box of a recognized line.",
"$ref": "#/definitions/BoundingBox"
},
"appearance": {
"description": "Style and styleConfidence of the text line.",
"type": "object",
"$ref": "#/definitions/Appearance"
},
"text": {
"description": "The text content of the line.",
"type": "string"
},
"words": {
"description": "List of words in the text line.",
"type": "array",
"items": {
"$ref": "#/definitions/Word"
}
}
}
},
"Word": {
"description": "An object representing a recognized word.",
"type": "object",
"required": [
"boundingBox",
"text",
"confidence"
],
"properties": {
"boundingBox": {
"description": "Bounding box of a recognized word.",
"$ref": "#/definitions/BoundingBox"
},
"text": {
"description": "The text content of the word.",
"type": "string"
},
"confidence": {
"description": "Qualitative confidence measure.",
"type": "number",
"format": "float"
}
}
},
"BoundingBox": {
"description": "Quadrangle bounding box, with coordinates in original image. The eight numbers represent the four points (x-coordinate, y-coordinate from the left-top corner of the image) of the detected rectangle from the left-top corner in the clockwise direction. For images, coordinates are in pixels. For PDF, coordinates are in inches.",
"type": "array",
"items": {
"type": "number",
"x-nullable": false
}
},
"Appearance": {
"description": "An object representing the style and styleConfidence.",
"type": "object",
"required": [
"style",
"styleConfidence"
],
"properties": {
"style": {
"description": "The text line style.",
"type": "string",
"enum": [
"handwriting",
"print"
]
},
"styleConfidence": {
"description": "The confidence of text line style.",
"type": "number",
"format": "float"
}
}
},
"ComputerVisionError": {
"description": "Details about the API request error.",
"required": [
"code",
"message"
],
"type": "object",
"properties": {
"code": {
"description": "The error code.",
"enum": [
"InvalidImageFormat",
"UnsupportedMediaType",
"InvalidImageUrl",
"NotSupportedFeature",
"NotSupportedImage",
"Timeout",
"InternalServerError",
"InvalidImageSize",
"BadArgument",
"DetectFaceError",
"NotSupportedLanguage",
"InvalidThumbnailSize",
"InvalidDetails",
"InvalidModel",
"CancelledRequest",
"NotSupportedVisualFeature",
"FailedToProcess",
"Unspecified",
"StorageException",
"InvalidPageRange"
],
"x-ms-enum": {
"name": "ComputerVisionErrorCodes",
"modelAsString": true
}
},
"message": {
"description": "A message explaining the error reported by the service.",
"type": "string"
},
"requestId": {
"description": "A unique request identifier.",
"type": "string"
}
}
},
"ImageUrl": {
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"description": "Publicly reachable URL of an image.",
"type": "string"
}
}
}
},
"parameters": {
"OcrDetectionLanguage": {
"name": "language",
"in": "query",
"description": "The BCP-47 language code of the text in the document. Currently, only English ('en'), Dutch ('nl'), French ('fr'), German ('de'), Italian ('it'), Portuguese ('pt'), and Spanish ('es') are supported. Read supports auto language identification and multi-language documents, so only provide a language code if you would like to force the documented to be processed as that specific language.",
"required": false,
"default": "en",
"x-ms-parameter-location": "method",
"type": "string",
"x-ms-enum": {
"name": "OcrDetectionLanguage",
"modelAsString": true
},
"enum": [
"en",
"es",
"fr",
"de",
"it",
"nl",
"pt"
]
},
"ImageUrl": {
"name": "ImageUrl",
"in": "body",
"required": true,
"x-ms-parameter-location": "method",
"x-ms-client-flatten": true,
"description": "A JSON document with a URL pointing to the image that is to be analyzed.",
"schema": {
"$ref": "#/definitions/ImageUrl"
}
},
"ImageStream": {
"name": "Image",
"in": "body",
"required": true,
"x-ms-parameter-location": "method",
"description": "An image stream.",
"schema": {
"type": "object",
"format": "file"
}
},
"Endpoint": {
"name": "Endpoint",
"description": "Supported Cognitive Services endpoints.",
"x-ms-parameter-location": "client",
"required": true,
"type": "string",
"in": "path",
"x-ms-skip-url-encoding": true
},
"Pages": {
"name": "Pages",
"in": "query",
"description": "Custom page numbers for multi-page documents(PDF/TIFF), input the number of the pages you want to get OCR result. For a range of pages, use a hyphen. Separate each page or range with a comma or space.",
"required": false,
"x-ms-parameter-location": "method",
"type": "array",
"items": {
"type": "string",
"pattern": "(^[0-9]+-[0-9]+$)|(^[0-9]+$)"
},
"collectionFormat": "csv"
}
}
}