Biatu

Webcam Barcode Reader using ZXing.

16 posts in this topic

#1 ·  Posted (edited)

I was trying to find a good way to read barcodes, but there were not many I could find without going through the pain of recompiling, or spend +$299 for just reading.

Makes use of:

 -WebcamDS_UDF by frank10

 -_WinAPI_ClearConsole by rover
-FastFind by FastFrench, frank10

Note, this requires java so far, and this script is not yet optimized.

It currently supports the following barcodes:

-Aztec Code (Full support as far as i can see!)

-Code 128 (ISO 15417, seems to only support 12 digits.)

-Code 39 (ISO 16388, Seems to be limited to, 0-9, aA-zZ, 5 digits.)
-Code 93 (Mostly A-Z, 0-9, Special Characters act odd)

-Databar
-Data Matrix(ISO 16022, seems to be fully supported)

-ITF 14
-PDF417

-QR Code
-UPC-A

-UPC-E

-EAN 14 (Reads as Code 128)

Tested with Microsoft HD 5000 Webcam.
Used Zint Barcode generator, DL License, Various random other barcodes for testing.

Latest Version (2013.06.16):

http://www.mediafire.com/download/15ykljpfbsbzfox/BarcodeReader.7z

Edit:
Updated URL

Enjoy

Edited by Biatu
1 person likes this

What is what? What is what.

Share this post


Link to post
Share on other sites



#5 ·  Posted (edited)

Why not use some free version of barcode reader on google?

This one is free, opensource, and you can use autoit to parse the information. I already built a decoder that read the PDF-417 barcode on the back of a driver's license. it was of use to me, might be of use to someone else that wants to do something with the data. I have no reason to improve this program either...unless that is someone finds it useful. :/

Edited by Biatu

What is what? What is what.

Share this post


Link to post
Share on other sites

Too many hoops to jump through with mediafire, upload to dropbox or similar filesharing please.


2015 - Still no flying cars, instead blankets with sleeves.

Share this post


Link to post
Share on other sites

cannot download from mediafire, please upload to other filesharing. thank you

Share this post


Link to post
Share on other sites

Do you have any kind of instructions on how to make it actually output something ? I get the webcam image, point to a supported code (datamatrix) and nothing happens ?

I do not have the mentioned drivers license with PDF417 code...


I am just a hobby programmer, and nothing great to publish right now.

Share this post


Link to post
Share on other sites

okey but webcam udf dont work why?

Share this post


Link to post
Share on other sites

DropBox Link: https://www.dropbox.com/s/ex4lwibeeo78juj/BarcodeReader.7z

 

okey but webcam udf dont work why?

What do you mean? I would need to know what the issue is.

 

Do you have any kind of instructions on how to make it actually output something ? I get the webcam image, point to a supported code (datamatrix) and nothing happens ?

I do not have the mentioned drivers license with PDF417 code...

The app works by taking various snapshots, then piping that data into the zxing java applet. The information should be shown on the console window.
I will run some tests and try some different barcodes to see if there are any bugs i missed


What is what? What is what.

Share this post


Link to post
Share on other sites

#11 ·  Posted

okey but webcam udf dont work why?

​Sorry for extremely late reply but the reason the webcam udf dont work is because its coded to open the webcam in 1280x720 with a 24bpp


What is what? What is what.

Share this post


Link to post
Share on other sites

Do you have any kind of instructions on how to make it actually output something ?

​Looks pretty cool but ^^

Share this post


Link to post
Share on other sites

Do you have any kind of instructions on how to make it actually output something ?

​Looks pretty cool but ^^

Share this post


Link to post
Share on other sites

Thanks a lot for sharing it with us. I need to take a look at it because I need to use the built in webcam of a tablet as qr reader inside one aplication.

 

Greets from Barcelona

Share this post


Link to post
Share on other sites

I have edited the code from Biatu for my pourposes and I would like to share it with you.

Maybe someone could find it necessary.

Some of the changes are:

-In my app I don't want to have a huge webcam screen (just a little region where the code will be readed), but without zooming or loosing resolution.

-I do not need to change between cameras, I'm always going to use the same video device, so the selection combobox is gone

-I'm going to decode the codes with a dll calling (I don't know if it works faster than the java solution)

 

This is a ripped version of my script:

#include <Misc.au3>
#include <Memory.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
#include ".\Data\WebcamDS_UDF.au3"
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <GUIConstants.au3>


Global $camnumber = 1;in my case I do not need to cange between cameras, I'm always going to use the rear camera of a tablet pc
;the camera index starts by 1. If you have a laptop with one built-in camera and an external usb camera you have to set the desired
;one changing te value of this variable.
Global $UserDLL = DllOpen("user32.dll")
Global Const $QR = @ScriptDir & '\Data\temp.bmp'
Global $msg

Opt("MustDeclareVars", 1)


_WebcamDS_Init()
Global $hGUI = GUICreate("QR Reading", 300, 300);;set gui size according to the size of the codes that you are going to read

GUISetState()


_WebcamDS_RenderWebcam($camnumber, 0, $hGUI, 0, 640, 480, 16)
;The third parameter can be a zero (the image of the webcam will be cropped, so the size of the window needed to decode codes doesn't need
;to be as big as the full resolution of the camera)

;_WebcamDS_RenderWebcam($camnumber, 0, $hGUI, 0, 1280, 720, 24);if you have an hd cam then you might better use this resolution

AdlibRegister("Snapper", 500)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            _WebcamDS_ReleaseObjects(1)
            DllClose($UserDLL)
            FileDelete($QR)
            Exit
    EndSelect
