Author Topic: Webcam Barcode Reader  (Read 9550 times)

0 Members and 1 Guest are viewing this topic.

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Webcam Barcode Reader
« on: January 16, 2012 »
I am making more progress with my barcode scanner.

It's a bit fiddly, but the diagnostic line in the image which reads "3211,1222,1222..." is correctly returning groups of numbers which add up to 7, so the next stage is to convert these number groups into decimal characters, and the data will be successfully obtained from the image.

 :updance:

(Mega-Update)

After an hours tinkering, I have combined this with my barcodebattler.co.uk Barcode Generator. Just visit my site, then click on "Technical", then "Generator", and you can see what sort of powers your barcodes will have on a Barcode Battler, simply by showing your barcodes to a webcam. ;D
« Last Edit: January 19, 2012 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Webcam Barcode Reader
« Reply #1 on: January 16, 2012 »
Cool stuff CK. Are you planning to make a barcode game with this?
raizor

Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Webcam Barcode Reader
« Reply #2 on: January 16, 2012 »
Awesome you got the thing working, that's pretty cool!  :clap:

I heard you about barcode battler before but I'm still unsure how it will work exactly. It seems like a really interesting concept though.

Also I've been reading up on barcodes a while back, as I was thinking about a barcode tatoo which them supermarket scanners can read. But it turned out there are a lot of different barcode types being used. What kind of barcode does this program use and do you know if barcodes are the same across country's, regions, markets or stores?
« Last Edit: January 16, 2012 by Kirl »
www.kirl.nl
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Webcam Barcode Reader
« Reply #3 on: January 16, 2012 »
Box of cornflakes defeats packet of Rizlas! Winner!!
raizor

Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #4 on: January 16, 2012 »
@ Raizor: Exactly :)

I'll try to remake the original Barcode Battler as well as using it for an original game of my own.

@ Kirl: Most supermarket scanners across the world will use the EAN-13 or EAN-8 standards.
You are our 9001st visitor.
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Webcam Barcode Reader
« Reply #5 on: January 16, 2012 »
Will there be some visuals and how will this play out?

Is the barcode used as some sort of XP or does it determine a static win/lose scenario? It would be cool if you could let multiple products batlle it out with eachother in some sort of arena. Bit like pokemon with products, it's the ultimate consumore game but I really like the concept...!


www.kirl.nl
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #6 on: January 16, 2012 »
The classic version will have similar "graphics" to the originals, with images of the characters on the cards or from the manual for added effect.

My newer games will use the barcodes in a similar way, but with animated graphics for attacks / effects.

Some barcodes will be interpreted as heroes / monsters, and others will be items for increasing (or decreasing :o ) certain stats such as health, attack, defense, speed, accuracy and evasion.

Many barcodes will represent the same hero or monster, but there will be stat differences for each barcode.

Online play against another user with a webcam is also a possibility.

Winning or losing will be down to a combination of how strong the character is, and which attacks / effects are used by the player.

I also had planned a top-down RPG in a similar style to the Gameboy Pokemon games, which will incorporate barcodes in some way, but I haven't planned how.

I'm also thinking of making a turn based game involving tanks - build a tank out of the pieces you find in your barcodes (chassis, armour, cannon, engine, etc) and battle against somebody else's tank. The winner gets to keep one part they like from the loser's tank to upgrade their own :kewl: It's a bit like Medabots.
« Last Edit: January 16, 2012 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Webcam Barcode Reader
« Reply #7 on: January 16, 2012 »
Sounds really excellent, keep us posted on your progress! :)
www.kirl.nl
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Webcam Barcode Reader
« Reply #8 on: January 16, 2012 »
What Kirl said, especially the tank stuff, that sounds really neat.
raizor

Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #9 on: January 16, 2012 »
Almost there - it's converting the raw image into numerical data, but not calculating the checksum. I also need to make it work for EAN-8 codes.

I have attached a test version - it will only work with EAN-13 or old UPC codes. You'll need to position the barcode so that it fills the screen and there are no dark areas between the edges of the screen and the start and end of the code.
« Last Edit: January 17, 2012 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Webcam Barcode Reader
« Reply #10 on: January 17, 2012 »
I tried it and it works well with good lighting. I had a bit of trouble to keep the bloody product steady while holding it in front of my laptop cam, so I didn't catch the details of the barcode. Meaby leave the last valid info onscreen until another valid input is presented?

It's really cool and I can't wait to see how any of my most random products will do!
www.kirl.nl
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #11 on: January 17, 2012 »
I'll make it leave the last valid output on screen and increase the camera input framerate.
You are our 9001st visitor.
Challenge Trophies Won:

