# Regression for calculating Distance

So I decided to write a script that outputs an equation when you input 2 variables: how “high” on the image your target is (target.y component) and distance. What is required it to record the .y value, and move the camera to various distances(CAMERA IS REQUIRED TO BE AT THE SAME HEIGHT FROM THE FLOOR), the more the better the regression will predict, then plug it into the script.

It will output 3 values, theta1, theta2, and theta3. The equation those belong to is: e^(theta1) + e^(theta2*X + theta3), where x is the .y value.

Attached is also a program that is user friendly. You use sliders to adjust the threshold of hue, saturation, and value, as well as the number of dilations, and with it, you can track any color, and you can set it up to output the center coordinate, or print it on the screen.

With these 2 resources, anyone should be able to track a target or game piece, and easily get an equation that yields how far away it is.

I hope this helps!

So I decided to write a script that outputs an equation when you input 2 variables: how “high” on the image your target is (target.y component) and distance. What is required it to record the .y value, and move the camera to various distances(CAMERA IS REQUIRED TO BE AT THE SAME HEIGHT FROM THE FLOOR), the more the better the regression will predict, then plug it into the script.

It will output 3 values, theta1, theta2, and theta3. The equation those belong to is: e^(theta1) + e^(theta2*X + theta3), where x is the .y value.

Attached is also a program that is user friendly. You use sliders to adjust the threshold of hue, saturation, and value, as well as the number of dilations, and with it, you can track any color, and you can set it up to output the center coordinate, or print it on the screen.

https://www.dropbox.com/sh/waiisgyzd...Hr3SuvrAPDkjfa

With these 2 resources, anyone should be able to track a target or game piece, and easily get an equation that yields how far away it is.

I hope this helps!