WEnd


Func Snapper()
    _ScreenCapture_CaptureWnd($QR, $hGUI, 0, 0, -1, -1, False); we take a picture of the gui with the video stream only. It increases the performance
    Local $hDll = DllOpen(@ScriptDir & '\Data\QRCodeDecodeDll.dll')
    Local $Ret = DllCall($hDll, 'ptr', 'QRCodeDecodeImageFile', 'str', $QR, 'int*', 0)
    If $Ret[0] Then
        Local $data = BinaryToString(StringToBinary(_WinAPI_GetString(DllStructGetData(DllStructCreate('ptr', $Ret[0]), 1), 0), 1), 4)
        ConsoleWrite($data & @CRLF)
        DllCall($hDll, 'none', 'QRCodeFree', 'ptr', $Ret[0], 'int', $Ret[2])
    EndIf
    DllClose($hDll)
EndFunc   ;==>Snapper

Func _Exit()
    _WebcamDS_ReleaseObjects(1)
    DllClose($UserDLL)
    FileDelete($QR)
    Exit
EndFunc   ;==>_Exit

The dll that does the decoding comes from here: http://www.aipsys.com/sdk-download/by-platform/sdk-for-microsoft-windows.html

There is an dll for every kind of code, so, in my aplication I only need the qr dll. If you need more than one then you have to try some other solutions.

All credits must go to this thread in a russian autoit forum: http://autoit-script.ru/index.php?SESSIONID=2371sci0hqd9s8v3fslf429fh5&topic=10872.msg71688#msg71688 (I don't know if he is the same Yashied from here, anyway thanks!)

 

Greets from Barcelona

QR.zip

1 person likes this

Share this post


Link to post
Share on other sites

I have edited the code from Biatu for my pourposes and I would like to share it with you.

Maybe someone could find it necessary.

Some of the changes are:

-In my app I don't want to have a huge webcam screen (just a little region where the code will be readed), but without zooming or loosing resolution.

-I do not need to change between cameras, I'm always going to use the same video device, so the selection combobox is gone

-I'm going to decode the codes with a dll calling (I don't know if it works faster than the java solution)

 

This is a ripped version of my script:

#include <Misc.au3>
#include <Memory.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
#include ".\Data\WebcamDS_UDF.au3"
#include <Constants.au3>
#include <ScreenCapture.au3>
#include <GUIConstants.au3>


Global $camnumber = 1;in my case I do not need to cange between cameras, I'm always going to use the rear camera of a tablet pc
;the camera index starts by 1. If you have a laptop with one built-in camera and an external usb camera you have to set the desired
;one changing te value of this variable.
Global $UserDLL = DllOpen("user32.dll")
Global Const $QR = @ScriptDir & '\Data\temp.bmp'
Global $msg

Opt("MustDeclareVars", 1)


_WebcamDS_Init()
Global $hGUI = GUICreate("QR Reading", 300, 300);;set gui size according to the size of the codes that you are going to read

GUISetState()


_WebcamDS_RenderWebcam($camnumber, 0, $hGUI, 0, 640, 480, 16)
;The third parameter can be a zero (the image of the webcam will be cropped, so the size of the window needed to decode codes doesn't need
;to be as big as the full resolution of the camera)

;_WebcamDS_RenderWebcam($camnumber, 0, $hGUI, 0, 1280, 720, 24);if you have an hd cam then you might better use this resolution

AdlibRegister("Snapper", 500)

GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            GUIDelete()
            _WebcamDS_ReleaseObjects(1)
            DllClose($UserDLL)
            FileDelete($QR)
            Exit
    EndSelect
WEnd


Func Snapper()
    _ScreenCapture_CaptureWnd($QR, $hGUI, 0, 0, -1, -1, False); we take a picture of the gui with the video stream only. It increases the performance
    Local $hDll = DllOpen(@ScriptDir & '\Data\QRCodeDecodeDll.dll')
    Local $Ret = DllCall($hDll, 'ptr', 'QRCodeDecodeImageFile', 'str', $QR, 'int*', 0)
    If $Ret[0] Then
        Local $data = BinaryToString(StringToBinary(_WinAPI_GetString(DllStructGetData(DllStructCreate('ptr', $Ret[0]), 1), 0), 1), 4)
        ConsoleWrite($data & @CRLF)
        DllCall($hDll, 'none', 'QRCodeFree', 'ptr', $Ret[0], 'int', $Ret[2])
    EndIf
    DllClose($hDll)
EndFunc   ;==>Snapper

Func _Exit()
    _WebcamDS_ReleaseObjects(1)
    DllClose($UserDLL)
    FileDelete($QR)
    Exit
EndFunc   ;==>_Exit

The dll that does the decoding comes from here: http://www.aipsys.com/sdk-download/by-platform/sdk-for-microsoft-windows.html

There is an dll for every kind of code, so, in my aplication I only need the qr dll. If you need more than one then you have to try some other solutions.

All credits must go to this thread in a russian autoit forum: http://autoit-script.ru/index.php?SESSIONID=2371sci0hqd9s8v3fslf429fh5&topic=10872.msg71688#msg71688 (I don't know if he is the same Yashied from here, anyway thanks!)

 

Greets from Barcelona

QR.zip

Very good. Dll is definately better. However at the time of coding this, I was looking for a way to use a dll from zxing to decode all kinds of barcodes I throw at it, but I couldn't find a way to implement the Dll calls, nor a way to work without a temporary file. So I used java as a fallback.


What is what? What is what.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now