-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e0f3c4
commit 65381a7
Showing
39 changed files
with
234 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
The source images: test1.jpg test2.png test3.png | ||
The source code: | ||
|
||
// Set the license file or try our product without license | ||
License lic = new License(); | ||
lic.SetLicense("Aspose.Total.lic"); | ||
// Set the license file | ||
//License lic = new License(); | ||
//lic.SetLicense("Aspose.Total.lic"); | ||
|
||
// Create AsposeOcr instance. | ||
// You can use the overloaded constructor to set characters restriction. | ||
AsposeOcr api = new AsposeOcr(); | ||
|
||
// You can put in parameters MemoryStream with image or path to the image | ||
|
||
// Create OcrInput object to containerize images | ||
OcrInput input = new OcrInput(InputType.SingleImage); | ||
input.Add(fileName); | ||
|
||
// You can put in parameters MemoryStream with image | ||
// The result is the degree of skew | ||
var result = api.CalculateSkew("test1.jpg"); | ||
|
||
// Print the result | ||
List<SkewOutput> result = api.CalculateSkew(input); | ||
Console.WriteLine("RESULT"); | ||
|
||
Console.ResetColor(); | ||
Console.WriteLine("------------------------------------------------------------------------------"); | ||
|
||
Console.WriteLine("SKEW IMAGE:"); | ||
Console.WriteLine(result); | ||
Console.WriteLine("SKEW IMAGE 1:"); | ||
Console.WriteLine(result[0].Angle); | ||
|
||
input.Clear(); | ||
input.Add("images/test2.png"); | ||
result = api.CalculateSkew(input); | ||
Console.WriteLine("\nSKEW IMAGE 2:"); | ||
Console.WriteLine(result[0].Angle); | ||
|
||
input.Clear(); | ||
input.Add("images/test3.png"); | ||
result = api.CalculateSkew(input); | ||
Console.WriteLine("\nSKEW IMAGE 3:"); | ||
Console.WriteLine(result[0].Angle); |
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
The source images: test.jpg | ||
The source code: | ||
|
||
// Set the license file or try our product without license | ||
License lic = new License(); | ||
lic.SetLicense("Aspose.Total.lic"); | ||
// Set the license file | ||
//License lic = new License(); | ||
//lic.SetLicense("Aspose.Total.lic"); | ||
|
||
// Create AsposeOcr instance. | ||
// You can use the overloaded constructor to set characters restriction. | ||
AsposeOcr api = new AsposeOcr(); | ||
|
||
// Set: | ||
// 1) path to the image or MemruStream with the image. | ||
// 2) set of filters for preprocessing. You can call any number of filters. | ||
MemoryStream memoryStream = api.PreprocessImage("test.jpg", new PreprocessingFilter { PreprocessingFilter.ContrastCorrectionFilter()}); | ||
// Create OcrInput object to containerize images | ||
// Add filters as you need | ||
PreprocessingFilter filters = new PreprocessingFilter // we automaticaly preprocess your image, but if your recognition result still bad, you can set up the set of filters by your own | ||
{ | ||
//PreprocessingFilter.Dilate() | ||
}; | ||
OcrInput input = new OcrInput(InputType.SingleImage, filters); | ||
input.Add(fileName); | ||
|
||
// Use Stream for further recognition or simply save it on the disk | ||
using(FileStream fs = new FileStream("corrected.jpg", FileMode.OpenOrCreate)) | ||
{ | ||
memoryStream.WriteTo(fs); | ||
memoryStream.Close(); | ||
} | ||
List<RecognitionResult> res = api.Recognize(input, new RecognitionSettings | ||
{ | ||
//// allowed options | ||
// AllowedCharacters = CharactersAllowedType.LATIN_ALPHABET, // ignore not latin symbols | ||
// AutoSkew = true, // switch off if your image not rotated | ||
// DetectAreasMode = DetectAreasMode.DOCUMENT, // depends on the structure of your image | ||
// IgnoredCharacters = "*-!@#$%^&", // define the symbols you want to ignore in the recognition result | ||
// Language = Language.Eng, // we support 26 languages | ||
// LinesFiltration = false, // this works slowly, so choose it only if your picture has lines and it they bad detected in TABLE ar DOCUMENT DetectAreasMode | ||
|
||
// RecognitionAreas = new System.Collections.Generic.List<System.Drawing.Rectangle> // set this if you want to recognize only partiqular regions on the image | ||
// { | ||
// new System.Drawing.Rectangle(0,0,10,20) | ||
// }, | ||
// RecognizeSingleLine = false, // set this true if your image has only one text line (without other objects) | ||
// ThreadsCount = 1, // by default our API use all you threads. But you can run it in one thread. Simply set up this here | ||
// ThresholdValue = 150 // if you want to binarize image with your own threashold value, you can set up this here (from 1 to 255) | ||
}); | ||
|
||
// Save the result | ||
// Set: | ||
// 1) path for new file | ||
// 2) File format | ||
// 3) set true if you want to correct the mistakes in the words | ||
// 4) set the language if you want to correct the mistakes | ||
// 5) you can set your own dictionary for spell-check | ||
res[0].Save("result.json", SaveFormat.Json, false); |
File renamed without changes
Oops, something went wrong.