<< return to Pixycam.com

pixy can't find the exact location of the blocks

I want pixy to aim the several blocks sequentially. I put several blue post-it (set as signatue 1) on the board and let pixy aim them correctly.
I don’t know how to control pixy’s coordinate. Pixy doesn’t work as I expected.
Please check my file in the attachment.
Key line is as below. I normalized the block position as you see.
Please help me find the reason for this problem.
Thanks.
Young

pixy.setServos((PIXY_MAX_X-pixy.blocks[j].x)PIXY_RCS_MAX_POS/PIXY_MAX_X, pixy.blocks[j].yPIXY_RCS_MAX_POS/PIXY_MAX_Y);

Hello Young,
What you are trying to do is actually fairly difficult (I think.) The pan/tilt demo uses a control loop to control the servos such that the largest detected object is centered in the image. The code does not calculate the position that the servos need to be. It calculates the velocity that the servos need to move to center the object, and it iteratively converges on the location of the object after several control cycles.

You are trying to calculate the position of each object and move the servos to this location. This approach makes good sense, but it’s a much harder problem. In order to calculate the servo positions, you need to have an accurate mathematical expression that maps the detected object position (the x-y position that Pixy provides) to the pan/tilt servo positions. This requires some calibration and is fairly challenging to get decent accuracy.

Anyway, I’m not sure what your application is. You sound like you are new to Pixy. Perhaps you can describe your application and we can suggest a simpler solution.

Edward