<< return to Pixycam.com

how to detect BLOBS/blocks representing Color Codes (CC) by Arduino Sketch?

Helmut, you are asking people to write code for you. Stop that!

“Just tell me how to write 1 or 2 lines of code!” — you are commanding us to write code, but nowhere did I see an offer of cookies or brownies! At least Cindy in Intro to Programming baked me cookies— and she was a lot more attractive…

Ask us a question sir!

I’m guessing — your question might be “Could you give me an example of what a signature number would be for a color code consisting of signature 1 and signature 2 put together (for example)?”

Sure —

It would be a base-8 (octal) number of 12. (the 1 representing signature 1 and the 2 representing signature 2).

How do I convert base-8 to base-10, so I can look for this signature in my code?

Check out this site:
http://www.rapidtables.com/convert/number/octal-to-decimal.htm

(so look for signature number 10 in your code.)

Helmut, when you write another message on this forum, please make sure you are asking a question!

thanks!

OMG if we only had a German forum!
of course I know how to convert octal to decimal - but I do not know what to do with the numbers!

I wrote “I don’t understand this “octal” thing and what I’ll get as a result” - I mean by that that I don’t know what the octal results are all about! How do I have to handle the octal numbers? or the decimal? or what ever???

My English is poor, I know, Google translate often does not help!
I have no I dea how to use code for CCs because you dont provide code for CCs!

You said I should look at your effing hello_world.ino, but I’m already using this code, I have already incorporated it into mine!
Just look at my code, it’s exactly helloworld, but a little more extended!

Give me good exampleas of your own and everything would be fine!
Otherway round, when you don’t have own code to explain things, show me how to change my code and show me what I will get!

Your tutorials are lousy, make better ones! I don’t see any explanations about CCs and I don’t understand a word!

Sorry Helmut – no one here speaks German.

Where did you purchase your Pixy? Assuming it was a German distributor, they might be able to help – that’s part of the agreement we have with our distributors — they provide product support with native speakers.

Trying to learn a technical topic in a foreign language (like you are doing) doesn’t sound like fun… so reach out to them. (please) This dialog is not progressing.

ok, it was Watterott Elektronik in germany, but I already asked them about SPI SS/CS mode and they couldn’t help me.
So they are not supposed to help me by this CC thing.

I meanwhile observed that already the Set CC Signature procedure does not work correctly.

I have a test screenshot 0
Here you see a book with a red bar and just at it’s right side there is a green bar.
The CC area is the whole red bar plus the directly adjacent green bar.

So the ColorCode which I marked by Set_CC_Signature_1 is the whole area of red bar + green bar.

If I do it I get the screenshot 1 - just unusable. What is going wrong?

screen shot after setting CC signature 1:

Ah, the color codes make an assumption that the color code markers (swatches, whatever you want to call them) are roughly the same size (between 50 and 200% of each other) It’s a constraint that reduces false positives.

Your object is not going to work because the green area is much much bigger than the red line.

Hope this helps!

quote:“Your object is not going to work because the green area is much much bigger than the red line.”

sorry, you’re wrong!
(besides, you didn’t mention this important detail at any place in your descriptions so far! )

But:
the red bar is almost of the same size as the dark green bar at it’s right side.
But even if I’m marking a rectangle in PixyMon as a subset of the whole 2-bar-area which is exactly half-red and half-green then it also does not work. afterwards the PixyMon screen looks exactly the same as on foto_1

Helmut, you’re making this too complicated! The API documentation is straightforward because the API is really simple! (two calls, init and get)

There is no colorcode field, you can tell if the block is a color code by looking at the signature number.

So— for example, if you want the position and angle of a color code with signatures 1 and 2 put together, just do this


if (pixy.blocks[j].signature==10) // 10 = 12 octal, but change number to whatever CC you want to detect!
{
   // position of this CC is pixy.blocks[j].x, pixy.blocks[lj].y, 
   // angle is pixy.blocks[j].angle
}

