Skip to content

Commit 76b026a

Browse files
committed
Release 21.06: Arabic, Hindi, Russian, Ukrainian languages.
1 parent d9a9729 commit 76b026a

24 files changed

+159
-80
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
_ReSharper.*
44
bin
55
obj
6-
.vs
6+
.vs
7+
Aspose.Ocr.Cloud.Sdk.sln.DotSettings

Aspose.Ocr.Cloud.Sdk.Demo.Net.Core/Aspose.Ocr.Cloud.Sdk.Demo.Net.Core.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ItemGroup>
99
<None Remove="10.png" />
1010
<None Remove="de_1.jpg" />
11-
<None Remove="table.png" />
11+
<None Remove="table.jpeg" />
1212
</ItemGroup>
1313

1414
<ItemGroup>
@@ -21,8 +21,8 @@
2121
<Content Include="10.png">
2222
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2323
</Content>
24-
<Content Include="table.png">
25-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
24+
<Content Include="table.jpeg">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2626
</Content>
2727
</ItemGroup>
2828

Aspose.Ocr.Cloud.Sdk.Demo.Net.Core/Program.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,16 @@ static void Main(string[] args)
4646
text = RecognizeTableFromUrl(conf);
4747
Console.WriteLine("-------------\n" + text + "\n-------------\n");
4848

49+
Console.WriteLine("Example #13:\nRecognize specific regions of image located by URL");
50+
text = RecognizeRegionsFromUrl(conf);
51+
Console.WriteLine("-------------\n" + text + "\n-------------\n");
52+
4953
Console.Write("Completed. Press any key..."); Console.ReadKey();
5054
}
5155

5256
static string RecognizeFromUrl(Configuration conf)
5357
{
54-
string imgUri = @"http://typecast.com/images/uploads/fluid-type-single-column.png";
58+
string imgUri = @"https://upload.wikimedia.org/wikipedia/commons/2/2f/Book_of_Abraham_FirstPage.png";
5559

5660
OcrApi api = new OcrApi(conf);
5761
var request = new PostOcrFromUrlOrContentRequest(null, imgUri);
@@ -136,7 +140,7 @@ static string RecognizeRegionsFromUrl(Configuration conf)
136140

137141
static string RecognizeTableFromContent(Configuration conf)
138142
{
139-
string name = "table.png";
143+
string name = "table.jpeg";
140144
using (FileStream fs = File.OpenRead(name))
141145
{
142146
OcrApi api = new OcrApi(conf);
@@ -150,7 +154,7 @@ static string RecognizeTableFromContent(Configuration conf)
150154

151155
static string RecognizeTableFromStorage(Configuration conf)
152156
{
153-
string name = "table.png";
157+
string name = "table.jpeg";
154158
using (FileStream fs = File.OpenRead(name))
155159
{
156160
OcrApi api = new OcrApi(conf);
71 KB
Loading
-30.7 KB
Binary file not shown.

Aspose.Ocr.Cloud.Sdk.Demo/5.png

509 KB
Loading

Aspose.Ocr.Cloud.Sdk.Demo/Aspose.Ocr.Cloud.Sdk.Demo.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,20 @@
8282
<Content Include="10.png">
8383
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8484
</Content>
85+
<Content Include="5.png">
86+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
87+
</Content>
88+
<Content Include="ar2.png">
89+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
90+
</Content>
8591
<Content Include="de_1.jpg">
8692
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
8793
</Content>
8894
<Content Include="r11.jpg">
8995
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
9096
</Content>
91-
<Content Include="table.png">
92-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
97+
<Content Include="table.jpeg">
98+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
9399
</Content>
94100
</ItemGroup>
95101
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Aspose.Ocr.Cloud.Sdk.Demo/Program.cs

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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:\nRecognize one of 21 supported languages");
39+
Console.WriteLine("Example #4.1:\nRecognize 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:\nRecognize 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:\nRecognize 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);

Aspose.Ocr.Cloud.Sdk.Demo/ar2.png

79.9 KB
Loading

Aspose.Ocr.Cloud.Sdk.Demo/table.jpeg

71 KB
Loading

0 commit comments

Comments
 (0)