Spire.Barcode is a professional barcode library specially designed for .NET developers (C#, VB.NET, ASP.NET, .NET Core) and Java developers (J2SE and J2EE) to generate, read and scan 1D & 2D barcodes.

Tue Oct 31, 2017 7:09 am

Hi,
I am using free Spire.Barcode library.

While scanning barcodes from image, Scan function is taking significant time to return results.
If the image has complex/ more data, time exceeds more than 25 seconds per page, that is quite a large.

Please help me to improve scan speed. My code is below

int ZoomFactor=3;
Stream stream1 = new FileStream(FileName, FileMode.Open, FileAccess.Read);
PdfLoadedDocument ldoc = new PdfLoadedDocument(stream1);
try
{
for (int i = 0; i < ldoc.Pages.Count; i++)
{
SizeF pageSize = ldoc.Pages[i].Size;
Bitmap img = ldoc.ExportAsImage(i, new SizeF(pageSize.Width * ZoomFactor, pageSize.Height * ZoomFactor), true);
string[] str = Spire.Barcode.BarcodeScanner.Scan(img, Spire.Barcode.BarCodeType.Code128);
foreach (string item in str)
{
txtProcessed.Text += item + "; ";
}
img.Dispose();
img = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
stream1.Close();
stream1.Dispose();
ldoc.Close();
ldoc.Dispose();
}
catch (Exception )
{
}
finally
{
stream1.Close();
stream1.Dispose();
ldoc.Close();
ldoc.Dispose();
}

pravinchopade
 
Posts: 7
Joined: Mon Aug 21, 2017 12:56 pm

Tue Oct 31, 2017 8:00 am

Hi pravinchopade,

Thanks for your inquiry.
Please provide us with your barcode image for further investigation.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 31, 2017 9:55 am

Hi pravinchopade,

Thanks for your sample file via Skype.
I have tested the file with Spire.BarCode(Hot Fix) Version:1.4.11, scanning barcode took about 1.5 second. So please try to use this version. Here is my testing code.
Code: Select all
            string[] str = Spire.Barcode.BarcodeScanner.Scan(path + "Sample.png", Spire.Barcode.BarCodeType.Code128);

If there is any question, please let us know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Nov 01, 2017 5:33 am

Thanks Betsy.jiang,

I want to know that, which option will process barcode faster
1. Process image file from physical path
2. Process bitmap, extracted from pdf.

pravinchopade
 
Posts: 7
Joined: Mon Aug 21, 2017 12:56 pm

Wed Nov 01, 2017 6:32 am

Hi pravinchopade,

Thanks for your feedback.
If the image is the same, the processing bitmap will be faster when scanning. Since in the internal code the image file from physical path needs to be loaded first, this will take time.
Any question, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.BarCode

cron