Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added descew functions from leptonica - #11
- Loading branch information
Showing
13 changed files
with
305 additions
and
28 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,71 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
|
|||
namespace Tesseract | |||
{ | |||
public struct Scew | |||
{ | |||
private float angle; | |||
private float confidence; | |||
|
|||
public Scew(float angle, float confidence) | |||
{ | |||
this.angle = angle; | |||
this.confidence = confidence; | |||
} | |||
|
|||
public float Angle | |||
{ | |||
get { return angle; } | |||
} | |||
|
|||
|
|||
public float Confidence | |||
{ | |||
get { return confidence; } | |||
} | |||
|
|||
#region ToString | |||
|
|||
public override string ToString() | |||
{ | |||
return String.Format("Scew: {0} [conf: {1}]", Angle, Confidence); | |||
} | |||
|
|||
#endregion | |||
|
|||
#region Equals and GetHashCode implementation | |||
public override bool Equals(object obj) | |||
{ | |||
return (obj is Scew) && Equals((Scew)obj); | |||
} | |||
|
|||
public bool Equals(Scew other) | |||
{ | |||
return this.confidence == other.confidence && this.angle == other.angle; | |||
} | |||
|
|||
public override int GetHashCode() | |||
{ | |||
int hashCode = 0; | |||
unchecked { | |||
hashCode += 1000000007 * angle.GetHashCode(); | |||
hashCode += 1000000009 * confidence.GetHashCode(); | |||
} | |||
return hashCode; | |||
} | |||
|
|||
public static bool operator ==(Scew lhs, Scew rhs) | |||
{ | |||
return lhs.Equals(rhs); | |||
} | |||
|
|||
public static bool operator !=(Scew lhs, Scew rhs) | |||
{ | |||
return !(lhs == rhs); | |||
} | |||
#endregion | |||
|
|||
} | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
|
|||
namespace Tesseract | |||
{ | |||
/// <summary> | |||
/// Represents the parameters for a sweep search used by scew algorithms. | |||
/// </summary> | |||
public struct ScewSweep | |||
{ | |||
public static ScewSweep Default = new ScewSweep(DefaultReduction, DefaultRange, DefaultDelta); | |||
|
|||
#region Constants and Fields | |||
|
|||
public const int DefaultReduction = 4; // Sweep part; 4 is good | |||
public const float DefaultRange = 7.0F; | |||
public const float DefaultDelta = 1.0F; | |||
|
|||
private int reduction; | |||
private float range; | |||
private float delta; | |||
|
|||
#endregion | |||
|
|||
#region Factory Methods + Constructor | |||
|
|||
public ScewSweep(int reduction = DefaultReduction, float range = DefaultRange, float delta = DefaultDelta) | |||
{ | |||
this.reduction = reduction; | |||
this.range = range; | |||
this.delta = delta; | |||
} | |||
|
|||
#endregion | |||
|
|||
#region Properties | |||
|
|||
public int Reduction | |||
{ | |||
get { return reduction; } | |||
} | |||
|
|||
public float Range | |||
{ | |||
get { return range; } | |||
} | |||
|
|||
public float Delta | |||
{ | |||
get { return delta; } | |||
} | |||
|
|||
#endregion | |||
|
|||
} | |||
} |
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
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Oops, something went wrong.