Regarding the red rectangle, etc, try playing with color codes similar to ones in this video

ie. squares and rectangles of roughly the same size.

it’s hard for me to understand what you are doing in your video because I can’t detect what you are doung on your computer.
A written pictured tutorial with detailed little steps would be appriciated.
As I already wrote:
I still have absolutely no clue how you are coding, storing, decoding, and retrieving color codes.
I don’t even understand the rough concept behind “colorcode” by geometry, mathematics and coding.
http://cmucam.org/boards/9/topics/5253?r=5263#message-5263

does it mean I first have to train the single colors and then by either obscured way have to teach what single colors have to be composed to a color code?

what do you mean by

// 10 = 12 octal, but change number to whatever CC you want to detect!

what does 12 octal stand for? 7 plus 5 ?
in case, yes: what is 7? what is 5?
or does it mean 1 plus 2 ?
in case, yes: what is 1? what is 2?
or what else?
i.e., by which mathematical formula do I get the single parts of the octal number?
and what exactly do the single parts of the octal number represent?

Please explain more detailed how to work with color codes, starting off by Zero.
Maybe these misunderstandings are the reason why I never get results by Arduino Code to retrieve CC data.

Helmut,
Each octal digit is one color code ID. For example if in pixymon, you defined CC 1 to be a red blob and CC 2 to be a green blob, getting an octal 12 means that Pixy has detected a blob with red and green adjacent. If you had also defined color code 3 to be yellow, an octal 132 means that Pixy has detected a blob of Red next to Yellow next to Green.

Because of the complexity that can arise from the possible number of combinations and of separating each octal digit, I recommend figuring out the color sequences you are interested in (for example RG, RGY, RYG) and the octal values (continuing the example 12, 123, 132). Then convert them to decimal, and have your program only look for those values when checking for color codes.

Hope this helps,
Tom

oh - does that mean that you have to define CC colors singularily? I always thought that a CC is the whole area consisting of 2 colors side by side…

If there only was a reasonable tutorial!

So Pixy combines all define single CC colors by itself to all permutations of all single ones?

3 defined colors would cause Pixy to detect
1+2
1+3
2+3
1+2+3
and even
2+1
3+1
3+2
2+1+3
3+2+1
1+3+2

and so on, side by side?

Based on tests I ran, that is what I saw.

But you will not get mirror images reported as 321. That would be reported as 123 with angle shifted 180 degrees.

You would get
12
13
23
123
132
213

I’m not sure if you would get 121, 212, 131, 232, 313, 323 assuming you had those 3 colors adjacent like in your earlier photo (but with more equal swatches).

Originally I tried defining groups of colors, and it seemed to work, but the results were screwy. When I read the wiki a few times, it seemed that the single color made sense and my data supported that.

So you can see that the more colors you define, how complex the results can be (especially if codes like 121 are possible.)

Tom

If you look in the Using Color Codes wiki article you can see a simple example.
Four colors for color codes are defined using Lego blocks. See the pictures in the article.

Blue is 1, Green is 2, Red is 3, and Blue is 4.

The last photo of the article shows the pixymon screen with 4 stacks of blocks. Above each block is the color code signature.

The left set of blocks is YGRB (1234), the upper center stack is BY (21 which is reported as 12, I’m not sure I understand the angle on that one). The bottom center is GYR (213), and the one on the right is YGR (123).

I think that some of the confusion is because “color codes” seems to be used for each individual color (color code signature) and the color group (color code).

Tom

yes, thank you, now your posts really helped me a lot to understand!

I always thought that “color code” is the whole colored pattern by either predefined color-combination that I have marked before.
I never understood that I had to train single colors, not the whole combined pattern thing!
And that it’s not allowed to have patterns like 1-2-1 was also new to me
(- anyway, by origin the 2 green colored areas right- and left-hand of the red bar are completely different but nevertheless the cam does not detect the difference.)

So that’s now enough information for me to start working with it. I’ll keep you informed…
thanks again!
:slight_smile: