<< return to Pixycam.com

How to make a range between coordinates


#1

Hello Everyone,
I am in school and I am making a project from my engineering class using the Pixy2. I am trying to write a code that detects objects between specific coordinates and will count the number of objects within that area. We are struggling to create a code that will detect if there are objects between given coordinates. If you can help with this that would be great.

Thank you,
Zachary


#2

Hello,
You might try starting with the hello_world code

https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29

And modify it such that you are only interested in blocks that are between specific x values and y values. That is, look at the pixy.ccc.blocks[i].m_x values and the pixy.ccc.blocks[i].m_y values.

Hope this helps!

Edward


#3

I feel that that is what we have been doing, but it is reading it that the blocks are always there even when we don’t put an object that we got the Pixy2 cam familiar with in front of the camera. Can you possibly show me what I am doing wrong? Thank you for all the help.

This is the line of code we are testing it with,

if ((pixy.ccc.blocks [i < 97].m_x) && (pixy.ccc.blocks [i > 71].m_x) && (pixy.ccc.blocks [i < 205].m_y) && (pixy.ccc.blocks [i > 35].m_y)) {

Serial.println("Hallway One");

}

Thank you,

Zachary


#4

Hey Zachary,

please see my email reply! Your code is not functional.

Thanks,
Jesse