 |
WiiLi.org a new revolution
|
| View previous topic :: View next topic |
| Author |
Message |
Cha0s Site Admin
Joined: 17 Jan 2007 Posts: 468
Digg It |
Posted: Wed May 09, 2007 4:40 am Post subject: |
|
|
I'll try it with some real data soon. Now why r can be constant. I'm not sure on that. BUT, r, just as before, is the distance from the lens to the image. This distance is always constant, regardless of where the image is, no? If I'm wrong, I'd love to hear it so I can make changes.
EDIT: Also, I think r will be that 1320, as the centered example is simply a subset of this example. However, I don't think that 1320 is right, unless 7.5 inches is VERY approximate. Let's say that we overestimated and that value for k was really 256. Even then, applying .1905 m (7.5 inches in centimeters) yields ~1344, which is a decent bit bigger than 1320. I'm going to measure the sensor bar itself meticulously and then try to find r experimentally and see if it is indeed constant. _________________ Cha0s |
|
| Back to top |
|
 |
wic
Joined: 26 Mar 2007 Posts: 57 Location: Sweden
Digg It |
Posted: Wed May 09, 2007 11:33 pm Post subject: |
|
|
Yes. IF r were the perp. distance. But according to your figure, it is not. r is the distance between the middle point ((p1+p2)/2) and the lens. Since both points vary between 0 and 1024, r cannot be constant. Or your figure must be wrong (or I'm reading it wrong).
I took a new look at your figure and tried some other derivations, and I wound up with 'y/z = l/p' once again. I worried that it only works for right angles, but I dont think that is the case, since I got it out of your figure as follows. I'm using a third angle, v, which is the one between d and x in your figure. I'm using 'z' to denote the perpendicular camera-image distance (its normally called 'd', but that one is in use ).
| Code: |
d/r = l/2 / p/2 = l/p => d = rl/p (1)
sin v = y/d (2)
sin v = z/r (3)
(2)+(3): y/d = z/r => y = dz/r (4)
(4)+(1): y = (rl/p)z/r = lz/p
|
So there you have it in a nutshell. Note that r is eliminated from the system which is very nice.
Now lets figure out what 'z' is. First take a look at these urls which outlines the projection theory. The first link is more correct than the next imo:
http://www.devmaster.net/articles/software-rendering/part2.php
http://www.iirc.net/petes/render/step3.shtml
This was the stuff I wrote about earlier when I used FOV to calculate z (again, z is called d). The links explains how to find screen points from known points (vertices in a 3D world). What we are trying to do here is the opposite, ie using known screen points to calculate points on the physical sensor bar. Well, the distance to it at least. So z is 1/tan(fov/2).
Here is some code I used for calculations using python.
| Code: |
def ndc(x):
return x/512.0-1
# a and b: pixeldots (x values)
# l: physical sensor bar length in meters
# fov: field of view in degrees
def calc_distance(a, b, l, fov):
fovr=fov*math.pi/180 # No need to calc each time obviously
z=1/math.tan(fovr/2) # z: perp. camera-image distance
p1=ndc(a) # Values [-1 1]
p2=ndc(b)
p=abs(p1-p2)
y=z*l/p
corr=264.0/abs(a-b) # This is the "correct" function (y = k/p) for comparison
# print "z : ", z
# print "p1 : ", p1
# print "p2 : ", p2
# print "p : ", p
# print "y : ", y, " meter"
# print "corr: ", corr, " meter"
# print "err : ", abs(corr-y)
return y
fov=40
l=0.19
#center=512
#for i in range(20, center):
# a=center+i
# b=center-i
# y = calc_distance(a, b, l, fov)
# print a, b, abs(a-b), y
|
This means that fov and physical length, l, is the only constants needed to calculate the distance y. I manually measured fov to 35 degrees, but testing using this code shows that fov is ~40 degrees. Sample output:
| Code: |
>>> calc_distance(612, 412, 0.19, 40.4)
z : 2.71061860933
p1 : 0.1953125
p2 : -0.1953125
p : 0.390625
y : 1.31844489158 meter
corr: 1.32 meter
err : 0.0015551084195
|
Btw, I first tried this using your y=sqrt(...) equation, but it didn't work out very well. It worked pretty well (ie looked much like the k/p-graph), but when I varied the 'yaw' point I couldn't make any real conclusions of the results. I probably did something wrong. I still have the code around if you want to work on it though.
Oh, I think that 1320 is based on 264/0.2 =1320, where 0.20 = 20 centimeters (~sensor bar length). But we dont need no stinking magic numbers anymore, right  |
|
| Back to top |
|
 |
dimevit
Joined: 07 Jun 2007 Posts: 2
Digg It |
Posted: Tue Jun 19, 2007 4:25 pm Post subject: Yaw |
|
|
hi wic,
i see, you are very good in this yaw calculation. Do you have some code for the calculation of the yaw. If you have can you send me a mail on
vitanovski@arcor.de please. I need the calculation of the yaw for one projectr on the university in germany
Thanks,
Dime Vitanovski |
|
| Back to top |
|
 |
Oinquer
Joined: 14 Nov 2007 Posts: 44
Digg It |
Posted: Thu Jan 17, 2008 5:37 pm Post subject: |
|
|
sorry for spamming this board...here i am trying to solve one problem...
i never been good at mathematics...so i ask you guyz here if you can give me at least the formula for this thing.
ok the 35ยช its the fov you guyz found out.
the bottom of the triangle its the Z wich equals to 43.18 Cm
i need to find out the X and the Y...
some buddy told me to cut the triangle in half and with the tangent find the side im missing for the pitagoras formula...
can you guyz gimme the formula or if youre really kind answer it and explain it at same time.[/img]
edit: found an app that calculated it for me...gave me 66cm on each side...if someone can confirm it. tkx |
|
| Back to top |
|
 |
wic
Joined: 26 Mar 2007 Posts: 57 Location: Sweden
Digg It |
Posted: Thu Jan 17, 2008 9:49 pm Post subject: |
|
|
This is an isosceles triangle, which means the last two angles are equal (180-35)/2 = 72.5
Anyway, divide the triangle in half by drawing a height from the top to the bottom (dividing 35 deg. angle in two, ie 17.5 deg.) and you end up with two right triangles. The base (z) is now 43.18/2 = 21.59 cm.
Use sin(17.5) = 21.59 / x =>
x = 21.59/sin(17.5) = 71.8 = y
You can play around with it here for instance: http://ostermiller.org/calc/triangle.html |
|
| Back to top |
|
 |
Oinquer
Joined: 14 Nov 2007 Posts: 44
Digg It |
Posted: Fri Jan 18, 2008 11:52 am Post subject: |
|
|
| yep that 70 cm, tkx then buddy... =) |
|
| Back to top |
|
 |
TheDro
Joined: 10 Feb 2008 Posts: 39 Location: Canada
Digg It |
Posted: Thu Feb 28, 2008 1:20 am Post subject: |
|
|
I don't think you should all be looking for such precise equations in the first place since the distance between the leds(at least on an official sensor bar) can vary. The light are set up like /|||\ so if you're on the left the wiimote could be picking up a different led than when you're centered etc.
You should just find an approximate formula that gives the distance between the wiimote and the bar. Finding a really precise formula using imprecise data isn't really worth it. We use estimations in physics and engineering all the time because it's quicker, easier and it doesn't matter if your position is off by 10 cm or so. Another factor adding an error to all your complex triangulations is that the wiimote isn't exactly perpendicular to the screen, and you're probably holding it at an angle so both of your dots aren't exactly on the same Y axis height.
Oh and btw, are you guys looking for the perpendicular distance to the bar or the actual distance? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|