Go to Post There's no problem another CIM motor wouldn't fix! - Tom Bottiglieri [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-02-2012, 22:55
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
Distance Algorithm

Hello,

I was wondering how everyone else was finding the distance to the target using the camera? I am using the algorithm mentioned in the paper Position Determination that I have posted below. My problem is that I have to keep on changing the effective focus length depending on my distance from the target to keep measurements accurate. Does anyone know of any better methods or what I doing wrong with my current method?

thanks
Attached Files
File Type: doc PositionDetermination (1).doc (1.21 MB, 91 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 06-02-2012, 23:03
Navi Navi is offline
Registered User
AKA: Ivan
FRC #0840 (Aragon Robotics Team)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2009
Location: San Mateo
Posts: 12
Navi is an unknown quantity at this point
Re: Distance Algorithm

Page 9 of the vision white paper includes an equation for calculating the distance using the pixel width, actual target width, camera view angle, and some trig.
Reply With Quote
  #3   Spotlight this post!  
Unread 06-02-2012, 23:56
severhale severhale is offline
Registered User
FRC #4097
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Northampton, MA
Posts: 10
severhale is an unknown quantity at this point
Re: Distance Algorithm

what i did was find the height of the bounding box in pixels at different known distances. theyre inversely proportional, so the k constant is d*h. d= k/h. i got about 15000 for k but you should run a few trials. it works at angles and is accurate within at most three inches.
Reply With Quote
  #4   Spotlight this post!  
Unread 07-02-2012, 00:06
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
Re: Distance Algorithm

Thank you very much for the new formula, but I was wondering, does the "k" constant stay the same when the robot is not directly in front of the target but at an angle? I was also wondering why other teams I talked to had all this crazy math and where using other images libraries like javacv?

Thanks
Reply With Quote
  #5   Spotlight this post!  
Unread 07-02-2012, 00:25
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: Distance Algorithm

You may find the following educational with regards to this:

http://www.roborealm.com/tutorial/FIRST/

Yes, the height will change based on where the target is in the image. Ideally you'd measure right in the center where the distortion is the least ... but if not you'll have to apply some form of distortion to accommodate the border areas.

You should not need to change the focal length once its set. If you can't figure this out post some images with some known distances and we can help check what the issue may be.

STeven.
Reply With Quote
  #6   Spotlight this post!  
Unread 07-02-2012, 07:55
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,753
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Distance Algorithm

I think you'll find that this is the same technique as what is in the white paper, but rather than use the constants about the camera and the target and work through the relationships, this measures it as a black-box system, determines the relationship, and uses field-data to model it. When systems get complex enough, this is a very good approach. Since the math involved is just a bit of trig, it should be pretty easy to show how to compute k and to compare it to the measured value.

Greg McKaskle
Reply With Quote
  #7   Spotlight this post!  
Unread 07-02-2012, 19:50
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
Re: Distance Algorithm

Okay, thanks for all the replies. but does the formula described in the white papers account for the change in angle such as moving from side to side?

Also regarding the images, i don't have access to them now. but I will post them tomorrow.

Last edited by cooltext : 07-02-2012 at 20:45.
Reply With Quote
  #8   Spotlight this post!  
Unread 08-02-2012, 19:10
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Distance Algorithm

Quote:
Originally Posted by cooltext View Post
Okay, thanks for all the replies. but does the formula described in the white papers account for the change in angle such as moving from side to side?
I initially ran into problems when testing the code used in that whitepaper because of skew moving from side to side. I changed the code to use the Y value instead of the X, so you won't run into problems with skew when moving from side to side on the field. If your robot relies on getting up close to the target you may still encounter problems with Y-axis skew, but since we're shooting balls and maintaining range, and since we have a fairly high mounted camera, we don't forsee Y skew becoming too much of a problem.
Reply With Quote
  #9   Spotlight this post!  
Unread 08-02-2012, 21:13
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
Re: Distance Algorithm

Quote:
Originally Posted by jesusrambo View Post
I initially ran into problems when testing the code used in that whitepaper because of skew moving from side to side. I changed the code to use the Y value instead of the X, so you won't run into problems with skew when moving from side to side on the field. If your robot relies on getting up close to the target you may still encounter problems with Y-axis skew, but since we're shooting balls and maintaining range, and since we have a fairly high mounted camera, we don't forsee Y skew becoming too much of a problem.
Could you post your formula please? thanks
Reply With Quote
  #10   Spotlight this post!  
Unread 09-02-2012, 17:04
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Distance Algorithm

Here you go.

I have this as a separate VI right inside my image processing loops.

Basically what this does is:

(Actual width of the target in ft * Y Resolution of camera image) / (The processed rectangle's height in pixels) / 2 / (the tangent of the camera's FOV/2)

Be very careful with the number you're using for FOV. The spec sheets all give you the FOV in degrees, and I used radians in my labview.

EDIT: I accidentally have width*x_res writte in that image, that should be y_res if you're using the height of the rectangle
Attached Images
File Type: bmp rangefindingVI.bmp (1.39 MB, 50 views)

Last edited by jesusrambo : 10-02-2012 at 01:33.
Reply With Quote
  #11   Spotlight this post!  
Unread 09-02-2012, 18:54
cooltext cooltext is offline
Registered User
FRC #0835
 
Join Date: Jan 2012
Location: Michigan
Posts: 32
cooltext is an unknown quantity at this point
Re: Distance Algorithm

Thanks for your formula. What is your average error on the measurements, and does it get worse at angles?
Reply With Quote
  #12   Spotlight this post!  
Unread 10-02-2012, 01:33
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Distance Algorithm

So far it's generally accurate within a few inches. Tweak the FOV number a little though, if you need. And keep in mind that FOV will change depending on if you're using the Axis 206 or the Axis M1011 camera.

Since we're using the height of the rectangle, you will notice increased error if you're driving up really close to it, since your angle will start getting funky, but the alternative is using the width, and that'll get thrown off by moving left to right at all. What we figure is since we're shooting we're not too likely to be up really close to the target anyways, so it's better to make that tradeoff.

Also, I accidentally have width*x_res writte in that image, that should be y_res if you're using the height of the rectangle.
Reply With Quote
  #13   Spotlight this post!  
Unread 11-02-2012, 00:48
nickpeq nickpeq is offline
Turing-complete
FRC #1255 (Blarglefish)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Baytown, TX
Posts: 60
nickpeq is an unknown quantity at this point
Re: Distance Algorithm

Quote:
Originally Posted by jesusrambo View Post
So far it's generally accurate within a few inches. Tweak the FOV number a little though, if you need. And keep in mind that FOV will change depending on if you're using the Axis 206 or the Axis M1011 camera.

Since we're using the height of the rectangle, you will notice increased error if you're driving up really close to it, since your angle will start getting funky, but the alternative is using the width, and that'll get thrown off by moving left to right at all. What we figure is since we're shooting we're not too likely to be up really close to the target anyways, so it's better to make that tradeoff.

Also, I accidentally have width*x_res writte in that image, that should be y_res if you're using the height of the rectangle.
You should be able to account for being under the targets by checking when width:height > 1.33 and calculating an angle from that ratio.
Reply With Quote
  #14   Spotlight this post!  
Unread 11-02-2012, 13:50
jesusrambo jesusrambo is offline
Self-Proclaimed Programmer Messiah
AKA: JD Russo
FRC #2035 (Robo Rockin' Bots)
Team Role: Programmer
 
Join Date: Feb 2012
Rookie Year: 2010
Location: Carmel, CA
Posts: 114
jesusrambo is an unknown quantity at this point
Re: Distance Algorithm

Quote:
Originally Posted by nickpeq View Post
You should be able to account for being under the targets by checking when width:height > 1.33 and calculating an angle from that ratio.
This wouldn't really work very well though unless you're directly in line with the target. Being at all to the left or the right would mean both x and y lengths are skewing, and not necessarily proportionally.
Reply With Quote
Reply


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 12:51.

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