Datamatrix BarCode Not Found

I have done every image manipulation I could think of to make the bar code in this attachment more clear. The code 39 barcode is being recognized with no problem however the datamatrix bar code is not found at all. However, when I crop the picture down to just the datamatrix bar code it is recognized just fine.


How can this be? What can I possibly do to help your software find the datamatrix bar code???

(using the .NET 3.5 dll)

Hello,

Could you please share your code? I test the attached pictures and the reader works fine. I'd attached the scan result within this post too.

Thanks

Dean,


It’s pretty much copy paste from your demo.

protected void Button2_Click(object sender, EventArgs e)
{
//// check if session variable is not null
//if (base.Session[“userfilename”] != null)
//{
// get the path of the image that was saved during the file upload
string str = base.Session[“userfilename”] as string;
// ApplyAppPathModifier does not let us work on our production environment
this.userImageUrl = str;
// Me.userImageUrl = Response.ApplyAppPathModifier("~/" & str)
try
{
// set the symbologies that were selected by the user
BarCodeReadType readType = null;
readType = this.GetReadTypes();

// Create an object of type BarCodeReader to recognize the barcode
// pass the image path as an argument to the constructor
BarCodeReader reader = new BarCodeReader(base.Server.MapPath(System.Convert.ToString(base.Session[“userfilename”])), readType);

this.Label1.Text = “”;
// recognize the barcode by calling the Read() method
string sourcePath = base.Server.MapPath((string)(base.Session[“userfilename”]));

if (reader.Read())
{
// set the labels with the codetext and symbology type
this.Label1.Text = (“Barcode Found. " + reader.GetReadType().ToString() + “:”) + reader.GetCodeText();
this.Label1.ForeColor = Color.DarkGreen;
using (Bitmap bm = new Bitmap(sourcePath))
{
string path = ((string)(base.Session[“userfilename”])) + “result.jpg”;
//Using graphics As Graphics = graphics.FromImage(bm)

// Dim region As New BarCodeRegion(reader.ReadRegion())
// region.DrawBarCodeEdges(graphics, New Pen(Color.Red, 2.0F))
//End Using
string tmpFileName = Server.MapPath(path);
bm.Save(tmpFileName);
// ApplyAppPathModifier does not let us work on our production environment
this.Image1.ImageUrl = path;
// this.Image1.ImageUrl = Response.ApplyAppPathModifier(”~/"+ path);
this.panelcomplain.Visible = false;
}
}
else
{
this.Label1.Text = “Barcode not found, please try different symbologies”;
this.Label1.ForeColor = Color.DarkGreen;
this.panelcomplain.Visible = true;
}

}
catch (Exception exception)
{
this.Label1.Text = exception.Message;
this.Label1.ForeColor = Color.Red;
this.panelcomplain.Visible = true;
}
//}
//else
//{
// this.Label1.Text = “image not found”;
// this.Label1.ForeColor = Color.Red;
//}
}

private BarCodeReadType GetReadTypes()
{
BarCodeReadType mType = null;
mType = 0;
// set the symbologies based on the respective checkbox value
if (this.cbBooklandEAN.Checked)
{
mType = mType | BarCodeReadType.BooklandEAN;
}
if (this.cbCodabar.Checked)
{
mType = mType | BarCodeReadType.Codabar;
}
if (this.cbCode11.Checked)
{
mType = mType | BarCodeReadType.Code11;
}
if (this.cbCode128.Checked)
{
mType = mType | BarCodeReadType.Code128;
}
if (this.cbCode39.Checked)
{
//mType = mType | BarCodeReadType.Code39Extended;
mType = mType | BarCodeReadType.Code39Standard;
}
if (this.cbCode93.Checked)
{
mType = mType | BarCodeReadType.Code93Extended;
}
if (this.cbDatamatrix.Checked)
{
mType = mType | BarCodeReadType.DataMatrix;
}
if (this.cbEAN13.Checked)
{
mType = mType | BarCodeReadType.EAN13;
}
if (this.cbEAN8.Checked)
{
mType = mType | BarCodeReadType.EAN8;
}
if (this.cbInterleaved2of5.Checked)
{
mType = mType | BarCodeReadType.Interleaved2of5;
}
if (this.cbPdf417.Checked)
{
mType = mType | BarCodeReadType.Pdf417;
}
if (this.cbPlanet.Checked)
{
mType = mType | BarCodeReadType.Planet;
}
if (this.cbPostnet.Checked)
{
mType = mType | BarCodeReadType.Postnet;
}
if (this.cbUPCA.Checked)
{
mType = mType | BarCodeReadType.UPCA;
}
if (this.cbUPCE.Checked)
{
mType = mType | BarCodeReadType.UPCE;
}
if (this.cbQR.Checked)
{
mType = mType | BarCodeReadType.QR;
}
if (this.cbMsi.Checked)
{
mType = mType | BarCodeReadType.MSI;
}
if (this.cbOneCode.Checked)
{
mType = mType | BarCodeReadType.OneCode;
}
//mType = mType | BarCodeReadType.Code39Standard;
return mType;
}

Nevermind, I’m an idiot…

My code was evidently just not looping through all of the different possibilities and was instead stopping once it read code 39.

I had to tweak the heck out of the picture to get it to this point but it seems to be working great now - thanks!!