View Single Post
  #3   Spotlight this post!  
Unread 15-06-2016, 20:04
snekiam snekiam is offline
Registered User
FRC #3322 (Eagle Imperium)
Team Role: Programmer
 
Join Date: Dec 2015
Rookie Year: 2010
Location: SE Michigan
Posts: 87
snekiam has a spectacular aura aboutsnekiam has a spectacular aura aboutsnekiam has a spectacular aura about
Re: Vision tutorials

What are you trying to do with vision? Auto aiming can be tricky, but the main ideas boil down to this:

-Use an LED ring (usually green) to reflect off the tape
-Set your camera's exposure as low as it will go while still seeing the reflective tape
-Create a binary image of only potential goals (in OpenCV, use an HSV filter) detect find all contours
-Throw away anything that isn't the goal (check similarity with opencv, aspect ratio, area vs perimeter, etc)
-Now comes the tricky part :-). You'll probably want to calculate distance and angle to the tape. Distance can be done using this equation: F = (P x D) / W, where F is your focal length (probably published, but should double check it with this equation), P is the number of pixels wide your camera is, D is the distance, and W is the width.
-To calculate angle, you'll essentially modify the field of view equation. The azimuth angle = arctan( ( center point of goal's x cordinate - ( (image width(pixels))/2 - 0.5) ) / focalLength).
-The azimuth is the angle your robot will have to rotate to be dead on with the goal


Most of this can be accomplished in OpenCV if you are feeling adventurous. We didn't get vision working this year until after competition, but we did it on a raspberry pi with a USB camera. We then sent the angle and distance over networktables to the roborio.

If you have any questions about how to do a specific part of this, feel free to ask.

Last edited by snekiam : 15-06-2016 at 20:05. Reason: Forgot about filtering goals!
Reply With Quote