Barcode (code 39) generation - c#

I've been looking for solutions and so far the best one I think for my project is to use a free Code 39 font. However, I've tried printing some samples and my barcode scanners can't read them.
I researched a bit more and stumbled upon this.
I printed Code 39 barcodes using that library and it worked just fine, the scanners are able to read them.
Problem is, the library is written in C# but not for ASP.net. I've tried playing around with the code but it's too complex for my basic knowledge. There are a lot of functions included in that library code and has a lot of other barcode types, making it harder for me to analyze.
Are there other ways to generate a Code 39 barcode? The library in codeproject seems a little to complex for my requirements.

Barcode scanners require your code 39 barcodes to be prefixed and suffixed with asterisks to read. Example: *12345*

First off, you say the library isn't written for ASP.NET, but if you can produce images with it then the easiest thing to do is write an HttpHandler that sits overtop of the library and returns the generated images to the browser. If it's a .NET library, I don't see any reason why that shouldn't work.
That being said, there are a couple things to look out for when generating Code39 barcodes:
Are you producing a valid Code39 barcode (see other answers, a Code39 barcode should start and end with *)?
Is the barcode you are printing sharp enough to be scanned?
For #1, I would check to make sure the images you are printing from your Code39 font look the same as the ones from the library. If they are, then image quality is probably the issue.
As far as #2 goes, I've successfully used a free Code 39 font with GDI+ to generate barcode images that I then displayed in HTML pages for printing. One of the problems I ran into when trying to scan the printed barcode images was that the images were not sharp enough (the edges of the barcode lines were blurry) and were not able to be read by the scanners.
The way I got around low quality images was to generate a large Code39 barcode image (say 1000 x 400), and then on the <img> tag that was displaying that barcode, I would set the width to something much smaller, say (200px, or 2.0 in). I would be sure to set only the width, the height will scale proportionally with the image. That would effectively increase the DPI of the image when it is printed, allowing us to produce barcode images that are easily able to be scanned (especially if you are printing using a laser printer).
EDIT
Almost forgot, one other good practice to use when generating these barcodes is to always print what you are barcoding underneath the barcode image. That's your failsafe in case the barcode image will not scan for whatever reason. You can see an example of this if you look at any standard UPC symbol. The numbers at the bottom are exactly what the barcode will read when it is scanned.

Related

Tesseract OCR C#: Training the network for unknown font

So I am using Tesseract with C# to read english text and it works like a charm. I use pre-trained data from the tesseract repo:https://github.com/tesseract-ocr/tessdata
So far, so good. However, I fail to understand how to solve the following situation: I have an image with a maximum of three numbers on it:
I also followed this tutorial in order to train my own data but I failed to understand what exactly I am doing mid-way:https://pretius.com/how-to-prepare-training-files-for-tesseract-ocr-and-improve-characters-recognition/
In this tutorial, they used some existing font and train their network accordingly. However, I do not know what this font is. I tried to figure it out myself but was overwhelmed by the huge amount of information about tesseract and actually do not have any idea where to start.
I was wondering if the following would be possible: I have lots of pictures looking like that(in fact, every possible character with every possible color, only difference is that the background is different):
etc...
And with those pictures, I want to train the network, without using any existing font files.
My algorithm right now does not use tesseract, it just screenshots the position of the numbers and I compare pixel-wise. I do not like this appoach though, as the accuracy is something like 60%.
Thanks for your help in advance

Can barcode Misread code?

