@@ -36,14 +36,20 @@ static void Main(string[] args)
3636 text = RecognizeFromStorage ( conf ) ;
3737 Console . WriteLine ( "-------------\n " + text + "\n -------------\n " ) ;
3838
39- Console . WriteLine ( "Example #4:\n Recognize one of 21 supported languages" ) ;
39+ Console . WriteLine ( "Example #4.1 :\n Recognize one of 21 supported languages" ) ;
4040 text = RecognizeFromStorageDeFr ( conf ) ;
4141 // You may also recognize it from Content or URL
4242 //text = RecognizeFromContentDeFr(conf);
4343 Console . WriteLine ( "-------------\n " + text + "\n -------------\n " +
4444 "Attention: UTF is not supported in windows console." +
4545 "\n ---------------------------------------------------\n " ) ;
4646
47+ Console . WriteLine ( "Example #4.2:\n Recognize Arabic" ) ;
48+ text = RecognizeFromContentAr ( conf ) ;
49+ Console . WriteLine ( "-------------\n " + text + "\n -------------\n " +
50+ "Attention: UTF is not supported in windows console." +
51+ "\n ---------------------------------------------------\n " ) ;
52+
4753 Console . WriteLine ( "Example #5:\n Recognize specific text regions (by coordinates) by URL" ) ;
4854 text = RecognizeRegionsFromUrl ( conf ) ;
4955 Console . WriteLine ( "-------------\n " + text + "\n -------------\n " +
@@ -89,7 +95,7 @@ static string RecognizeFromUrl(Configuration conf)
8995 {
9096 string imgUri = @"https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png" ;
9197 OcrApi api = new OcrApi ( conf ) ;
92- var request = new PostOcrFromUrlOrContentRequest ( null , imgUri ) ;
98+ var request = new PostOcrFromUrlOrContentRequest ( null , imgUri , resultType : ResultType . Text ) ;
9399 OCRResponse response = api . PostOcrFromUrlOrContent ( request ) ;
94100
95101 return response . Text ;
@@ -135,6 +141,19 @@ static string RecognizeFromContentDeFr(Configuration conf)
135141 return response . Text ;
136142 }
137143 }
144+
145+ static string RecognizeFromContentAr ( Configuration conf )
146+ {
147+ string name = "ar2.png" ;
148+ using ( FileStream fs = File . OpenRead ( name ) )
149+ {
150+ OcrApi api = new OcrApi ( conf ) ;
151+ var request = new PostOcrFromUrlOrContentRequest ( fs , "" , language : LanguageEnum . Arabic ) ;
152+ OCRResponse response = api . PostOcrFromUrlOrContent ( request ) ;
153+
154+ return response . Text ;
155+ }
156+ }
138157
139158 static string RecognizeFromStorageDeFr ( Configuration conf )
140159 {
@@ -183,22 +202,21 @@ static string RecognizeRegionsFromUrl(Configuration conf)
183202
184203 static string RecognizeRegionsFromContent ( Configuration conf )
185204 {
186- List < OCRRegion > mImageBook_of_Abraham_FirstPagePngRegions = new List < OCRRegion > ( )
205+ List < OCRRegion > mImage5PngRegions = new List < OCRRegion > ( )
187206 {
188- new OCRRegion ( ) { Order = 0 , Rect = new OCRRect ( 209 , 28 , 283 , 39 ) } ,
189- new OCRRegion ( ) { Order = 1 , Rect = new OCRRect ( 24 , 114 , 359 , 185 ) } ,
190- new OCRRegion ( ) { Order = 2 , Rect = new OCRRect ( 21 , 201 , 356 , 451 ) } ,
191- new OCRRegion ( ) { Order = 3 , Rect = new OCRRect ( 21 , 464 , 359 , 558 ) }
207+ new OCRRegion ( ) { Order = 0 , Rect = new OCRRect ( 243 , 308 , 2095 , 964 ) } ,
208+ new OCRRegion ( ) { Order = 1 , Rect = new OCRRect ( 240 , 1045 , 2108 , 1826 ) } ,
209+ new OCRRegion ( ) { Order = 2 , Rect = new OCRRect ( 237 , 1916 , 2083 , 3180 ) }
192210 } ;
193211
194- string name = "de_1.jpg " ;
212+ string name = "5.png " ;
195213 using ( FileStream fs = File . OpenRead ( name ) )
196214 {
197215 OcrApi api = new OcrApi ( conf ) ;
198216 OCRRegionsRequestData requestData = new OCRRegionsRequestData ( )
199217 {
200- Language = LanguageEnum . German ,
201- Regions = mImageBook_of_Abraham_FirstPagePngRegions
218+ Language = LanguageEnum . English ,
219+ Regions = mImage5PngRegions
202220 } ;
203221 OCRResponse response = api . OcrRegionsFromContent ( requestData , fs ) ;
204222
@@ -208,15 +226,14 @@ static string RecognizeRegionsFromContent(Configuration conf)
208226
209227 static string RecognizeRegionsFromStorage ( Configuration conf )
210228 {
211- List < OCRRegion > mImageBook_of_Abraham_FirstPagePngRegions = new List < OCRRegion > ( )
229+ List < OCRRegion > mImage5PngRegions = new List < OCRRegion > ( )
212230 {
213- new OCRRegion ( ) { Order = 0 , Rect = new OCRRect ( 209 , 28 , 283 , 39 ) } ,
214- new OCRRegion ( ) { Order = 1 , Rect = new OCRRect ( 24 , 114 , 359 , 185 ) } ,
215- new OCRRegion ( ) { Order = 2 , Rect = new OCRRect ( 21 , 201 , 356 , 451 ) } ,
216- new OCRRegion ( ) { Order = 3 , Rect = new OCRRect ( 21 , 464 , 359 , 558 ) }
231+ new OCRRegion ( ) { Order = 0 , Rect = new OCRRect ( 243 , 308 , 2095 , 964 ) } ,
232+ new OCRRegion ( ) { Order = 1 , Rect = new OCRRect ( 240 , 1045 , 2108 , 1826 ) } ,
233+ new OCRRegion ( ) { Order = 2 , Rect = new OCRRect ( 237 , 1916 , 2083 , 3180 ) }
217234 } ;
218235
219- string name = "de_1.jpg " ;
236+ string name = "5.png " ;
220237 using ( FileStream fs = File . OpenRead ( name ) )
221238 {
222239 OcrApi api = new OcrApi ( conf ) ;
@@ -227,7 +244,7 @@ static string RecognizeRegionsFromStorage(Configuration conf)
227244 OCRRegionsRequestDataStorage requestData = new OCRRegionsRequestDataStorage ( )
228245 {
229246 Language = LanguageEnum . German ,
230- Regions = mImageBook_of_Abraham_FirstPagePngRegions ,
247+ Regions = mImage5PngRegions ,
231248 FileName = name
232249 } ;
233250 OCRResponse response = api . OcrRegionsFromContent ( requestData , fs ) ;
@@ -245,7 +262,7 @@ static string RecognizeFromContentToPdf(Configuration conf)
245262 var request = new PostOcrFromUrlOrContentRequest ( fs , resultType : ResultType . Pdf , dsrMode : DsrMode . DsrAndFilter ) ;
246263 OCRResponse response = api . PostOcrFromUrlOrContent ( request ) ;
247264
248- return response . Pdf ;
265+ return response . Pdf . Substring ( 0 , 30 ) + " .................." ;
249266 }
250267 }
251268
@@ -293,7 +310,7 @@ static string RecognizePdfFromContent(Configuration conf)
293310
294311 static string RecognizeTableFromContent ( Configuration conf )
295312 {
296- string name = "table.png " ;
313+ string name = "table.jpeg " ;
297314 using ( FileStream fs = File . OpenRead ( name ) )
298315 {
299316 OcrApi api = new OcrApi ( conf ) ;
@@ -307,7 +324,7 @@ static string RecognizeTableFromContent(Configuration conf)
307324
308325 static string RecognizeTableFromStorage ( Configuration conf )
309326 {
310- string name = "table.png " ;
327+ string name = "table.jpeg " ;
311328 using ( FileStream fs = File . OpenRead ( name ) )
312329 {
313330 OcrApi api = new OcrApi ( conf ) ;
0 commit comments