<< return to Pixycam.com

Pixy2 camera using Arduino


#1

Hi,
can you please tell me how to use the different elements present in a block while accessing pixy2 camera. I had accessed the blocks and printed it. now i want to get the values of sig, index, x , y , height , length individually to separate variables. Please suggest me the possible ways to do the same.

Waiting for your reply.


#2

Hello,
Assuming you are using Arduino, bring up the ccc_hello_world program.

    void loop()
    { 
      int i; 
      // grab blocks!
      pixy.ccc.getBlocks();
      
      // If there are detect blocks, print them!
      if (pixy.ccc.numBlocks)
      {
        Serial.print("Detected ");
        Serial.println(pixy.ccc.numBlocks);
        for (i=0; i<pixy.ccc.numBlocks; i++)
        {
          Serial.print("  block ");
          Serial.print(i);
          Serial.print(": ");
          pixy.ccc.blocks[i].print();
        }
      }  
    }

Note, in this context you can refer to pixy.ccc.blocks[i].m_x for the x coordinate, ccc.blocks[i].m_y for the y coordinate, ccc.blocks[i].m_signature, ccc.blocks[i].m_width, ccc.blocks[i].m_height, etc. according to the API document here:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:ccc_api

Hope this helps.

Edward