Showing posts with label rgb. Show all posts
Showing posts with label rgb. Show all posts

Wednesday, 19 October 2011

Here's a grid of 54 blocks of colour - each with a unique combination of RGB values, one for each playing card in a regular deck (52 cards + two jokers). We're hoping to use these with a colour sensor to build a device which can "read" playing cards placed in a special holder.


Creating unique colour combinations for playing card reader

Ok. With the numerous problems and repetitions in our previous attempt, we've turned to Excel to help us solve this conundrum. We need to be sure that every playing card has a unique combination of red, green and blue in the colour block (whether we settle for a single colour in the block, or stick with the 2x2 grid approach, we'll have to wait and see, once we know how sensitive our LDR is going to be).

Each colour will have an intensity of zero-to-three.
By writing out all possible permutations, we get 64 combinations (three colours, four intensities, 4^3=64)

RedGreenBlue
000
001
002
003
010
011
012
013
020
021
022
023
030
031
032
033
100
101
102
103
110
111
112
113
120
121
122
123
130
131
132
133
200
201
202
203
210
211
212
213
220
221
222
223
230
231
232
233
300
301
302
303
310
311
312
313
320
321
322
323
330
331
332
333

We only need up to 52 colours, so we've decided to do away with the "darker" colours
(e.g. a block with the colour combination 0 1 0 would have one single green square and three black ones in a 2x2 grid). The easiest way to do this was to sum the totals of RGB and any block with a total of two or less was discarded (0-1-0 gets binned, 0-1-1 gets binned, but 0-0-3 can stay, as can 0-1-2 and so on)

This leaves us with 54 colour combinations:

RedGreenBlue
003
012
013
021
022
023
030
031
032
033
102
103
111
112
113
120
121
122
123
130
131
132
133
201
202
203
210
211
212
213
220
221
222
223
230
231
232
233
300
301
302
303
310
311
312
313
320
321
322
323
330
331
332
333

Where the total sum of colours in a block exceeds three (1-2-3 for example represents 1R-2G-3B) we'll have to mix the colours to make secondary colours (magenta, cyan, yellow) and maybe even black and/or white. But hopefully, using these colour intensity charts as a guide, we'll come up with colour blocks that enable us to uniquely identify a card based on the RGB values received by the LDR/light sensor.

Seeing playing cards with an LDR and RGB LED

It didn't take long after posting about our intelligent poker table for the emails to come in pointing out a few mistakes on our colour-block image.


We'd tried to come up with at least 52 unique combinations of colour blocks, using only primary (red, green, blue) and secondary (magenta, cyan, yellow) colours. We thought we'd done a pretty good job until Matt from BuildBrighton pointed out -

Looking at the top-left block of colours, it's easy to see that we've two red, one green and one blue block. Let's write this as 2R-1G-1B.

Now on the top row, look at blocks three and five.
Block three has two red, one magenta and one green.
Magenta is made up of equal parts (1:1) red and blue.
So block three is 3R-1G-1B

Block five is made up of two red, one yellow and one blue.
Yellow (as most people who paid attention in physics class will tell you) is made up of red and green light (yes, when mixing paint, yellow+blue = green, but when mixing light, red+green = yellow. Just accept it!)
This makes block five also 2R + 1R+1G + 1B = 3R-1G-1B

So although we'd used unique combinations of colour pigments for our blocks, we've actually repeated intensities of light for a lot of the colour combinations. In fact, looking through the image, we can see we've actually repeated ourselves quite a few times!

Back to the drawing board....

Intelligent poker table without RFID

As a member of HackLlan (Llangollen's Hackspace) we're trying to get some ideas together for a show-and-tell session in November and to organise a robot kit for a weekend-workshop.
This means a few of our other projects have been sidelined, while we try to find projects that are both simple enough to explain in a few hours, but complex enough to keep people's interest for the whole day.

One project we're looking at is an intelligent poker table. You know the sort - players put their cards face down on the table and a graphic appears on-screen showing their "hole" cards. This was first seen in the UK on Channel 4's Late Night Poker, where the rather lo-tech solution was to put a camera behind a sheet of glass at every player's position.



This approach is still used in a lot of televised poker tournaments, and they are available on the 'net to buy, but you'd have to be a dedicated poker player to house a full-sized 10 seater table in your house!
A variation on this theme is to have cameras mounted in the "rail" of the poker table, which sneak a peak at each player's hand, as they bend their cards upwards to have a look at them.

For home-games, an alternative approach is becoming popular, but it still quite expensive - RFID playing cards. Each card in the deck has a tiny RFID tag, and each player has an RFID reader in front of them. As the cards as placed on the reader, the unique ID is read from each tag and the system knows which cards the player holds.
This is infinitely simpler than having up to ten webcams under a table, but RFID tags are expensive. Each tag costs 50p-£1 and a professionally made deck of cards costs £100 or more. You can make your own cards, by simply applying an RFID label to each playing card, but this increases the thickness of the deck significantly and the labels are still susceptible to breaking if players bend the cards too much.

We're after a much more low-tech (i.e. cheaper solution) that should be accessible to almost anyone.
One of the ideas we're investigating is a colour sensing circuit and a 2x2 grid of colour, unique to each card.


The idea is to have an RGB LED and a light sensor (either an LDR or something like a light-to-voltage sensor) under an opening onto which the card is placed. By flashing the LED red, then measuring the amount of reflected light, then green, then blue, should allow us to work out which combination of colours is showing.

At the minute it's all just a fancy idea - but hopefully this week we'll find time to put together a proof-of-concept prototype to see if it's feasible to continue.