in my asp.net mvc application on Register Form when users are using barcode scanner to insert data to textbox ,they say that it misses some portion of code like if they scan 02501603566 they get 02501602566 or 01301103564 can be 01301403564 after register.can barcode misread some data? i tested on my barcode and everything works fine.customers have big amount of data so they cant check every time what they have scanned in input.this can happen 1 times in 100..
Yes its not only possible that a scanner misreads are barcode, it definitely happens. 1D barcodes are the worst, but also cheap readers and readers configured improperly for the type of barcode being read can also be a problem.
If you are in control of the code, use a barcode with the appropriate error checking (and there are many).
Also check your barcode reader settings (they all have them).
If all else fails check the barcode with a different scanner or barcode reader app and check if its the fault tolerance of the scanner itself.
Misreads in the form of a perfectly scanning but wrong barcode can be
caused by scanner number substitution
Somehow the printed barcode image is wrongly decoded by the scanner. A poor quality printed barcode can contribute to this, but barcode structure also contributes. UPC is notoriously vulnerable to number substitution of 1 and 7, and 2 and 8 characters
Low ISO Decodability scores can contribute to barcode misreads,
especially when they are caused by pixel rounding in the print process
This is most common in a thermal or thermal transfer printing but it can also occur in ink jet, DOD and other digital printing systems
Scanners can also misread otherwise acceptable barcodes. Most often
the cause can be traced to damaged or dirty optics, but faulty decode
algorithms area known cause, albeit a rare one
Older, high-mileage scanners such as lasers tend to be more prone to misreads than newer, more sophisticated digital area imager scanners.
If a calibrated, ISO compliant verifier decodes and assigns an acceptable grade to a misreading barcode, one can be confident the cause lies with the scanner and not the barcode itself. This is yet another example of how a scanner cannot effectively serve as a verifier

How to OCR email address

I am trying to OCR and extract the email form the images. The images are supposed to have one line of text which is the email address.
I am using EmguCV.OCR to extract the text (email address) from those images. The target is to have 100% accurate result.
We can fix the font and size of the text. For example Ariel, 12pt, so that all the images will have email written in Ariel 12pt with black on white background.
The problem is that Tesseract OCR in EmguCV is not recognizing the text properly. It recognizes only 80% of the characters accurately.
I am using preprocessing with Leptonica library.
Here are some sample images I am trying to recognize.
Is there any way to achieve the target of 100% accuracy
With those sample images I can suggest two ways to solve the same problem. In those images JPEG artifacts are present (the result of lossy compression). Because of this, the letters are becoming connected to each other (zoom in on the image in a program where you can see the actual pixels, windows photo viewer worked fine for me). TesseractOCR relies on spacing between letters (it uses connected components) to do character recognition. Have any pieces connected throws off the recognition process which means it tries to recognize the combination of "co" as one letter.
Two possible solutions:
I'm not sure what preprocessing steps are already being done, but you'll want to do some thresholding to removing the lighter shades on the image (disconnecting the characters). However, you have to be careful with this as it may remove more than what you want.
If at any time during this process you have a higher resolution image, or a non-jpeg/lossy format (i.e. png), then keep it in this format as you do other processing steps. Try to avoid any lossy compression that might happen. It sounds like these images don't come to you as shown above. This is the preferable solution as you wont risk losing too data.
I tried to recognize your images with ABBYY Cloud OCR SDK and got 100% accuracy.
You can use Demo Tool to make sure of recognition accuracy.
I work for ABBYY and can give you more information about our technologies if you need.

How to search for famous logo in scanned image?

I have following scanned document, with the logo on it, and I have another black and white image with same logo and style (Shown in black and white color below).
How do I make sure that the logo is present on this image or not?
Usually I will have many scanned documents, OCR will pickup MTNL, but sometimes these logos are just made up of symbols not recognized easily by OCR.
Size and position of logos change, they are not fixed many times. They may be placed anywhere on the document.
I want to organize and catalog scanned images based on the logos and symbols present. Most documents may or may not be in english, may or may not contain any bar codes, in such case logo match will help.
I have seen Aforge.NET library, but I am not very much sure which methods to combine to do search. Pixels search is very slow and fails if source destination are of different size.
I have heard that YouTube does some sort of Histogram or Heat Signature match to see if the video contains any copyrighted material. I will be helpful if someone can guide me in this case.
My ideal choice would be C# and Aforge.NET, otherwise some command line tool will be appreciated.
You can try using Aforge.net
Check these links
1) http://www.aforgenet.com/articles/shape_checker/
2) http://www.codeproject.com/Articles/9727/Image-Processing-Lab-in-C
3) http://www.aforgenet.com/forum/viewtopic.php?f=4&t=323
Detect useful features in your logo image, and look for those features in the scanned document. SIFT is a useful feature descriptor that is scale and rotation invariant. Other descriptors include SURF and HOG.
If you look around, there will be plenty of implementations, some of them even in C#.
You can use this small utility:
https://github.com/remdex/logoDetect
It worked for me. Perhaps it will work for you also.

