QRCode not recognized in TIFF image (Aspose.Barcode 5.5.0)

Hi,

I'm having issues with the latest version of Aspose.Barcode library. Am trying to recognize barcodes in TIFF images, but it always does not recognize any of them. I tested the same images on eg. http://zxing.org/w/decode.jspx and my mobile phone and these have been recognized properly.

A piece of VB.NET code:
rd = New Aspose.BarCodeRecognition.BarCodeReader(TBitmap, BarCodeReadType.QR) 'TBitmap is an instance of System.Drawing.Image
rd.OrientationHints = RecognitionHints.ImageBinarization.MedianSmoothing Or RecognitionHints.ImageBinarization.Grayscale
' also tried to set rd.CustomizedScanStrength to various values 128, 256 etc. but with no success
rd.Read() ' returns false

Note that the same files are properly recognized when using 3.6.1 version of the Aspose.Barcode library! A piece of VB.NET code we used with this version:
'TBitmap is an instance of System.Drawing.Image
rd = New Aspose.BarCodeRecognition.BarCodeReader(TBitmap, BarCodeReadType.QR)
rd.SetHints(RecognitionHints.ImageBinarizationHints.MedianSmoothing Or
RecognitionHints.ImageBinarizationHints.Grayscale Or
RecognitionHints.ScanStrengthHints.Strong)
rd.Read() ' returns true and rd.GetCodeText returns expected value

SetHints is obsolete in the latest version but the documentation retrieved from http://www.aspose.com/community/files/51/.net-components/aspose.barcode-for-.net/category1280.aspx
have likely not been updated for a long time. So am not sure if my new code is appropriate.

I also tested the same on 4.8.0, 5.0.0 and 5.4.0 with no success. We are having now a then occurring crashes on 3.6.1 so that's the reason why we decided to upgrade to the latest...

Attaching the images - TIFF and JPEG version, all of them are possible to recognize with the 3.6.1 version using the code above.

Jiri Matejka

Hi Jiri,


Thanks for your inquiry. I tested your sample bar code images against the latest build of Aspose.BarCode for .NET 5.5.0. The provided bar code images are too extended vertically. I re-sized these images and able to recognize them. I have attached a zip file for your reference. Also, I have logged this problem under ticket id BARCODENET-33502 in our issue tracking system. We will investigate the cause of recognition failure. You will be notified once it is fixed and available for public use. We’re sorry for your inconvenience.

Hi Imran,


thanks for your reply. Note that these QRCodes have been created using Aspose.Barcode library (3.6.1 version). Also I retested with 5.5.0 and the QRCodes are again created vertically extended… Is there any chance how to force Aspose.BarCode.BarCodeBuilder to create to codes as squares?

thanks

Jiri

Hi Jiri,


Thanks for the information. Can you please share the source code you are trying to generate these bar code images with our latest build of Aspose.BarCode for .NET 5.5.0? It will help me to replicate the problem.

Hi Imran,


I figured out that the QR vertical extension was caused by two aspects:
1) There are default margins when the QR code is generated are different for top/bottom and right/left. The generated code is fine itself but
2) When it is placed to a PDF file using Aspose.Pdf.Kit.PdfFileStamp class then it gets vertically extended.

Solution: It is enough to override the default margins before the QR code is generated:
Dim b As New Aspose.BarCode.BarCodeBuilder
b.SymbologyType = Aspose.BarCode.Symbology.QR
b.AutoSize = True
b.xDimension = 2
b.QREncodeMode = QREncodeMode.Auto
b.QRErrorLevel = QRErrorLevel.LevelH
b.CodeText = "sometext"
b.ImageHeight = 150
b.ImageWidth = 150
b.Margins.Bottom = 1
b.Margins.Top = 1
b.Margins.Left = 1
b.Margins.Right = 1
b.GenerateBarCodeImage()
b.Save(‘c:\somefile.bmp’, System.Drawing.Imaging.ImageFormat.Bmp)

and now the code is placed to a PDF file:

Dim stamper As PdfFileStamp = New PdfFileStamp(_Template, PDFFileName)
TextStamp.BindImage(BmpFileName)
TextStamp.IsBackground = False
TextStamp.SetOrigin(x,y)
stamper.AddStamp(TextStamp)
stamper.Close()

The both orignal QRcode saved into BMP file and the one placed into PDF file are correct and recognizable

Hi Jiri,


Thanks for the information and sorry for the delayed response. First off, please note that since June-2011, Aspose.Pdf.Kit for .NET has been discontinued as a separate product and it has been merged with Aspose.Pdf for .NET. All the classes and enumerations of legacy Aspose.Pdf.Kit for .NET is now present under Aspose.Pdf.Facades namespace of Aspose.Pdf for .NET. Based on your query, I tested your provided source code against the latest builds of Aspose.Pdf and Aspose.BarCode product. I’m able to extract and recognize bar code images. Could you please try using the latest builds of Aspose components and let me know how it goes on your side? You can download the latest builds from here:
http://www.aspose.com/community/files/51/.net-components/aspose.pdf-for-.net/default.aspx
http://www.aspose.com/community/files/51/.net-components/aspose.barcode-for-.net/default.aspx

Second as a workaround you can set image size e.g. Stamp.SetImageSize ( System.Single width ,System.Single height). While stamping the image, you need to keep the same size as per original bar code image. Also, you can adjust the actual bar code size before stamping using custom bar code width support. Please visit the appropriate documentation links below:
http://www.aspose.com/docs/display/barcodenet/Generate+Barcode+Using+Custom+Width+Support
http://www.aspose.com/docs/display/pdfnet/Add+Image+Stamp+on+All+Pages+in+a+PDF+File+%28Facades%29

I hope this will help you. Please let us know in case of further assistance and comments.

Hi Jiri,


Thanks for your patience. Good news for you is BARCODENET-33502 has now been resolved and its fix will be included in the next version of Aspose.BarCode for .NET (5.6.0). Which is expected at the start of next week. We will inform you via this forum thread as soon as the new release is published.

The issues you have found earlier (filed as BARCODENET-33502) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.