Jump to content
heng1991

Barcode decoder by using Labview

Recommended Posts

Hi, since in the forum we do have the QR code generator. I would like to ask does anyone know how to make a barcode decoder for both code 39 and QR code by using Labview?

Decode the code by using the image captured by the webcam.

Does anyone know where can I get any .dll library or zxing library that can be use to decode the both type of code?

 

http://www.onbarcode.com/products/net_barcode_reader/barcodes/code39.html

This link do provide the .dll library, but only free for 30 days.

 

https://code.google.com/p/zxing/

This link do provide some of the libraries, but I do face some problems when trying to implement it by using LabView.

 

And here are some other references:

http://www.idealsoftware.com/opensource/scan-1d-2d-barcodes-webcam-zxing-opencv-visual-c.html

http://www.summitsystemsinc.com/programming/qr-code-with-labview/

http://stackoverflow.com/questions/9013703/how-to-find-the-location-of-red-region-in-an-image-using-matlab/9014569#9014569

 

Yes, LabView do provide the both the 1D and 2D decoder in the Vision Development Module, but that one is a licensed software, that means we need to pay.

 

I hope we can work together to solve for this problem.

Share this post


Link to post
Share on other sites

It looks like there is a .NET version of the ZXing. I think that would by my first approach.

 

I would take a look at one of the C# examples and recreate it in labview.

  • Like 1

Share this post


Link to post
Share on other sites

Nice! I expected it would be something simple like that. Didn't have time to investigate myself.

 

Only thing I'll add is that you need to close your references to all of your .Net objects (i count 3, Barcode reader, bitmap and results)

 

I love when a .NET object does exactly what you need it to.

Share this post


Link to post
Share on other sites
I think the price of the zxing lib is much better...

You wouldn't say that if you worked at Onbarcode.com

  • Like 1

Share this post


Link to post
Share on other sites
Phillip, if you don'd mind, can you send me your VI of that one using the zxing library?

Do you think that adding the VIs that undergo the binarization and image filter to the image before decoding will be better?

Share this post


Link to post
Share on other sites
I think the price of the zxing lib is much better...

 

Yeah, for some reason these guys seem to spamming both LAVA and the NI forums recently with these supposedly authentic and off the street one-time posters who point to different sites which look similar, but all offer barcode utilities for pay.

Share this post


Link to post
Share on other sites

Philip.... I had built in the labview... since my image is already in the bitmap format...

