i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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.
@Spoo
each code has digitized meaning.How do i decode it?
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
Originally Posted by coolcurrent4u
can u give me sample code to do what u said cos i dont understand
Well, it is a little involved..
First, to get the file into a binary array, something like this
Code:
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
You will now have an array, aaBitData, that contains all of the BMP data
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.
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 do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
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
Then I'm even more confused because this is from CoolCurrent's first post.
I am using a scanner to scan the barcode image.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
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.
Then I'm even more confused because this is from CoolCurrent's first post.
Quote:
I am using a scanner to scan the barcode image.
Yes... I suppose it comes down to the meaning of "scanner"
I simplisticly assumed CoolCurrent was referring to a desktop-like
device such as a printer/scanner, as opposed to a retail store's
checkout line hand-held scanner.
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.
Yes... I suppose it comes down to the meaning of "scanner"
I simplisticly assumed CoolCurrent was referring to a desktop-like
device such as a printer/scanner, as opposed to a retail store's
checkout line hand-held scanner.
Spoo
Well Spoo, it would appear that you have assumed correctly!
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing??
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...
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....
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.
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.
Last edited by westconn1; Feb 8th, 2010 at 03:16 AM.
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case. Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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.
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...
Last edited by CVMichael; Feb 8th, 2010 at 10:19 AM.
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
Programming is all about good logic. Spend more time here
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 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
Last edited by coolcurrent4u; Feb 14th, 2010 at 10:01 AM.
Programming is all about good logic. Spend more time here
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 ?
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 ?
Here are som from my HP printers
Programming is all about good logic. Spend more time here
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.
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:
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
Programming is all about good logic. Spend more time here