Go to Post Yay for teaching how to fish! - RoboMom [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-02-2013, 19:22
danielcg25 danielcg25 is offline
Registered User
FRC #0706
 
Join Date: Jan 2013
Location: Milwaukee, WI
Posts: 7
danielcg25 is an unknown quantity at this point
How do I calculate the distance between an object and the camera?

I know the size of the of the object (in this case the Frisbee targets) and I'm using the Axis M1011 camera.

EDIT: In VBScript. (to put into RoboRealm)

Last edited by danielcg25 : 05-02-2013 at 19:29.
  #2   Spotlight this post!  
Unread 05-02-2013, 19:24
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,600
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: How do I calculate the distance between an object and the camera?

Have you read the vision whitepaper? http://wpilib.screenstepslive.com/s/3120/m/8731
  #3   Spotlight this post!  
Unread 05-02-2013, 20:10
danielcg25 danielcg25 is offline
Registered User
FRC #0706
 
Join Date: Jan 2013
Location: Milwaukee, WI
Posts: 7
danielcg25 is an unknown quantity at this point
Re: How do I calculate the distance between an object and the camera?

Quote:
Originally Posted by Joe Ross View Post
Have you read the vision whitepaper? http://wpilib.screenstepslive.com/s/3120/m/8731
How do I calculate tan theta from the camera's output?
  #4   Spotlight this post!  
Unread 05-02-2013, 20:36
catacon catacon is offline
Registered User
FRC #1444 (Lightning Lancers)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2006
Location: St. Louis
Posts: 154
catacon is a splendid one to beholdcatacon is a splendid one to beholdcatacon is a splendid one to beholdcatacon is a splendid one to beholdcatacon is a splendid one to beholdcatacon is a splendid one to beholdcatacon is a splendid one to behold
Re: How do I calculate the distance between an object and the camera?

2*theta is the field of view of the camera you are using. You should be able to find that value in the datasheet for the camera.

So... tan(FOV/2) = w/d
  #5   Spotlight this post!  
Unread 05-02-2013, 22:05
RoboRealm RoboRealm is offline
Registered User
FRC #0443
 
Join Date: Nov 2011
Location: United States
Posts: 36
RoboRealm is a jewel in the roughRoboRealm is a jewel in the roughRoboRealm is a jewel in the roughRoboRealm is a jewel in the rough
Re: How do I calculate the distance between an object and the camera?

If you look at the VBScript code you'll actually see the answer already in there. In the current case the code will calculate the distance between the camera and a 12" high target. Instead, you'd want to know the width of the frisbee (since the height would be distorted by perspective) and base the distance on that. For example, have a look at the attached code/image as an example.

Note, we're note sure of the width of the frisbee (I think its 10") so you may need to change that in the VBScript.

Also, note that this is the diagonal distance from the camera to the frisbee ... this is NOT the floor distance which will be shorter. But if you know the angle of the camera to the floor you can use a different geometry to figure out that distance.

STeven.
Attached Files
File Type: zip Frisbee_Distance.zip (258.7 KB, 136 views)
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 02:23.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi