<< return to Pixycam.com

Identification of variables in hello_world for arduino.

Hello everyone. I finally managed to connect to the forum.
I’m excited about this project. Congratulations for Pixy.
After giving more than one lap, I managed to understand the meaning of the variables (static int i), (uint16_t blocks). I believe that (i) identifies the corresponding Array to each detected object (blocks) indicates the number of detected objects. Please correct me if not. However I do not quite understand is the role that the variable (j). I beg a little patience for my stupidity and I’m starting and I would deeply understand the meaning of this little program to move forward.

Thanks and regards.

Manuel,

Thanks for trying Pixy. I’m assuming you’re asking about the @‘j’@ variable in the @‘loop’@ method in the ‘hello_world.ino’ arduino example. In this case, the @‘j’@ variable is used as an index to the pixy.blocks array. Whereas, @pixy.blocks[0]@ is the first element in the array, @pixy.blocks[1]@ is the second, and so on.

John

Thanks for your answer John.
I now understand much better the performance of this program.
However, I would like you to confirm me whether the following items are correct:

  • (blocks). Number of detected objects.
  • (i). Identification number of each object. Used to identify the Array.
  • (j). Identification number of a particular Array index.

I have many questions still unanswered. I will start with these:

  • How Pixy assigned the number (i) to recognize each object?
  • In each detection the same number is assigned to a particular object?
  • The identification is always performed by a number?

For now, it is more than enough.
Thanks in advance and best regards.

Hi Manuel,

  • Yes, you are correct that @blocks@ is the number of objects (or “blocks of pixels”) that match a signature.
  • @i@’ is just used as a counter to keep track of how many calls to @pixy.getBlocks();@ we’ve made. Then on the 50th one, we print out the block data to Serial.
  • Yes, ‘@j@’ is used as an index to access all of the blocks in the array.

For your second set of questions:

  • Pixy doesn’t actually assign a number to each object, ‘@i@’ is just used to count how many times we’ve asked Pixy for block data.
  • Please see the description of variable ‘@i@’ above.
  • The distinction between objects is made using @Block.signature@, not ‘@i@’.

Hope this helps.

Scott

Thanks Scott.
Your explanations have helped me a lot. I’m looking forward to receiving my new Pixy to start experimenting with it. I try to run a small project for identification and counting of manufactured products, by color code. This is an implementation of small-scale traceability.

Thanks and I hope to continue with your help. My level is too basic.

Happy to help, Manuel! Feel free to post on the forums or email us with any questions you have.

Scott