LEADTOOLS Support
Document
Document SDK Questions
Same ID card but two different pictures - one scans PDF417 but other doesn't
#1
Posted
:
Tuesday, November 8, 2016 12:57:38 PM(UTC)
Groups: Registered
Posts: 2
I am evaluating your BarCodeReader functionality for possible inclusion in our product.
I created a basic project that allowed me to choose a PNG file off my filesystems and try to scan it. I took a picture of my ID card on my iPhone and took one from my Windows laptop. Same ID card, both are saved in PNG format.
I was able to attach my Visual Studio Project now. here are the main code I have. Not sure if it is relevant but using the x64 assemblies.
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Forms;
using Leadtools.Barcode;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
private BarcodeEngine barcodeEngineInstance; // The barcode engine
private RasterImage theImage; // The current loaded image
private string imageFileName; // Last file name we loaded, this is used in the "Writing Barcodes" tutorial
public Form1()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
// Replace the keys with unlock support string provided by LEADTOOLS, or use the evaluation kernel
// Unlock reading 1D barcodes
string MY_LICENSE_FILE = @"eval-license-files.lic";
string MY_DEVELOPER_KEY = @"xxx";
RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DEVELOPER_KEY);
// Create the BarcodeEngine instance
barcodeEngineInstance = new BarcodeEngine();
base.OnLoad(e);
}
protected override void OnFormClosed(FormClosedEventArgs e)
{
// Delete our resources
if (theImage != null)
{
theImage.Dispose();
}
base.OnFormClosed(e);
}
private void loadImageButton_Click(object sender, EventArgs e)
{
string fileName = String.Empty;
using (OpenFileDialog dlg = new OpenFileDialog())
{
if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
{
fileName = dlg.FileName;
}
else
{
return;
}
}
// Load the image
using (RasterCodecs codecs = new RasterCodecs())
{
RasterImage newImage = codecs.Load(fileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);
// Delete old image if any
if (theImage != null)
{
theImage.Dispose();
}
theImage = newImage;
imageFileName = fileName;
}
}
private void readBarcodesButton_Click(object sender, EventArgs e)
{
if (theImage == null)
{
MessageBox.Show("Load an image first");
return;
}
try
{
BarcodeData healthCardData = barcodeEngineInstance.Reader.ReadBarcode(theImage, LogicalRectangle.Empty, BarcodeSymbology.PDF417);
StringBuilder sb = new StringBuilder();
sb.AppendFormat("Symbology: {0}, Location: {1}, Data: {2}", healthCardData.Symbology.ToString(), healthCardData.Bounds.ToString(), healthCardData.Value);
sb.AppendLine();
MessageBox.Show(sb.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
The issue is the PNG from my iPhone scans fine and returns data into my BarcodeData object but the PNG from my laptop results in a null value for the BarcodeData object. If I use the sample PNG file for PDF417 you provide it also works fine.
When I look at the properties of all the PNGs the main difference is my laptop image is a lower resolution and depth. Is there some minimum threshold your ReadBarcode() needs?
Is there a way I can privately send a copy of my images to you for you to look at? It is of my own ID card so has personal info on there I would rather not have on a public forum.
Thanks,
Dan
Edited by moderator Friday, November 11, 2016 9:45:21 AM(UTC)
| Reason: removed dev key
#2
Posted
:
Tuesday, November 8, 2016 3:34:45 PM(UTC)
Groups: Manager, Tech Support, Administrators
Posts: 218
Was thanked: 12 time(s) in 12 post(s)
Dan,
Thanks for your post on the LEADTOOLS Technical Forums.
To recognize PDF417 barcodes on the back of Driver's the minimum resolution needed is 720 but 1080 is the recommended because the printed barcodes are very dense.
Looking at the code that you posted, it looks like the code you are using is correct so it might be one of the following 2 things:
- The Barcode symbology decoder DLL is not included in the output directory with the EXE
- The Image quality is not good enough for barcode recognition
So first thing to check is to ensure that you are including all of the necessary DLLs to your output directory.
A handy chart can be found at the
Files To Be Included With Your Application documentation page but here it is for you to see as well:
So please try adding these DLLs as references in your project to see if that solves the issue.
Otherwise, I will send an email from
support@leadtools.com to the email address that you registered on the forum. If that email address is not correct, please update it and let me know so I can resend the email. Please reply to this email with the images that you are having issues with and I will look into it on my end.
Thank you.
Edited by user Thursday, November 10, 2016 5:11:33 PM(UTC)
| Reason: added better info
Hadi Chami
Developer Support Manager
LEAD Technologies, Inc.
LEADTOOLS Support
Document
Document SDK Questions
Same ID card but two different pictures - one scans PDF417 but other doesn't
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.