-
Notifications
You must be signed in to change notification settings - Fork 741
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
Showing
6 changed files
with
57 additions
and
22 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 | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Tesseract.Tests.Console | ||
{ | ||
class Program | ||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
private const int DefaultIterations = 10000; | ||
|
||
public static void Main(string[] args) | ||
{ | ||
System.Console.WriteLine("Is 64bit process: {0}", Environment.Is64BitProcess); | ||
|
||
try { | ||
var testFixture = new Tesseract.Tests.EngineTests(); | ||
testFixture.Initialise_CanLoadConfigFile(); | ||
} catch (Exception e) { | ||
System.Console.WriteLine("Unhandled exception occured: \r\n{0}", e); | ||
} | ||
System.Console.WriteLine("Is 64bit process: {0}", Environment.Is64BitProcess); | ||
|
||
try { | ||
var program = new Program(); | ||
|
||
using (var pix = Pix.LoadFromFile("./phototest2.png")) { | ||
// Convert RGB to grayscale (required for binarize operations). | ||
using (Pix grayPix = pix.Depth == 32 ? pix.ConvertRGBToGray() : pix.Clone()) { | ||
//program.MemoryLeakDetector(grayPix, tempPix => tempPix.BinarizeSauvolaTiled(50, 0.35f, 8, 8)); | ||
//program.MemoryLeakDetector(grayPix, tempPix => tempPix.BinarizeSauvola(50, 0.35f, true)); | ||
//program.MemoryLeakDetector(grayPix, tempPix => tempPix.BinarizeOtsuAdaptiveThreshold(50, 50, 5, 5, 0.1f)); | ||
|
||
// Test clone | ||
program.MemoryLeakDetector(grayPix, tempPix => tempPix.Clone()); | ||
} | ||
} | ||
} catch (Exception e) { | ||
System.Console.WriteLine("Unhandled exception occured: \r\n{0}", e); | ||
} | ||
System.Console.WriteLine("Press any key to exit."); | ||
System.Console.ReadKey(); | ||
} | ||
|
||
public void MemoryLeakDetector(Pix pix, Func<Pix, Pix> op, int iterations = DefaultIterations) | ||
{ | ||
for (int i = 0; i < iterations; i++) { | ||
using (Pix result = op(pix)) { | ||
//using (Pix binaryPix = grayPix.BinarizeOtsuAdaptiveThreshold(50, 50, 5, 5, 0.1f)) { | ||
System.Console.WriteLine("Memory: {0} MB", System.Diagnostics.Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024)); | ||
} | ||
|
||
GC.Collect(); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
Loading
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