<< return to Pixycam.com

Getting CC data out through the serial port

Hi guys!

Trying to use the pixy to get tracking data for an object going through a defined space. Have wired a pixy up to an arduino which has code to send the simple data (X,Y,height, width) when a physical button is pressed out to the serial port and using a code written in Processing 3.0 to get data from serial/USB connection and save it to a .txt file.

That all works fine, automated the read-in, read-out. Heck, both files pasted here for anyone’s use.

However, however, for my purposes, it’d be TONS BETTER if I could get the CC data (location, angle) for the item instead. The programming to deal with that seems to be a lot less documented/clear/easy to figure out. Questions:

  1. Is there perchance any information/examples that you might be able to point me to? Examples especially are good.
  2. The data I’m getting… it’s not 50Hz. I’m not following something, I guess. Is there something I can modify in the code to send packets more frequently?

Thanks!

-Gene

Hello Gene,
Have you looked at the hello_world example? It prints color code data and collects data at 50Hz. (Make sure you’re using the latest firmware and latest Arduino library, because older versions of firmware and Arduino libraries do not have color code support!)

http://cmucam.org/projects/cmucam5/wiki/Latest_release

Hope this helps!

Edward

Thank you, Edward.

Holy moly, I’m…errr…special. For some reason, having never tried the default program with the CC turned on (and reading some online posts about the complexity of the situation) I’d assumed (without checking) that the same code that output color patches wouldn’t work for CC data. Whooooops. Got that workin’.

A quick additional question, however… for some reason, the code (in the beginning) is outputting data in a sorta-garbled way… any thoughts why that might be/how I can fix it?

Example:

1092 - 81 decimal) x: 51 y: 185 width: 34 height: 28 angle -177
1109 - 59 y: 170 width: 46 height: 57 angle -20
1125 - block 0: CC block! sig: 121 (81 decimal) x: 51 y: 185 width: 34 height: 28 angle -177
1142 - Starting…
6177 - block 0: CC block! sig: 12 (10 decimal) x: 83 y: 196 width: 30 height: 5 angle -14
6460 - block 0: CC block! sig: 121 (81 decimal) x: 82 y: 186 width: 43 height: 24 angle 174
6560 - block 0: CC block! sig: 121 (81 decimal) x: 80 y: 182 width: 43 height: 33 angle 166
6643 - block 0: CC block! sig: 121 (81 decimal) x: 80 y: 182 width: 43 height: 34 angle 166
6726 - block 0: CC block! sig: 121 (81 decimal) x: 78 y: 180 width: 44 height: 38 angle 162

For some reason, ‘Starting’ is in the middle of the data field…

Thanks,

-Gene

Hello Gene,
Hmm, that’s interesting. I’m not sure where the numbers are coming from. It sorta looks like the numbers are being inserted by the terminal program. I bet if you wrote a simple printf(“hello world\n”) program, you’d still see the numbers, because, for example, the “Starting” message in the Pixy hello_world program is just a straightforward call to printf.

Which terminal program are you using?

Edward

Thank you, Edward.

Uhm, not sure what you mean re. terminal program. I’m using Processing 3.0 to read from data output via Arduino. It is then recorded to a .txt file - both of the codes used are attached to the first post.

Looks like things are coming in/being recorded out of order, is all.

-Gene

I’m a little confused myself. Are you talking about the numbers at the beginning of the lines?

1092
1109
1125
1142

That’s what caught my eye and I thought that’s what you were concerned about. But you’re referring to the order of messages? Please describe a little more.

Edward