Hi all,
Am trying to read barcode from products in a supermarket software, and parse it to get the barcode. I am using a scanner to scan the barcode image.
any ideas
thanks
Printable View
Hi all,
Am trying to read barcode from products in a supermarket software, and parse it to get the barcode. I am using a scanner to scan the barcode image.
any ideas
thanks
cool
The title of your thread (emphasis on "images") leads me to
think you that the source for your VB app is a .BMP file. Correct?
Spoo
use a barcode scanner?
cool
I haven't tried this, but perhaps one way is to analyze
the relative widths of the bars in your BMP to determine
the corresponding numeric value.
To do that, I'd probably put the BMP into a binary array.
Then, analyze one "row" of pixels. If it is a black and white
image, you'd only be getting (0, 0, 0) and (255, 255, 255)
triplets in the array.
Does that get you started?
Spoo
@westconn1
how do i read images or data from a barcode scanner?
@Spoo
each code has digitized meaning.How do i decode it?
can u give me sample code to do what u said cos i dont understand
You got me there! I'm looking at a bar code on a
pack of smokes. Different "bar width patterns" seem to
correspond to the digits shown below. Unless you can
find an explanation of barcodes somewhere, I guess
you'll need to figure that out yourself. This Wiki page might be a
place to start
Well, it is a little involved..
First, to get the file into a binary array, something like this
You will now have an array, aaBitData, that contains all of the BMP dataCode:ff = "c:\myfile.bmp" ' modify as needed to be your BMP file path
Close #1
Open ff For Binary as #1
flen = FileLen(ff)
Dim aaBitData() as Byte
ReDim aaBitData(flen)
Get #1, , aaBitData
Close #1
Second, you'll need to be able to interpret the BMP file properties
that are contained in the header section. It will give you, among
other things,
... the offset as to where the "image" begins, and
... how many pixels are contained in each "row" of data.
Holler if you are unable to figure this part out. I might be able to
come up with a link for you.
Spoo
most barcode scanners come with builtin code recognition, they work as an input device, some used to split into the keyboard cable, so programs just saw the input as if it had come from the keyboard
I'm not understanding any of this thread. Adding to what westconn1 said, a PS2 type scanner will input the text or alphanumeric data directly into any text editor that has the focus. This includes a TextBox on your form!
Guys
My assumption was that OP did not have such technology
and was trying to code such by brute force, starting just
with a BMP file.
Spoo
Barcode reading and coding, akin to OCR reading, is not a trivial process. There are over 20 types of 1D barcodes. Many considerations must be taken into account... including the DPI of the scan. Anything less than 150 DPI will usually give errors. 300 or 200 DPI is probably best.
There are many ActiveX and SDK's for barcode reading/writing. These usually are around $300-$500 with some available at over $1000. There is one free barcode reader SDK I'm aware of but it's accuracy is not great.
Google Bar Code Reader ActiveX SDK for more info. The link below is to a site that has a good 1D bar code reader ActiveX for just under $500 and it's royalty free.
http://www.gdpicture.com/products/pl...ecognition.php
Good Luck!
Tom
Spoo
Exactly, this is what am talking about. Although we would be using a handheld scanner later.
CDRIVE
Haha.. sometimes keeping it simple helps.
Now for the hard part.. can CoolCurrent derive any benefit
from using a binary array and reading the BMP file header
plus a "sample row".
Spoo
Can you post a sample image of the barcode you want to recognize ?
If the barcode is Code128, I can probably make a function to recognize it, it does not sound that difficult to me... The only problem is that I am not sure if I will actually have time to do it...
Since we are at this topic, I created this: VB6 - Code128 A,B and C
Thanks CVMicheal for sharing!
i saw your code, but i don't want restricted barcode reader. i want to develop somthing that will be able to read standard international barcode.
Any more ideas
Hi coolcurrent4u,
I should have said in my previous post, the code in that link is the opposite of what you need. That code generates the barcode in a picture...
What you are asking does not really make sense... there is no such thing as "standard international barcode".
Code128 is a very popular barcode, Code 39 is also popular, among other ones that I don't know the names, but you can find them is you search for Barcodes on the net.
The way I see it, you have 2 choises:
1) is to buy an already made tool to read the barcode from pictures, wich in the backgound it basically has algorithms to decode Code128 (+ the other barcodes).
Here is a link that found for example: http://www.ocrtools.com/fi/Default.aspx
There is a link "Try it out"
2) Build your own tool, where you implement the OCR's for Code128, Code 39, etc....
CVM
It appears that CoolCurrent is going for choice 2.
That is what I was trying to help him with when I proposed use of
the binary array and "reading the pixels" in a sample "row"
Spoo
Spoo
Can you do a sample project that will decode one of the printed barcode in CVMicheal image and give back the number that was use to encode it
CoolCurrent
No offense, but short answer is no !
However, I'll be glad to walk you through what I was proposing,
if you find that helpful.
Spoo
CoolCurrent
This link showing a BMP header format may help get you
started.
The key, it seems to me, is to find the image width in pixels.
That would then enable you to "read" one line of the bar code.
Some experimentation will be required, but if you play around
with the raw BMP file in Notepad, you should see quite a bit of
repetition (as each "row" of the barcode is repeated).
Lets say that the "barcode image" happens at offset 51
So, your binary array may look like:
aaBA(51) = 255 ' white
aaBA(52) = 0 ' black
aaBA(53) = 0
aaBA(54) = 255
etc...
I've simplified here... if I recall, there might actually be
3 array elements per pixel (to capture the R, G, and B).
The trick would be to find "narrow bars" and "wide bars", and
then establish which letter/number these patterns correspond to.
Not an easy job, but I think it would be doable.
Spoo
coolcurrent4u,
I could have made a sample for you if you would have given me what I asked you: A sample scanned picture !
The picture that I have in my post in the other thread is too "perfect" because it was generated by the computer, I need a picture that is actually scanned by you, that is imperfect.
Second, the approach to read the BMP directly is not good. Instead load the picture into a picturebox, and THEN read the image into a byte array. This way you are not limited to only BMP, you can also read jpg, and other formats that VB6 supports. But the byte array will always be in BMP byte array regardless of the input format.
You can use the code here to get the byte array of the picture:
http://www.vbforums.com/showpost.php...5&postcount=14
Copy that code into a module
This is a .NET component. Didn't see any COM version on this site and in their FAQ's is this question/answer:Quote:
The GDPicture web site link in post #12 offers both .NET and ActiveX (COM)Quote:
Question: Do your components work with VB 6.0?
We do not officially support our products in the VB 6.0 environment
here is a free one for code 39, with c source code available, maybe you can get some info from that
http://alumnus.caltech.edu/~josephc/barcode.html
also see this page for some more basic ideas by someone who has done
http://www.velocityreviews.com/forum...rom-image.html
That barcode is EAN-13, I tested it with this: http://www.bcgen.com/linear-barcode-creator.html
If you type "97800723981590000" in the Data to encode (the number in your barcode), and from the Barcode symbology drop down, select "EAN-13", you will get the same barcode you posted in the image.
Next step is to find information on how EAN-13 is generating the barcode, and then reverse engineer it...
Thanks, am makeing the app for customers, they may not know the type of Barcode their items contains.
Just want a means that i can use to help dem recognize their own products.
Scnanning and decoding it might help.
that is why i started this this thread
any more helo on the Next steps
Thanks, am making the app for customers, they may not know the type of Barcode their items contains.
Just want a means that i can use to help them recognize their own products.
Scanning and decoding it might help.
that is why i started this this thread
any more help on the Next steps
Did you do some research to find out how EAN-13 generates the barcode ?
I can start to make a sample for you to decode the Code 128 (since I am familiar with it), can try to find a barcode that is encoded with Code 128 and post the scanned image of it ?
Most barcoding for business is done by simply purchasing a hand held scanner. The scanner does all the work and sends the "text" back to your program. I do this all the time. I have worked with barcode scanners and VB6 for years. The reason for buying a scanner to do this work is pretty straight forward. To may times you can put all the time into the work to do one barcode and then some jerk on the other end decides to change the barcode they'be been using for years. With scanners most can read all kinds of barcodes, you just have to program them to enable some of non-default if it doesn't read it by default.
Scanners come in all kinds of types, flavors, and most of all costs.
What I would recommend is that you take example barcodes you want to scan and contact datalogic or symbol companies (Motorolla bought out symbol about year ago). Send them the images and they will decode and tell you exactly what type of symbol it is, and all it's characteristics.
You see, most hand held scanners can read many types of barcodes and a good portion of the barcodes have different characteristics that need to be setup. I would think a grocery store would most like be a simple UPC type barcode.
Most hand held, or for that much, even the type like you see in walmart that the product runs in front of, can be programmed to read any of many types of barcodes. Most by default to be able to read the standard code39, code 128 types of barcodes. Some times with some scanners you may have to enable UPC or related type barcodes along with setting their characteristics up. Most of this will come in the manual of the barcode, and if you do run into setup problems, symbol and datalogic both are outstanding in talking you through the steps.
Now for the types of scanners. I have and still do a lot of serial port scanners, but that is getting to be old school. I would look at a wedge(keyboard PS2 type) or straight USB scanner. The older wedge type I have had some issues in the past and I would recommend USB over the wedge at this point. The usb type acts just like a wedge in that once installed, which is usually plug and play or just a CD install, and you scan something it will decode and send the text result to the screen.
Now for the VB side. Since the text is getting sent to the screen (your program) you just always do things to keep focus on the text box you want the value to be entered in to.
Then it is best of you setup your scanner to have a suffix of char 13 or char 10 depending on what your scanner can setup the easiest. Then you have your text box's key press event monitor for the char 13 or 10 - this is like hitting the enter key.
That is pretty much it.
Also, CoolCurrent, there are free on-line barcode readers. You just upload an image containing the barcode and it returns the text in a window. Here's a fairly reliable site:
http://zxing.org/w/decode.jspx
Thanks Tom Moran
That code is java, and for mobile phones, i don't currently know how to translate java to Vb6.
Any help here?
Sorry, Cool. Can't help with Java Translation.
Have you looked at the Freeware barcode reader utility from Bytescout?
http://bytescout.com/barcodereader.html
Tom
Hello Tom Moran,
I downloaded the program above, but it dose not seem to work!!!
After downloading, i selected one of the picture (one in jpg format and the other in png format) i posted ealier, but the programs throws an exception.
The idea is that i have to read the picture into byes array according to #7
but what happens after then, i.e how to read each bar and decode its value is just what is the problem.
any more help here
thanks in advance
Cool
If by "according to #7" you mean "post #7", then I guess
you mean me.
I could possibly walk you thru the reading of a BMP file format
(which has no compression), but not a JPG or PNG (both of which
involve compression).
Spoo
I don