<< return to Pixycam.com

Finding the distance to an object, mathematically.

I would like to use Pixy on a robot for FRC. Knowing that my object is 26.9" * 16.9" * 12.1", what is the equation I could implement to find the distance?

If we move the a BB twice as close to the camera, it gets bigger. But the area it covers does not get twice as large. The apparent length will double, but the apparent area will quadruple. The square root is there to deal with that.

Formula:

distance(final)= distance(initial)times(x) the square root of {initial area divided by measured area}

The initial area can be measured at one meter distance away from camera. The measured area is what the pixy is giving you.
Hope this helps.

Hello,
The camera equation is like this:

x_pixel = constant * (Xe/Ze)

Where Xe and Ze are in the environment. It tells you that if you are looking at an object, say 2 feet away from Pixy’s lens, and you move it 1 foot away (halve the distance), the width will double. (Ze goes from 2 ft to 1 ft).

So the distance is like this:

Ze = constant/width_of_object_as_measured_by_pixy_in_pixels (this is available in the object block)

The “constant” can be calculated by making a measurement of the object block width at a known distance and backing it out.

I think the discussion of the area of the object might be confusing.

Hope this helps!