<< return to Pixycam.com

save coordinate

Hi,

how i can do to take the coordinate x from getblock and save it in array?

for example:

Detected 4:
block 0: sig: 1 x: 71 y: 176 width: 16 height: 6 angle 0
block 1: sig: 1 x: 161 y: 114 width: 19 height: 11 angle 0
block 2: sig: 1 x: 189 y: 113 width: 14 height: 1 angle 0
block 3: sig: 1 x: 220 y: 119 width: 17 height: 18 angle 0

take the x coordinate X of each blocks and save it in array[]?

I did it this way:

#define maxblocks  64
uint8_t    blockS[maxblocks];
uint8_t    blockX[maxblocks];
uint8_t    blockY[maxblocks];
uint8_t    blockW[maxblocks];
uint8_t    blockH[maxblocks];

void loop()
{
  // *SNIP*  
      uint16_t nblocks = pixy.getBlocks();

      for (j=0; j<min(nblocks,maxblocks); j++)
      {  
               
        blockS[j]= pixy.blocks[j].signature;
        blockX[j]= pixy.blocks[j].x;
        blockY[j]= pixy.blocks[j].y;
        blockW[j]= pixy.blocks[j].width;
        blockH[j]= pixy.blocks[j].height;

        // ...

      }    

  // *SNIP*
     

Helmut Wunder wrote:

nachdem ich schier verzweifelt bin an der unglaublich miserablen Dokumentation der Pixy-Cam-API-Funktionen, hier ein Programmbeispiel…
(after I am absolutely desperate at the incredibly lousy documentation of Pixy cam API functions, here is a sample program …)
[…]

sample program:

http://www.mindstormsforum.de/viewtopic.php?f=78&t=8508&p=66139#p66139

let’s right

one moment if i need of each x of blocks with same sign, how i can take it in a array without it become overwrite because the prog think it’ the same?

for example if i write so:

[code]
for (j=0; j<blocks; j++)
{
sprintf(buf, " block %d: ", j);
Serial.print(buf);
pixy.blocks[j].print();
a1 = pixy.blocks[j].x;
a2 = pixy.blocks[j].x;
a3 = pixy.blocks[j].x;
a4 = pixy.blocks[j].x;
}[\code]

isn’t the right way because to a1 a2 a3 will be assign the same varaiable pixy.blocks[j].x how i can do to have the relative x for every an?

blocks by the same signs come one after another, by increasing j

after 1 sign is finished then it’s the next sign’s turn, by further increasing j

(ceterum censeo, we needed more examples…) :-/

yes but my problem is that code:

for (j=0; j<blocks; j++)
      {
        sprintf(buf, "  block %d: ", j);
        Serial.print(buf); 
        pixy.blocks[j].print();
        a1 = pixy.blocks[j].x;
        a2 = pixy.blocks[j].x;
        a3 = pixy.blocks[j].x;
        a4 = pixy.blocks[j].x;
      }
    Serial.println(a1);
    Serial.println(a2);
    Serial.println(a3);
    Serial.println(a4);

print this:

Detected 3:
  block 0: sig: 1 x: 141 y: 190 width: 27 height: 18 angle 0
  block 1: sig: 1 x: 59 y: 179 width: 18 height: 8 angle 0
  block 2: sig: 1 x: 53 y: 194 width: 19 height: 8 angle 0
x1:53
x2:53
x3:53
x4:53

it not print the value of each x for each block but the last only…

ahhh ok now i have see… but, how can capture the x of each blocks with the same signature? for example to have that result:

Detected 3:
  block 0: sig: 1 x: 141 y: 190 width: 27 height: 18 angle 0
  block 1: sig: 1 x: 59 y: 179 width: 18 height: 8 angle 0
  block 2: sig: 1 x: 53 y: 194 width: 19 height: 8 angle 0

x1:141
x2:59
x3:53

ok i solved