Barcode 128 size restrictions. Most compact barcode font?

I am generating a barcode label and sending it to the user as a .pdf (this is a web app). The user has already purchased barcode labels that are only 2 inches wide. I want to use an image so that I don't have to install fonts on all of the users machines that will be using the web site. I am able to get the barcodes small enough if I use fonts from IDeautomation.com but I would much rather use an image generated using BarCodeRenderer
or some other opensource project but I can not get the barcodes small enough as the system has pre-existing ID's of around 20 characters in length. What is the smallest Barcode font (I am trying to use 128 as the IDS are alphanumeric) and how can I resize the generated image in a way to make it fit in the width that I have available?(Other ideas or Libraries that do this are also accepted as answers)
IDautomation has several products.
Specifically they have one for Crystal reports with a Code 128 checksum calculator. It bypasses the need for a font and generates the font right in the report, which can go straight to PDF. The smallest size I have been able to use this feature is at about 12 point font. Specifically they have broken down the Code 128 font spec to allow you the smallest barcodes possible. This does not render as a font, or an image as far as I recall.
Alternatively I recall them having a product that will render a font as an image.
Another product that might be useful is Barbeque. Maybe you can find something along that line.
The other factors that weigh in when trying to print and read small barcodes are:
How long is the value that you are encoding in the barcode. 20 Characters is a lot.. Is there any way you can concatenate it, or shrink it somehow? Tricks I have used in the past include using a hashed value (or record number) that would link to all the values I needed. The shorter you can get your barcode, the smaller you can make it and still have it super clear.
Will the barcode get longer over time? If so, you might need a wider label, or consider a different format. I am starting to like a few of the 2D barcodes a lot.
Label material. I have seen issues with using colored or overly shiny labels instead of white, matte ones making it much harder to read.
The barcode readers can make a big difference. Having a laser based reader instead of an optical based one will give you greater resolution in reading barcodes. This means you can read them from further away, or read smaller ones. Symbol has some great $150 laser based barcode scanners.
The bar code printing and reading systems I've worked on have done in the range of a few million prints and reads with barcodes of small to medium sizes, so I hope some of the suffering and learning I've had above helps!
What I've done is to take the barcode and make it fit the width that I want by resizing it down. What then happens is that the height is not good enough for most readers, so I copy the image and duplicated it above it, so it now is the width I want and double the height of the generator. That makes it more readable to most common off-the-shelf barcode readers.
If your barcodes only consist of an even number of numeric digits, you can quite easily switch to the Code C variant to get them down to half the size.
Generating a small barcode as an image in a PDF is going to be error prone, since you can't optimize to the dot size of the printer. Your barcode widths are going to be off by plus or minus half a dot; the wider your bars are, the less of an issue this will be. I've worked with label printers that are 203 DPI, and they would be nearly impossible to support with a generic image. Fonts are better since they can be hinted to be an exact multiple of dots. I don't know if any of the commercial barcode fonts have the necessary hinting, but I presume at least one of them does.
I have had good luck using Data Matrix format as you can have varying amounts of data, and you can size the barcode as you wish.
Here are some links that may help:
libdmtx
Aspose.BarCode for .NET and Java
Barcode Writer in Pure PostScript
The checkbox "Use Unicode UTF-8 for worldwide language support" should not be checked.

Categories

Resources