
This is a small application that can be fed the output video stream of a webcam, in which it can recognise and decode
code-39 barcodes.
It is simply a console application that is limited to parsing an input raw ppm stream, outputting the barcodes to the stdout.
Make sure you set up your camera so the barcode more or less completely fills the screen!
Not all cameras can focus well at this close distance, but I've had pretty good results with an old philips usb webcam with a manual-focus lens.
After building 'barcode' (and assuming you have ffmpeg installed and a working v4l setup), you can run the following command:
ffmpeg -an -s 640x480 -vcodec rawvideo -f pgmpipe - 2>/dev/null | ./a.out
This makes ffmpeg capture a video stream from your webcam, piping each frame in the raw grayscale format into the application.
I haven't run this application in quite a while so I'm not sure what the output format looked like, but basically whenever it can find a barcode on the screen it tries to decode it, outputs it in plain text. Since this program was mainly meant as a quick hack, it will contain numerous bugs, and if I recall collectly the length (in characters) of the barcode is somewhere fixed as a constant in the code. To do anything 'useful' with this application some hacking is be required.
To generate a postscript
test sheet you can run the included script:
./mksheet.sh > testsheet.ps
lpr testsheet.ps
This script depends on the
barcode package.
Sourcecode can be downloaded
here.
For another application that seems to be a bit more robust and a lot cleaner, check out
zebra.