Low performances using Barcode1DReaderDoScan with PDF files

Discussions about 1D barcode reading and writing
Post Reply
mdelbene
Posts: 31
Joined: Wed May 11, 2011 10:03 am

Low performances using Barcode1DReaderDoScan with PDF files

Post by mdelbene » Fri Oct 21, 2011 11:43 am

Hi all,
I'm using GdPicture.NET rel. 8.3.0.5.
My application contains a GdViewer control, where I can drag a file from file system.
When I drop the file, I load the file, then detect a possible barcode and show the document in the control.
During barcode detecting, I encounter very low performances when I load a PDF file.

With barcode detection elapsed time is 26 seconds.
Commenting the detection call the time decreases drastically to 2 seconds. :shock:

This is my C# code snippet of Detect method:

Code: Select all

//------------------------------------------------------------------------------------
private List<string> DetectBarcodeInPDFFile(string pdfPath)
{
	List<string> bCodes = new List<string>();

	if (gdPDF.LoadFromFile(pdfPath, false) == GdPictureStatus.OK)
	{
		for (int i = 1; i <= gdPDF.GetPageCount(); i++)
		{
			// select current page
			if (gdPDF.SelectPage(i))
			{
				// extract image
				int imageId = gdPDF.RenderPageToGdPictureImage(200, false);
				if (imageId > 0)
				{
					// search barcode in j-th page
					if (gdPicture.Barcode1DReaderDoScan(imageId, Barcode1DReaderScanMode.BestQuality) == GdPictureStatus.OK)
					{
						// per ogni barcode individuato memorizzo le sue informazioni
						for (int j = 1; j <= gdPicture.Barcode1DReaderGetBarcodeCount(); j++)
							bCodes.Add(gdPicture.Barcode1DReaderGetBarcodeValue(j));
					}

					// I release the memory
					gdPicture.Barcode1DReaderClear(); 
					gdPicture.ReleaseGdPictureImage(imageId); 
				}
			}
		}
		gdPDF.CloseDocument();
	}
	return bCodes;
}
I attach the zipped file which is particularly slow.

Probably something is wrong in my code, otherwise there is another way to improve this operation?

Thanks in advance.
Michela
Attachments
ASL3.zip
(178.72 KiB) Downloaded 160 times

User avatar
Loïc
Site Admin
Posts: 5576
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Low performances using Barcode1DReaderDoScan with PDF fi

Post by Loïc » Mon Oct 24, 2011 10:17 am

Hi Michela,

In your snippet you convert 70 pages of a PDF in 200 DPI, then try to recognize barcode on each produced Bitmap.
24 sec to do that is really acceptable for me.

Unfortunately there is no faster way to do such things.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests