Monday, April 22, 2013

3D Scanner Theory

Theory

This entry I will cover some of the theory behind the laser. The first image is the concept on capturing the image with the webcam.
The webcam and the laser will have a fixed angle between them. The webcam will capture a 2D image with laser outlining the profile of the object. The picture will have captured the distance from the center of the image to the laser which is defined as 'B'. Knowing the angle between the webcam and laser and measuring the distance B from the captured image, the 'R' can be calculated from trig using sin(Beta)=B/R. This distance B and R is captured for each image taken, for mine its 200 images. The larger the angle between the webcam and the laser, the less error you will get with the depth. Taking a 2D image will profile the image in a perpendicular plane. The smaller the distance between the perpendicular plane and the laser, the less error you will have from te depth of the object being captured in a 2D image.

After the 'R' value is determined, this has to calculated to the X,Y and Z coordinates. The picture below explains.
'R' is a distance defined in the X-Y plane, shown my the large red dot. The red plane is where the line laser acts. If we know 'R' we can again use trig to calculate its location in the X-Y plane. The Z coordinates simply goes by the height of the object. To convert to Cartesian coordinates, the following equations are:
x = ro * cosinus( fi )
y = ro * sinus( fi )
z = z

Code

All my calculations come from how python stores the images. The JPEG's store R,G,B values so my program looks for the brightest Red value because I have a red laser. The pixel location is easy is is stored in a 2-D matrix starting with pixel location 0,0 and ending, for a 620x480 image at 620,480. I chose to look for the brightest red pixel so its ok to scan with some ambient light and it does not have to be done in the dark. My code is in the link below.


No comments:

Post a Comment