Created
June 6, 2018 12:33
-
-
Save msinnema/c0a941f5fe2c0dfc137b210e41e2ca84 to your computer and use it in GitHub Desktop.
Basic multi-threaded Intrada ALPR
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
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Threading; | |
using Intrada.ALPR; | |
namespace RecognizeDirMultiThreaded | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
string[] filenames = Directory.GetFiles(".", "*.jpg", SearchOption.AllDirectories); | |
IntradaALPR intrada = new IntradaALPR("<COMPANY_NAME>", "<COMPANY_KEY>"); | |
IntradaALPR.RecognitionContext context1 = intrada.CreateNewRecognitionContext(); | |
context1.LoadSettings("settings.txt"); | |
IntradaALPR.RecognitionContext context2 = intrada.CreateNewRecognitionContext(); | |
context2.LoadSettings("settings.txt"); | |
Thread thread1 = new Thread(() => | |
{ | |
foreach (string filename in filenames.Take(filenames.Length / 2).ToArray()) | |
{ | |
Result result = context1.Recognize(filename); | |
Console.WriteLine(filename + "\t" + result); | |
} | |
}); | |
thread1.Start(); | |
Thread thread2 = new Thread(() => | |
{ | |
foreach (string filename in filenames.Skip(filenames.Length / 2).ToArray()) | |
{ | |
Result result = context2.Recognize(filename); | |
Console.WriteLine(filename + "\t" + result); | |
} | |
}); | |
thread2.Start(); | |
thread1.Join(); | |
thread2.Join(); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine("Error: " + e); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment