It's aliiive
Jan. 1st, 2010 05:54 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
I made a New Year's resolution to get my geek on more. With that in mind I've spent some time today working on robot software. I now have stereoscopic robot vision, woo! Using my stereo webcam the robot can calculate angle to and distance of any object that its blob detection picks up (two normal webcams would work about as well, and that's what I tried first, but I've had distinct difficulty mounting the things parallel to each other with sufficient accuracy so I took the easy way out; besides, the Minoru is kind of cute).
Basically, I know the difference between the two eyes (60mm) and the FOV of the cameras (40 degrees). Using this and the X position of the detected blob in each webcam image, I can calculate angles from each lense to the blob giving this triangle -

where the object is at the apex, the cameras are at a and b, and angles a and b and length C are known. From there I calculate the top angle then use trigonometry to figure out the length of each remaining edge. For now I just average those, but at some point soon I should be able to break down the triangle into two right-angle triangles and figure out the Cartesian coordinates of the object. If I do the calculation twice, once for each edge of the blob, I should be able to calculate its width too.
The distance calculation looks mostly accurate with my red testing softball, at least at the 20-60cm range, but it tends to jump around a surprising amount for some reason. I suppose I might get better results with wider-placed lenses (which would require going back to my old camera system), but this is probably fine for now.