Offline Raizor

  • Founder Member
  • Pentium
  • ********
  • Posts: 1154
  • Karma: 175
    • View Profile
Re: Webcam Barcode Reader
« Reply #12 on: January 17, 2012 »
Might be nice to allow scanning barcodes from pictures. So those without a webcam can take a picture of a barcode with a camera or phone.
raizor

Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #13 on: January 17, 2012 »
I have now moved the program to the first post in the thread to make it easier to find.

There is the possibility of importing an image file - I'll try to add this functionality.

The checksum feature is now half working. The data is being recovered but not validated.

(update)

A newer version is available. It can read an up-side-down barcode and correctly calculate the checksum. It still isn't validating, but one step at a time will get us there.
« Last Edit: January 17, 2012 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline jace_stknights

  • Amiga 1200
  • ****
  • Posts: 399
  • Karma: 32
  • PEEK & POKE are not MOVEM!
    • View Profile
    • ST Knights WebSite
Re: Webcam Barcode Reader
« Reply #14 on: January 18, 2012 »
Great work! Did you make it for computer or phone?
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #15 on: January 18, 2012 »
It will work on any flash enabled computer or phone with a camera with a high enough resolution.

(update)

EAN-13 scanning is complete - it's validating the checksum and everything ;D

My next task is make EAN-8 scanning work.

(further update)

EAN-8 scanning now works :)

Now I just need to tidy the code and the debug displays before incorporating it into a game.
 8)
« Last Edit: January 18, 2012 by combatking0 »
You are our 9001st visitor.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Webcam Barcode Reader
« Reply #16 on: January 19, 2012 »
I tried it on my laptop - when I have the bar code close enough to the camera so it fills the view (is that required?) it is terribly out of focus and it just says Invalid.  The black and white bar thing doesn't seem to pick up the light and dark at all - I'm assuming it's meant to show where it thinks the stripes are.  Both the barcodes I'm scanning are dark blue on white backgrounds.  The camera is 2 megapixels.
Is there anything I can do about it?
EAN-13 refers the the number of digits?

Jim
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #17 on: January 19, 2012 »
EAN-13 refers to the number of digits - it will detect either an EAN-8 or EAN-13 barcode.

The camera needs to be focussed on nearby objects, roughly 1 to 3 inches away. This may not be possible on some webcams built into laptops and monitors.

The resolution gets scaled down to 320 by 240, which is wide enough to read a barcode without slowing down the flash player.

The only option I can reccomend is to buy an external camera.
You are our 9001st visitor.
Challenge Trophies Won:

Offline Kirl

  • Senior Member
  • Pentium
  • ********
  • Posts: 1217
  • Karma: 230
    • View Profile
    • Homepage
Re: Webcam Barcode Reader
« Reply #18 on: January 27, 2012 »
Meaby you could add an option to snap a pic at a higher res while displaying a low res? Also I'm not sure if you're doing this already but increasing the contrast of the image should help considerably.


I've been thinking of hacking the parking lot tickets lately as I noticed there's a scanner next to the slot where the ticket comes out (when driving in), I figure it's for people that work nearby. Should be an interesting side quest...

I'm wondering how much of a fuss they'll make about this though, as them parking lots are littered with cams (as is the rest of the city btw) and my car is pretty recognisable with a big spray painted smiley on the hood!  ;D
« Last Edit: January 27, 2012 by Kirl »
www.kirl.nl
Challenge Trophies Won:

Offline combatking0

  • JavaScript lives!
  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4569
  • Karma: 235
  • Retroman!
    • View Profile
    • Combat King's Barcode Battler Home
Re: Webcam Barcode Reader
« Reply #19 on: January 28, 2012 »
At the moment it's reading the red level of the pixels in the red line. If the level is above a certain value, it is classed as "255", if not, it is classed as "0".

When it finds a number of lines it recognises, it checks the widths of certain lines, and calculates a mean average. It then compares the white mean with the black mean, and adjusts the threshold for "255" or "0" accordingly.

There may be a better or faster way of adjusting the contrast - I will look into it.

The only way I know of getting flash to read a higher resolution image is to display one, but I can set the visibility of the bitmap to hidden to get round this.

As for the parking lot tickets - ideally I'd need to know the symbology of their barcode system. If it was made up by the company that made the parking lot machines, it will be a closely guarded secret. There are other ways of cracking barcodes, but I wouldn't want any of us getting into trouble ;)
You are our 9001st visitor.
Challenge Trophies Won: