|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
|||
|
|||
|
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 |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
|||
|
|||
|
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. |
|
#8
|
|||
|
|||
|
Re: Distance Algorithm
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.
|
|
#9
|
|||
|
|||
|
Re: Distance Algorithm
Quote:
|
|
#10
|
|||
|
|||
|
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 Last edited by jesusrambo : 10-02-2012 at 01:33. |
|
#11
|
|||
|
|||
|
Re: Distance Algorithm
Thanks for your formula. What is your average error on the measurements, and does it get worse at angles?
|
|
#12
|
|||
|
|||
|
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. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|