<< return to Pixycam.com

How to get the Number of Pixels in the Detected Object

I am doing a project where it is important to have accurate area of the detected object known to take some decision.
From the Blocks the only information I get is Height & Width but calculation of area of detected object can not be done accurately using this information.

As far as I know the Pixy algorithm identifies the pixel of Interest by looking up in the Signature table and accumulates if is part of it. So ideally, Pixy has the information what I need. But it’s not available on the interface.

Can anyone tell me what can be the solution to the problem.

Thanks in Advance,
Hiren

1 Like

Hello Hiren,
So you want the number of pixels that match your signature for each detected object. Is that an accurate description? Usually the width x height is a good approximation of this number. But if you want this number in particular, it’s not provided in the current firmware. I’ll log this as a feature request. I believe you are the first person so request this.

The other option is the modify the firmware to provide the information you want.

what are you trying to do? Can you describe your application? Perhaps there is another solution we could suggest.

Edward

Good Morning Edward,

First of all thank you for your prompt response…

I am actually developing a device using pixy which sorts the objects based on its size.
Since, the shape of the object is irregular, the height & width information is not enough to get the actual size.
Hence, I need to obtain the number of pixels in the detected object to identify its size.
Based on this information my controller takes decision to drop the object in a particular bin.

Regarding the firmware modification, I am very new to the development process.
If you can tell me what part of the firmware program to be updated to get the required information on the interface, It would be of great help to me.

Thanks & Regards,
Hiren

Edward Getz wrote:

Hello Hiren,
So you want the number of pixels that match your signature for each detected object. Is that an accurate description? Usually the width x height is a good approximation of this number. But if you want this number in particular, it’s not provided in the current firmware. I’ll log this as a feature request. I believe you are the first person so request this.

The other option is the modify the firmware to provide the information you want.

what are you trying to do? Can you describe your application? Perhaps there is another solution we could suggest.

Edward

Hello Hiren,
I’m probably not the person to ask about which part of the firmware to modify. Perhaps someone on this forum can help.

Edward

Hi Edward,

Can you provide/ point me the documentation regarding the firmware where I can understand the program flow?
If you know anyone who can help me do this, please share the contact details.

Thanks in Advance,
Hiren

Hello Hiren,
The firmware code isn’t documented per se. It’s something on our list of things to do, but for now, it’s fully open source.

Edward

Hi Hiren & Edward,

I am also extremely interested in knowing the number of pixels in a detected object, for i am also doing a project involving needing to know the size of the object that is detected. Is this by chance possible using the Arduino API? I was reading through the wiki about using Pixy with Arduino, and am i correct in assuming that the “pixy.blocks[i].width” and the “pixy.blocks[i].height” commands would achieve this? Thanks in advance!!

Cheers,
Nathan

Dear Nathan,

If you don’t need the precise size the approximation with the block parameters is good enough.
It approximates the size of the detected object to the rectangle of height & width maximum in the detected object.

However, if you are looking for the precise area of the detected object, you actually need the number of pixels in the detected object.

Hope this is helpful.

Regards,
Hiren

Ahhh, ok, that makes sense. I haven’t yet had a chance to test it out, so i will see if the approximation will be adequate for my project…do you by chance know how accurate the approximation is?

Also, if it turns out that i do need a precise number of pixels in the detected object, then you and i both are just waiting for Edward to get back to us with some good news, right? Thanks for the reply Hiren!

Cheers,
Nathan

Hello Edward,

Can I use the color code mode to detect my object?
As in this mode I get the information of angle also. But can I use only one color for the color code?

Thanks in Advance,
Hiren

Hello Hiren,
You might find this page useful:

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

Color codes are 2 or more color tags placed close together, so one color color codes will not work.

Edward

It is a very hard time for me to understand the firmware…
Can anyone help me understand it?

Hi Edward,

I am trying hard to understand the program flow of the firmware.
Till now I could understand is that the code is running on either of M0 or M4 core.
M0 core is mostly dedicated for data acquisition from the sensor, while the M4 core process the data.
What is not clear to me is that in which program the Block Parameters (Hight, width and other details) are calculated and stored, from where the Blocks is accessible by arduino libraries?

I believe that you know the structure of the firmware program and can answer my question.

Thanks in advance,
Hiren

Hello Hiren,
I think most of the code you are talking about is in blocks.cxx. Look at the method getBlocks().

Hope this helps!

Edward