<< return to Pixycam.com

Please help me to coding about object size setup

i want to detect a bugs by pixy’s. but i cant make a code how to detect object size!
I want to write code that recognizes a range of specific values ​​using an expression for the size of the object I want to detect.
Because the distance that the camera can detect is short, I want to write code that allows objects larger than a certain size to be detected.

#include <Pixy2.h> // This is the main Pixy object
Pixy2 pixy;

void setup() {

Serial.begin(115200);
Serial.print(“Starting…\n”);
pixy.init();

}

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(”:angle ");
pixy.ccc.blocks[i].print();
}
}
}

I don’t know how to add here please help.

Hello,
In the code you referenced, you can access the width and height of each object with

pixy.ccc.blocks[i].m_width
pixy.ccc.blocks[i].m_height

This page has more information:

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:ccc_api#member-variables

Edward