Skip to content

Instantly share code, notes, and snippets.

@msinnema msinnema/sample.cs

Created Jun 6, 2018
Embed
What would you like to do?
Basic multi-threaded Intrada ALPR
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
You can’t perform that action at this time.