so what first come into my mind is that whether i can directly send the .bmp image to decode instead of passing through the bitmap .net constructor (actually i can't find it in my zxing.dll... i am using .net3.5 version...)

But it will result in the broken wire.... when i try to connect like this way.... And can i do with this way? As my webcam can capture the image in the .bmp format, so i think if i can connect like this, it may be better....

And i do have another question, does the zxing library provide the barcode detection and localization function?

 

http://s292.photobucket.com/user/heng1991/media/broken-wire.png.html?filters[user]=72164204&filters[recent]=1&sort=1&o=1 (i cant use the image extension... please click in the link below to see the image of the problem... please)

 

And this is one of the example of the barcode that i used to decode... I am looking through a few of the articles regarding how to localize the barcode.... but i still blur with some the concept for it.....

 

http://s292.photobucket.com/user/heng1991/media/Image2013_07_19_091904848.png.html?filters[user]=72164204&filters[recent]=1&sort=1&o=0

 

Here are some of the articles:

http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2898214/

http://www.ski.org/Rehab/Coughlan_lab/BLaDE/BLaDE_TechReport.pdf

http://www.ski.org/Rehab/Coughlan_lab/General/Publications/WACV09-barcode.pdf

http://www.slideshare.net/VladimirKulyukin/an-eyesfree-visionbased-upc-and-msi-barcode-localization-and-decoding-algorithm-for-mobile-phones

Share this post


Link to post
Share on other sites

The Bitmap constructor is part of .net, not the zxing lib; look for System.Drawing.Bitmap

 

If your webcam exports an image, you would have to convert that to a bitmap or look through the zxing API for a method that accepts an image.

 

I played around with rotating my 1D barcodes and found that if you cannot draw a horizontal or vertical line that passes through all of the elements of the barcode, you will fail to decode. 2D QR codes worked without a problem.

 

The decode method returns a Result object; use the properties to retrieve the result points and metadata. You might need to iterate over the metadata object to get the key/value pairs.

 

I've attached the VI with the all of the .NET closes as pointed out in the thread. I still work in LV 8.6 and that is limited to .NET 2.0 so that's what I've posted here.

 

Place it in the same folder as the zxing .net 2.0 DLL and it should 'just work'.

 

 

 

 

zxing.net Read Barcode.vi

  • Like 1

Share this post


Link to post
Share on other sites

yeah.... thanks a lots, Philip~~

i had tried on the VI by using the webcam to capture the images.... but i found out there's something weird....

There is a barcode that i keep cant decode... even i increased the contrast, increased the sharpness, reduced the saturation of the picture... i still cant decode it....

i have use the other licensed software to decode it too.... but seem like most of them take quite a long time to decode... .and most of times the value that those softwares give to me is the wrong value.... only 1 decoder software done it with less error occur.... the zbar barcode decoder..... the value of the barcode should be 18572E5 (code 39)....

Do you know how to solve this problem? Should I add binarization, skeletonization and any others function? I thought by grayscaling the image is enough to decode it....

 

And here are the pictures that i am taken.....

 

Untitled32.png

Barcode-1.png

Barcode.png

Share this post


Link to post
Share on other sites

There appears to be very little label after the barcode (left side in your image).

 

There are quiet zone specifications for all barcodes; maybe this one does not meet spec.

 

I opened the first image first using MS Office picture manager where I increased the contrast. I then opened it in ms-paint and deleted the dark region at the left (surface label was placed on). This effectively created a larger quiet zone and then zxing decoded the barcode...

 

I didn't have to flip the image once I increased the quiet zone.

 

post-949-0-42318400-1374578154.png

Edited by Phillip Brooks
  • Like 1

Share this post


Link to post
Share on other sites

Phillip~ really thanks again to you~ really is the problem of the quiet region~

Now i am thinking the solution for it.... Can I increase the quiet region by adding white space on both side of the barcode?

Since i need to 10 X the dimension of the narrowest element in the bar code~

 

And i am wondering, what's the main differences between the Zxing and Zbar, since both library can used to decode the barcode?

Is it the method use to decode the barcodes is different for both of them? Because I found out that when i am using the barcode reader software (using the Zbar library), it can decode the barcode that i posted... and on the picture there, the Zbar barcode reader do label the starting and the ending position in the barcode...

But Zbar barcode reader currently do not provide any library in .net assembly....

Edited by heng1991

Share this post


Link to post
Share on other sites

It looks like you are learning quickly about barcodes. I'm no expert, just a lot of (bad) experiences with 2D scanners and printers.

 

I downloaded the .NET zxing because I was curious, and happen to like .NET solutions to LV problems. This one worked with very little effort, and I may even look at replacing some of my 2d scanners with webcams on my next test setup.

 

It looks like the zbar lib uses a bunch of other libs to run under Windows, not sure that I would want to have all those dependancies/version problems in the future.

 

As far as the image with insufficient quiet zone, I see that as a failure of the provider of the code to follow standards. If I was "hacking" or needed to compensate for a case that I new I would have to continue supporting (supplier/vendor wouldn't fix the barcode) then I might dig in more and look for parameters for tweaking the quiet area, but I don't need to  :P 

Share this post


Link to post
Share on other sites

Hello Phillip.

 

I'm trying to use your code with a Matrix Code.

 

1.- I'm taking the picture from a USB WEB cam with very good quality, but I'm getting the Image as "Image Data Type", how can I covert that to System.Drawing.Bitmap?

2.- I tried saving the image to a file (jpg or bmp), but still no data out..

http://forums.ni.com/ni/attachments/ni/170/803110/1/2D%20Code.jpg

I added a jpg of my picture2D%20Code.jpg

 

 

Thank you guys...

Share this post


Link to post
Share on other sites

Post some code.  I can't be sure the data type you are working with, or what you are trying based on your description but I think I know a way to go from the LabVIEW image data type to a system stream image in .NET.

Share this post


Link to post
Share on other sites

here you go..

 

Please rename zxing.txt to zxing.dll

 

you going to need file "AForge.NET Framework-2.2.5.exe" from 

http://www.aforgenet.com/aforge/framework/

 

 

 

 



1.- Change zxing extension to .dll

2.- Install AForge.NET Framework-2.2.5.exe

3.- open ReadSerialAForge-Sample.vi

 

event.vi

ReadSerialAForge-Sample.vi

zxing.txt

zxing.net Read Barcode.vi

Share this post


Link to post
Share on other sites

I know it's quite old, but I'm trying to get image from the web cam from your VI readAForge-sample.vi.

When I open it, it's a broken VI.

Is it possible to have any help on this?

Thanks

Share this post


Link to post
Share on other sites
On 7/16/2013 at 6:58 PM, Phillip Brooks said:

I downloaded the .NET zxing lib and was able to use the 2.0 version to create a VI that reads various bar code image files downloaded frmo a google search with very little effort.

 

zxing.net dotnet 2.0 LabVIEW Read Barcode.png

I'm using this code but it seems to keep the BMP file open until the VI closes. Anyone know how to close the file so I can delete it?

Share this post


Link to post
Share on other sites

You aren't cleaning up your references at all.  On top of holding onto the file you likely would have memory leaks.  Close all the references you open when you are done with them.  There are some functions that also have a dispose method so you may want to see if those are appropriate for releasing reference too.

Share this post


Link to post
Share on other sites

Hi Hoovahh,

Thanks!! - I am actually closing the 3 references in my code (I just quoted the image from here) - here's my code below. How do I locate the dispose method? This might be what I need. Is that a .NET method like the Bitmap

 

barc.png

Share this post


Link to post
Share on other sites

Just look through the list of methods for a given reference using an invoke node.  I've used the Bitmap .Net before a few times and I don't remember having to do anything else to release a file from being held by an application.

Share this post


Link to post
Share on other sites

Hooovahh, thanks for the tip! Using the dispose node fixed the problem. Bitmap does not release the files without it (unless the Vi stops). Thanks!!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.