Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@msinnema
Created June 6, 2018 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msinnema/c0a941f5fe2c0dfc137b210e41e2ca84 to your computer and use it in GitHub Desktop.
Save msinnema/c0a941f5fe2c0dfc137b210e41e2ca84 to your computer and use it in GitHub Desktop.
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