LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Implement Live Capture of Drivers Licenses on Windows
#1
Posted
:
Wednesday, February 14, 2018 12:20:49 PM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
Attached is a LEADTOOLS V20 .NET C# demo application that uses the
LEADTOOLS Multimedia SDK alongside the
LEADTOOLS Barcode SDK and the newly released
AAMVAID class.
This demo shows how to use the
LEADTOOLS Callback Filter to grab frames from a video device (webcam) and attempt to parse a Drivers License Barcode found within.
The demo takes advantage of the .NET 4+ System.Threading.Tasks Namespace to process multiple frames at once. There is a hard-coded 'MaxConcurrentTasks' property that tracks the total number of tasks being run at the same time to limit the application's use of threads. This is handled like so:
Code:
private List<Task> Runningtasks = new List<Task>();
private const int MaxConcurrentTasks = 8;
private TimeSpan Timeout = TimeSpan.FromSeconds(2);
//Check to see if we are at max concurrency
if (Runningtasks.Count <= MaxConcurrentTasks)
{
//Start a new task here
Task processFrame = Task.Factory.StartNew(() =>
{
//start the barocde read process in a new task
var task = Task.Factory.StartNew(() => ProcessBarcode(pData, lWidth, lHeight, lBitCount, lSize, bTopDown));
//if we are unable to find a barcode in 2 seconds, kill the task
if (!task.Wait(Timeout))
return;
});
// add the task to the list of running tasks
Runningtasks.Add(processFrame);
//once the task is complete (either through timeout or normal completion) remove it from the list of running tasks
processFrame.ContinueWith(s =>
{
Runningtasks.Remove(processFrame);
});
}
The demo implements a custom event for when it finds a barcode in one of the threads to stop the other threads and notify the main program like so:
Code:
public delegate void BarcodeFoundHandler(object sender, BarcodeFoundEventArgs e);
public event BarcodeFoundHandler OnBarcodeFound;
public class BarcodeFoundEventArgs : EventArgs, IDisposable
{
public AAMVAID AAMVAID { get; private set; }
public BarcodeFoundEventArgs(AAMVAID aamvaid)
{
AAMVAID = aamvaid;
}
public void Dispose()
{
AAMVAID.Dispose();
}
}
When a barcode is found, the AAMVAID is then parsed and displayed to the user like so:
In order to run the demo, you need to have the LEADTOOLS Multimedia SDK installed as well as the LEADTOOLS Main Evaluation.
The demo can be downloaded from here:
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
#2
Posted
:
Monday, February 19, 2018 3:53:41 PM(UTC)
Groups: Tech Support
Posts: 366
Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
This demo has been updated with UI changes to show when the user has selected a device to capture from. The demo also releases that device when the application is closed.
The callback has also been updated to only grab one out of ever 6 frames. This is necessary to achieve better performance through lower CPU usage and keep the application responsive while attempting to find a barcode in the video stream.
Walter Bates
Senior Support Engineer
LEAD Technologies, Inc.
#3
Posted
:
Friday, March 30, 2018 10:50:14 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 199
Was thanked: 28 time(s) in 28 post(s)
Added simple image processing to aid the recognition (
AutoColorLevel and
DynamicBinary):
Code:
AutoColorLevelCommand autoColorLevelCommand = new AutoColorLevelCommand();
autoColorLevelCommand.Run(editted);
DynamicBinaryCommand dynamicBinaryCommand = new DynamicBinaryCommand();
dynamicBinaryCommand.Dimension = 13;
dynamicBinaryCommand.LocalContrast = 25;
dynamicBinaryCommand.Run(editted);
And if it still doesn't read (
BarCodeReadPreprocess):
Code:
BarCodeReadPreprocessCommand barCodeReadPreprocessCommand = new BarCodeReadPreprocessCommand();
barCodeReadPreprocessCommand.Options = BarCodeReadPreprocessOptions.UseAutoDocumentBinarization;
barCodeReadPreprocessCommand.Run(editted);
Then using the location found by the preprocess command:
Code:
if (!barCodeReadPreprocessCommand.BarcodeLocation.IsEmpty)
data = engine.Reader.ReadBarcode(editted, barCodeReadPreprocessCommand.BarcodeLocation, BarcodeSymbology.PDF417, options);
Anthony Northrup
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Examples
HOW TO: Implement Live Capture of Drivers Licenses on Windows
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.