I built hockey game with Pixy Cam5 and Arduino as a learning experience. The only problem I have is alignment with the hockey puck and the robot. When my vision system thinks they are aligned, they really aren't. If the object is close to dead center it seems to work very well. But if the puck(object) is off center it will be inaccurate. The further from the center the more it is off. And the discrepancy varies with the distance from the camera. My camera is mounted immediately above the robot arm and travels with it.
Could this be a lens distortion issue? How do others handle such an issue? Maybe I should mount the camera high above the hockey table in a stationary position looking down on the action. That way maybe I wouldn't have to deal with depth perception as I am now.
It could be lens distortion; have you tried measuring the angle/distance and amount things are "off" - then plot an X/Y graph to see what it looks like? It should be fairly linear - but if it has the distortion you are saying, then you should get a curve.
If you get a curve, then you could (in theory) do a "curve fit" of the graph (ie - find the function that approximates the curve), then use that to correct the issue.
Your issue could also be because the plane of the camera, and points along that plane vs the centroid of the camera, get further from the camera lens as the distance increases from the center (ie - the hypotenuse of the line, from the center of the FOV).
*_______X
| /
| /
| /
| /
| /
| /
|/
C
C = camera
* = center of FOV (field of view)
X = some point away from center
...thus - line XC is a longer line than line *C - understand?
Thanks! I did toy around with plotting a graph but then decided against it because the discrepancies also change with the depth or the y axis. Since I'm really only interested in one axis(robot arm only moves on one axis) I may relocate the camera up above to a fixed location. This has been a great exercise to go through since I am new to both Arduino and Pixy.