View Single Post
  #1   Spotlight this post!  
Unread 02-21-2016, 11:27 AM
Cinnamon Toast's Avatar
Cinnamon Toast Cinnamon Toast is offline
Registered User
FRC #3641 (The Flying Toasters)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2013
Location: Michigan
Posts: 32
Cinnamon Toast is an unknown quantity at this point
Re: How to calculate distance from camera using Opencv APIs

Hi!

Depending on your opencv code this is very possible. The way we do vision processing we do blob detection of a particular target (biggest blob always is the one targeted). After we find the blob we draw a circle around it, and place a dot in the center of the circle. For pose correction we use the pixel coordinates of the dot that we draw. Something else we do get from the code is the radius of the circle that we drew. As the camera gets farther away from the target, the target gets smaller, and so does the circle that we drew around the blob. By taking a couple of measurements, you can just create a linear relationship between radius of the circle and real world distance. The calculation actually holds up pretty well, as we plan to use it for targeting this year.

-Cinnamon Toast.
P.S. PM me if you want some sample code with opencv and stuff. I'd be willing to help.
Reply With Quote