View Single Post
  #1   Spotlight this post!  
Unread 12-07-2014, 00:19
faust1706's Avatar
faust1706 faust1706 is offline
Registered User
FRC #1706 (Ratchet Rockers)
Team Role: College Student
 
Join Date: Apr 2012
Rookie Year: 2011
Location: St Louis
Posts: 498
faust1706 is infamous around these partsfaust1706 is infamous around these parts
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.

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!
__________________
"You're a gentleman," they used to say to him. "You shouldn't have gone murdering people with a hatchet; that's no occupation for a gentleman."