# Machsupport Forum

## Mach Discussion => Video P*r*o*b*i*n*g => Topic started by: Don C on December 01, 2007, 02:00:33 PM

Title: setting up cammera and laser
Post by: Don C on December 01, 2007, 02:00:33 PM
How is the camera to laser setup. Is the camera and laser running parallel to the X axis (X axis moving front to back (gantry)). What should the angle be of the camera and the laser. Is there any setup notes yet?
Don
Title: Re: setting up cammera and laser
Post by: TomHubin on December 03, 2007, 12:09:00 PM
Hello Don,

The laser line generator is pointed down, parallel to Z axis, oriented in the YZ plane.

The camera is located a few inches to the left of the laser. It is pointed down and to the right so that it crosses the laser plane at an angle.  A forty five degree angle is a good place to start experimenting.

The goal is to image the laser, and nothing else, onto the camera detector so that the laser ZY plane is imaged onto the camera HV plane. That is, the Z dimension of the laser is imaged onto the camera horizontal dimension and the laser Y dimension is imaged onto the camera vertical dimension.

This is shown at http://www.sensorland.com/HowPage056.html, except that this view shows the camera to the right of the laser.

Try to find a camera with a small angular field of view. Let's say, about 10 degrees. That will image about a 1 inch section of the laser onto the full size of the detector. If you use a wide angle camera, let's say 45 degrees, then you will probably image a 4 to 6 inch length of the laser in the Z dimension. Accuracy is some fraction, possibly 1%, of the full section imaged. So you want to image a small section to get some accuracy.

Also, short depth of field is desirable. Pinhole type webcams focus over a huge range. Let's say from 12 inches to 12 feet. You want points in the laser ZY plane to be in focus on the camera detector and you want everything else out of focus. That is, if something is closer to the camera than the laser or farther from the camera than the laser, you want that feature blurred. You cannot exactly achieve that with a prepackaged camera and lens, but you can come close. To shorten the depth of field use a larger diameter camera lens. That will collect more light from the laser while spreading background light out.

http://www.multires.caltech.edu/pubs/DGPCourse/CurlessChapter.pdf pages 4 and 5 show the correct orientation of the detector as NOT perpendicular to the lens optical axis. This is known as the Scheimpflug condition. (Say that fast three times). This is the way that the pros do it to get high accuracy. This can be done if you mount the camera separate from the lens.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: Don C on December 03, 2007, 12:27:50 PM
Don :)
Title: Re: setting up cammera and laser
Post by: DavidCousins on December 03, 2007, 01:08:37 PM
Tom,
I went back to Arts pictures to confirm your description and wow you are correct the laser line is in the YZ plane.   I thought the laser line would be in the XZ plane.   In another thread, Art indicated that the gantry movement was in the Y direction, which doesn't make sense to me.   I thought we'd want to step in a direction perpendicular to the laser line.

What am I missing?
Dave
Title: Re: setting up cammera and laser
Post by: TomHubin on December 03, 2007, 02:52:02 PM
Hello Dave,

You have to move a small amount (say 0.010 inch) in the X direction, stop, then grab the frame, then find the spike in each horizontal camera line. This produces a set of (V,H) camera coordinates which will uniquely map to (Y,Z) machine coordinates. The X value is taken from the machine.

When you have completed the X scan you move back to the start of X and over to the next Y value. The Y increment is the width of the track that you just took. That could be a quarter inch or several inches depending on your setup.

You are raster scanning your part in X and Y with small steps in X and large steps in Y.

In order to create the cloud of points in XYZ coordinates you need to know how to map the (V,H) camera coordinates to (Y,Z) machine coordinates. This requires some calibration of the camera and laser combination.

One simple method is to move the head of a pin in the YZ plane of the laser. The pin head should image to a small area on the camera. You could move 0.1 inch steps in Y and Z and find the center of the hot area on the camera for each (Y,Z). This is probably not the most accurate method but it is easy to demonstrate.

Tom Hubin

Title: Re: setting up cammera and laser
Post by: DavidCousins on December 03, 2007, 04:18:12 PM
Tom,
The light bulb is not burning to brightly right here.

Your description makes me think that the program scans a narrow camera view in the X direction, then translates in the Y, a distance equal to the narrow view.  Then repeats the X scan.  How am I doing?

Makes me think of a Zamboni cleaning ice, except all scans are directly adjacent to each other.
Dave
Title: Re: setting up cammera and laser
Post by: Don C on December 03, 2007, 04:24:15 PM
I think the line should go across the tablle (from left to right) and the camera travels with the light from front to back. Correct or not?
Don
Title: Re: setting up cammera and laser
Post by: TomHubin on December 03, 2007, 06:11:27 PM
Hello Don,

If you arrange the laser so that it is on the left end of the table with laser light traveling from left to right then you will be locating points on the left side of your part. Not what most folks want.

However, I think that what you are trying to do is make the laser plane parallel to the detector plane. This is the way the camera was meant to be used. However, getting data on the left side of a part is not popular.

It would make more sense to have the laser pointed down so that the light is in the YZ plane. Then locate the camera on the left end of the table looking to the right and focused on the laser YZ plane. This would allow you to measure the height of points on a surface. However, most points would be occluded from the camera. That is, laser light hits the part at some point but the light scattered from that point often cannot get to the camera.

So you raise the camera above the surface then rotate it clockwise so that it is pointing in the neighborhood where the laser light hits the surface. This works fine for a pinhole camera but not so well for a camera lens of significant diameter.

As the camera lens diameter increases it becomes apparent that the plane of the laser is not imaged on the detector unless the detector is also rotated an appropriate amount. I have formulas and graphical methods for all of that but I want to avoid the math until the principle of operation is established.

Some of this is explained here:
http://www.multires.caltech.edu/pubs/DGPCourse/CurlessChapter.pdf pages 4 and 5 show the correct orientation of the detector as not perpendicular to the lens optical axis. This is known as the Scheimpflug condition.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: TomHubin on December 04, 2007, 10:20:13 AM
How is the camera to laser setup. Is the camera and laser running parallel to the X axis (X axis moving front to back (gantry)). What should the angle be of the camera and the laser. Is there any setup notes yet?
Don

Hello Don,

Try this experiment to demonstrate the concept of laser triangulation.

Install a simple laser pointer (not a line generator) in the spindle. Use a drill chuck or endmill holder or collet. Whatever works. Battery operated pointer might be easier to avoid wiring difficulties. Otherwise, figure out how to route laser pointer wiring. DO NOT RUN THE SPINDLE MOTOR.

The laser is pointing downward and hitting a piece of white paper on the XY table. You see a bright red spot where the laser hits the paper.

Attach the camera somewhere on the Z axis and pointed down at the bright red spot where the laser hits the paper. Use tape or rubber bands to lash the camera into place. You should see the bright spot somewhere on the camera monitor screen.

Move the Z axis up and down and observe that the bright spot on the monitor moves. For every Z position the spot appears in a unique location on the monitor.

Tom Hubin

You probably also see the table and whatever happens to be in the field of view of the camera. Turn off all of the nearby lighting. This will make the table and other stuff disappear but the laser spot is still visible.

Again, move the Z axis up and down and observe that the spot moves on the monitor. Other than the laser spot, the screen should be pretty dark.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: Don C on December 04, 2007, 11:06:44 AM
The example art shows is a line laser not a point laser. I have used David, and triangle and both use a line laser. I also own a nextengine 3d laser scanner. I think your confused and should find out what is correct before giving advice.
I could not resist
Don
Title: Re: setting up cammera and laser
Post by: Greolt on December 04, 2007, 04:46:51 PM
To be fair,  Tom was using the example of a spot laser just to make the concept clear.

Thanks for taking the time Tom.

Greg
Title: Re: setting up cammera and laser
Post by: Don C on December 04, 2007, 05:06:34 PM
Its hard enough to get a answer that is plane and to the point. To often poster try to make things harder than they need to be. When someone answers a post with wrong or misguided info it just makes it harder for folks that need an answer they can use. All I wanted to know was the placement of the laser in referance to the camera.
Thanks
Don
Title: Re: setting up cammera and laser
Post by: TomHubin on December 04, 2007, 06:43:22 PM
The example art shows is a line laser not a point laser. I have used David, and triangle and both use a line laser. I also own a nextengine 3d laser scanner. I think your confused and should find out what is correct before giving advice.
I could not resist
Don

Hello Don,

My apologies for directing my previous post to you. You are correct. Your query was specific about setting up a line laser and my response was meant to be a general tutorial to demostrate the principle of laser triangulation with minimal equipment.

So, although I stand by the accuracy and usefulness of my response, it did not answer your question and I should not have quoted your query.

This is only my second day on this forum and I am just getting the hang of how to post. Perhaps I should have started a new thread for discussion of laser triangulation basics.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: GAWnCA on December 05, 2007, 08:09:18 PM
Does it really matter in which axis the camera and the laser are installed as long as the movement and capture are in the correct direction?  You could mount the laser and camera on the vertical with the line being on the horizontal.  I see why Art did it this way, he took advantage of his CNC machine and it's ability to move in precise steps.
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 18, 2008, 10:12:36 PM
Tom

You say in a previous post you want a short depth of field (DOF) and a narrow field angle (FOV)...why? I would think you need at least 1.4 times (if the camera plane and the laser plane are at 45 degrees to one another) the field view so that the laser is in sharp focus when its in the camera's field of view. I am not sure if fully follow what Art is doing in his setup, does he change the camera/ laser height to get a deeper measurment?

The way I see it if the height above the object being scanned is fixed the maximum measurable distance in the Z direction will be the camera field of veiw devided by 1.4  for a 45 degree intersection of laser plane and camera axis.

I understand that minimising both feild and DOF will increase the pixel to displacement amount therefore increase scanning resolution but maybe we should work backwards from a desired resolution (plus safety margin like 3 times) and then decide what FOV is desirable to acheive this.

Cheers

Mark

Title: Re: setting up camera and laser
Post by: TomHubin on February 19, 2008, 05:27:17 AM
Hello Mark,

Thanx for commenting and questioning. I work best in an interactive mode.

Accuracy depends on being able to find the center of the image of the laser where it encounters the target surface. Noise, like illuminated background objects, can be a serious problem. Part of the solution is to make the laser diameter very small so that it is 100 to 10000 times brighter than any other light on the target surface. Another part is to be sure that the laser is to be imaged small on the camera ccd array while anything closer or farther is blurred.

That means that the laser plane must be imaged onto the ccd plane. A short depth of focus will permit a fine image of the laser while blurring any sources not originating in the laser plane.

Most of the drawings I have seen that explain the principle of laser triangulation show a single line being traced from the intersection of laser and target, through the center of the lens, to the ccd array. This is valid for a pinhole camera that does not have a lens but uses a tiny pinhole instead. Unfortunately a pinhole camera has low resoultion, low sensitivity, and high depth of focus...all undesirable characteristics.

When you use a lens you need to consider the point where the laser encounters the surface as a small source scattering light in all directions. A cone of that light passes through the lens and is imaged to a small area. If you trace several such cones you will find out that if the ccd array plane is parallel to the lens plane then the laser plane must also be parallel to the lens plane. If this is not so then most of the points in the laser plane will not be imaged onto the ccd array. Putting it another way, the "points" on the ccd array will be large blurs.

To use an inexpensive camera like a webcam, with the lens built in so that the lens plane is parallel to the ccd plane, it is necessary to arrange the camera and laser so that the laser plane is also parallel to the ccd plane.

Ideally the laser would point straight down the z axis and the camera would be off to the left and looking to the right. However, the camera's view would be blocked by the target.

A more practical solution would be for the assembled gauge to be rotated. Suppose the setup is rotated 30 degrees CW. Then the laser plane is 30 degrees CW of the z axis and the camera axis is 60 degrees CCW of the z axis. The ccd plane and lens plane are parallel to each other and to the laser plane. This also results in very little distortion since the only source of distortion is the lens itself.l

Certainly it is desirable to package in other ways. Like maybe have the laser pointed straight down the z axis and have the camera axis 30 degrees CCW from the z axis. This is the type that I used to design. The problem is that the laser plane is not parallel to the ccd plane. In order to form an image onto the ccd array it is necessary to separate the lens from the camera and mount it at an appropriate angle.

We can talk about those calculations if there is interest. But to use a prepackaged camera and lens it is essential that the laser plane be parallel to the ccd and lens planes. The lens should have the lowest fNumber you can arrange so that only the laser plane is imaged onto the array while background and foreground are blurred as much as possible.

If you do this then you can turn off the camera AGC and set the exposure time for 1ms or less. All of the foreground and background will be black since the exposure time is so short. The laser scattered from the target will be bright enough to be detected by the camera and it will only cover a few pixels. This allows for faster capture of frames and faster processing of the small data set.

I don't know what hardware arrangement Art and others are using. The written descriptions that I have seen have been vague and I have seen no drawings.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 19, 2008, 06:30:44 PM
Thanks Tom

Ok I now understand. What I was confused with was your decription and Arts setup which shows the included angle between the laser plane and the optical axis being around 45 degrees.
My background is also in laser imaging and electronics as I used to work for an imagesetter manufacturer in Canada. So I understand flat field optics and laser beam shaping and have access to some parts from some decommisioned gear at my new job (actually 90% of my CNC router is being built with salvaged high quality parts)

So if I understand correctly the ideal is to have a F-theta type optic in front of the CCd to bring the laser plane in focus over the entire CCD while still having the camera axis a something less than the ideal 90 degrees included angle (FYI for those not familiar with F-theta optics they are a special type of lens (usually an array of lenses) that has different focal lengths F depending on the incident angle theta and are used in all flatbed imaging devices like photocopiers and scanners)

Now I guess the challenge is to either find just the right optic (\$\$\$ and quite involved) or to use sofware to find the center of a fussy beam image (less than ideal and sacrifice accuracy and resolution). The later is the approach that seems to be favoured by both Art and the David setup.

Anybody got access to ray tracing software? Might make finding the right layout and optics choice easier.

I am still a long way from completing my CNC and have a huge pile of parts waiting to be assembled so unfortunately I can't test much right now but when it is all together I plan on using high res B/W securiity cams which were part of a machine vision system and either buy a cheap laser pen or use the high end optics that I also have out of an old imagesetter and add a line gen optic.

Cheers

Mark

PS When I do get to the test stage I have access to a laser power meter and 2 axis beam scan collimation shearing plates, stearing first surface mirror etc etc..This is not however the case for most people and thus maybe those of us that have the gear and some i dear,  can come up with a simple solution thats more obtainable to the masses. I think software solution is the go but maybe we can improve the overall performance with a bit of optical enhancements.
Title: Re: setting up cammera and laser
Post by: TomHubin on February 20, 2008, 01:13:56 AM
Hello Mark,

> So if I understand correctly the ideal is to have a F-theta type optic in front of the CCd
> to bring the laser plane in focus over the entire CCD while still having the camera axis a
> something less than the ideal 90 degrees included angle

No. The lens is a typical imaging lens...an fTan(theta) lens if you want to put a math label on it. An fTheta lens is used to produce a constant velocity line scan from a rotating mirror. An fTheta lens will produce distortion if used for imaging.

I will say that a small angular field of view is preferred as that is simply a longer focal length and otherwise nothing special. A short focal length lens produces a wide angular field of view but usually also produces significant barrel distortion unless you buy an expensive wide angle lens. Try to keep the full angular field of view under 20 degrees where the tangent of the angle is nearly equal to the angle in radians. Focal lengths in the 10mm to 25mm range are much better than 3mm to 10mm range for low distortion.

> Now I guess the challenge is to ... use sofware to find the center of a fuzzy beam
> image (less than ideal and sacrifice accuracy and resolution).

Bad plan. That is like saying that you will not use an antenna because you can digitally salvage a radio signal. There is only so much you can do with software to salvage a poor signal buried in noise.

I do.

> Might make finding the right layout and optics choice easier.

I have done this many times. However, I need the lens prescription to do a proper trace. That info is not included with a \$30 webcam. I have reverse engineered one camera but cannot possibly reverse engineer the variety of cameras being used by this group.

When I did this for hire I started with customer requirements then chose the camera and its lens and the laser and its lens from optical engineering catalogs and designed everything else. Costwise these components put the project out of the amateur's reach.

But to see for yourself how bad it is when the ccd plane IS parallel to the lens while the laser plane IS NOT parallel to the lens you need only do a paraxial ray trace on graph paper or with line drawing software. If I can figure out how to post embedded drawings I will post some and describe the problem details.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 20, 2008, 08:20:28 AM
Hi Tom

Its good having a 10 hour time delay between us (Your in the UK? aren't you?) as it allows me think about your response and come up with some more questions.

Like I said my background is going the other way and putting a focused beam onto a flat surface that is orthogonal to the center of the scan rather than read an image back to a CCD. Hence the need for optics that have longer focal lengths at the sides of them than at the center. BTW they don't actually do a perfect job of creating a constant velocity scan and the artifacts (compression and expansion of the image in the scan direction) are removed by manipulation of the data clock which is frequency locked to the scanner... but I digress.

I am still not clear on what type of optic element would be required to keep the laser in focus with a non orthogonal CCD axis to laser plane. I would have thought it would be some form of cylindrical lens or prism not just the standard lens mounted at an angle to the CCD.

First off I am only interested in the image of the beam at the point it crosses the horizontal line of the lens.
Lets assume I want the camera axis looking straight down and the laser plane intersecting it a 45 degrees from the RHS.The image from the camera is in landscape and the laser plane draws a vertical line.
Lets also say that when the beam is imaged in the center of the CCD that this represents Z(measured)=0 and if it is to the right this is Z(meas) >0 to the left of center Z(meas) <0
We want the beam to be in focus for the entire range from left to right but the distance is varying hence the need for a longer focal length of the LHS compared to the RHS.

Looking at it another way if I was to place a DOF scale (with the same angle as our beam angle) under the camera the entire scale should be in focus if the center is in focus.

I usually draw pics to help explain what I'm thinking so this may or may not make any sense.

I agree that you can only salvage so much from a poor signal, I also agree that good optics are outside the scope of what most of us are able to use in our designs (like I said previously \$\$\$ and quite involved) so we have a catch 22.

You can however do some pretty neat stuff in S/W to reduce the effects of noise much the same way that you do in electronics through differential inputs. For example take the image frame with the beam on minus the same frame with the laser off.
You are also right in pointing out that you will most likely have either barrel or pincushion distortion but this too can be compensated for by s/w calibration using a look up table and a known gauge block.

I may be wrong but I would think a B/W security camera would be better suited to this app than a Web cam. You don't need colour as you will just be filtering out as much as possible outside the 670nm (for HeNe or for whatever colour laser you chose) plus the single CCd may be less noisy and most likely higher res. I would think that one could get one of these fairly inexpensively since everyone wants colour theses days.

So the question now is.... If one has a camera and separate lens is it a simple matter of adding another optical element between them to get the desired effect and if so what does this beast look like?

My setup consists of Panasonic B/W security cam with a 1/3" CCD  a 5mm extension tube and a 50mm 1:1.8 lens . this gives a focal length of around 12" with a FOV of around 1"
I can make the image even tighter using a 2x adapter but that really restricts the FOV and hence the measurement range plus by changing the extension tubes I can increase or decrease the working range which will depend on how I end up mounting the gear.

The other thing that I would think is a trade off is that as you decrease the included angle between the camera axis and the beam plane the measurement range goes up while the resolution goes down while the FOV remains constant.

Cheers
Mark
Title: Re: setting up cammera and laser
Post by: TomHubin on February 21, 2008, 03:08:47 AM
Hello Mark,

> Its good having a 10 hour time delay between us (Your in the UK? aren't you?)

Nope. Just a night person in Maryland USA.

> I am still not clear on what type of optic element would be required to keep the laser
> in focus with a non orthogonal CCD axis to laser plane.

Nothing special. An ordinary imaging lens is all that you need.

You need to read about the Scheimpflug principle. Many references in a google search. Reading about it will make you cross eyed and dazed until the instant that it makes sense.

Here is a mini lesson.

Let's define the optical axis as the line perpendicular to the lens plane and passing through the center of the lens.

odist is the distance from lens to object plane as measured along the optical axis.

idist is the distance from lens to image plane as measured along the optical axis.

latmag = -idist/odist is lateral magnification where the optical axis intersects the object and image planes.

It is customary for the object plane to be parallel to the lens plane. In that case the image is also parallel to the lens plane.

However, if you tilt the object plane so that it is NOT parallel to the lens plane then the image plane will also be tilted so that it is NOT parallel to the lens plane either.

To be more specific,

tan(image tilt angle) = latmag*tan(object tilt angle)

or

image tilt angle = arctan(latmag*tan(object tilt angle))

> You are also right in pointing out that you will most likely have either barrel or pincushion
> distortion but this too can be compensated for by s/w calibration

agreed

> I would think a B/W security camera would be better suited to this app than a Web cam.
> You don't need colour as you will just be filtering out as much as possible outside the
> 670nm (for HeNe or for whatever colour laser you chose) plus the single CCd may be
> less noisy and most likely higher res. I would think that one could get one of these
> fairly inexpensively since everyone wants colour theses days.

I agree about B&W being better and cheaper than color. However, webcam vs BNC is a debate about connector and communication styles. Either type has both good and poor quality cameras. I am accustomed to the Sony XC-75 but that is a \$500 BNC CCTV camera and then you need to buy a frame grabber and do some programming. Webcams are convenient because they are cheap and plentiful and...most important...that is what Mach3 uses.

> So the question now is.... If one has a camera and separate lens is it a simple
> matter of adding another optical element between them to get the desired
> effect and if so what does this beast look like?

Only one lens needed. See the math above to start.

> My setup consists of Panasonic B/W security cam with a 1/3" CCD
> a 5mm extension tube and a 50mm 1:1.8 lens . this gives a focal
> length of around 12" with a FOV of around 1"
> I can make the image even tighter using a 2x adapter but that really restricts
> the FOV and hence the measurement range plus by changing the extension
> tubes I can increase or decrease the working range which will depend on how
> I end up mounting the gear.

You need to start with your requirements and do the math to determine lens focal length and location and orientation. Then find a close lens and redo the math to fit the chosen lens focal length.

There are graphical techniques as well as math for the layout but you really need to get a handle on the Scheimpflug principle first.

> The other thing that I would think is a trade off is that as you decrease the included
> angle between the camera axis and the beam plane the measurement range goes up
> while the resolution goes down while the FOV remains constant.

The ANGULAR FOV remains constant.

The resolution at the near end of the measurement range is the best while the resolution at the far end is the worst. Kind of like your own vision. You might judge distance to a far away object as 100 feet plus or minus 10 feet and the distance to a nearby object as 10 feet plus or minus 1 foot.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 21, 2008, 05:28:39 AM
Thanks again Tom

Looks like I have home work  ;D first thing will be to figure out how to pronounce Scheimpflug  ???

I'll try slapping something together to do some testing as it may help Art with his s/w debugging if he can separate problems caused by poor optics from those in his algorithms. I have a couple of cams with no labels but the internals have Sony components the other one is a Panasonic WV-BP554. and planned to use a USB video capture dongle I have used to stream video to the web (nothing kinky just the Sydney Hobart race start)

Maybe a bit of destructive reconstruction will be needed with the webcams to "fix" their optics alignment.

Thanks for the formulas as it gives me a starting point to get my head around the issues. Its interesting how magnification has an impact on the tilt angle.

So if I am doing the math properly... simplifying everything if one has a 45 degree object plane and a 1:1 magnification then the lens axis would be tilted 22.5 degrees to rotate the image plane to the CCd plane.

I don't have one but I think the cheap CCd cams one can get at Jaycar or Dick smith (like radio shack / Tandy) are focusable so the optics can be unscrewed and possibly modified.

Well I better go off and start reading my homework.

Cheers

Mark

Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 21, 2008, 06:00:36 AM
Ok so I need to make one of these :
http://www.oxfordlasers.com/imaging/accessories/scheimpflug_mount

An figure out all the relative geometry to get all the planes to intersect at the right place.

Now that I see how it works I realise that we used perspective corrective lenses  (keystone correction) when I used to do multi projector slide shows in a past job. So that's how they worked!

Brains a bit rusty as I haven't had to use it much in my present job... this is like a get fit routine for my head.

I'm sure with some of the talent around here that have built their own CNC mills etc etc knocking up a mount similar to the one shown should be a breeze.

Cheers

Mark
Title: Re: setting up cammera and laser
Post by: TomHubin on February 21, 2008, 06:37:21 AM
Hello Mark,

> Looks like I have home work  ;D first thing will be to figure out how to pronounce Scheimpflug  ???

I have had that problem for years. I still have that problem.

> I'll try slapping something together to do some testing as it may help Art with his s/w debugging
> if he can separate problems caused by poor optics from those in his algorithms.

I plan to do the same. Design for a simple non-Scheimpflug layout is nearly complete. I hope to machine the pieces in a few weeks then send a completed laser triangulation gauge to Art to evaluate. I hope to convince him that he needs to disable AGC and set exposure time for less than a millisecond to make all disappear except the laser.

> Thanks for the formulas as it gives me a starting point to get my head around the issues.
> Its interesting how magnification has an impact on the tilt angle.

BTW, that lateral magnification is only valid at the points where the optical axis crosses the object and image planes. It is just a useful number that you can relate to conventional optical layouts. The actual linear magnification needs to be calculated parallel to the object plane and its corresponding point parallel to the image plane. This number will vary with distance from the optical axis.

> So if I am doing the math properly... simplifying everything if one has a 45 degree
> object plane and a 1:1 magnification then the lens axis would be tilted 22.5 degrees
> to rotate the image plane to the CCd plane.

I am not sure what you are saying but it does not sound right. If you have 1:1 magnification then the image plane tilt with respect to the optical axis must be equal to the object tilt with respect to the optical axis. Try laying it out with a paraxial ray trace on graph paper.

Start with all planes vertical. Object on the left, image on the right, lens between them, light traveling from left to right, object distance equal to image distance equal to twice the lens focal length. Then rotate the object plane 45 degrees CW about its center. Trace from the object end points through the lens to the image end points. You will find that the image has rotated 45 degrees CCW. In this particular arrangement the image plane is perpendicular to the object plane.

In a triangulation gauge you are more likely to have latmag between -0.1 and -0.5.

> I don't have one but I think the cheap CCd cams one can get at Jaycar or Dick Smith
> (like radio shack / Tandy) are focusable so the optics can be unscrewed and possibly modified.

I have reverse engineered the optical and mechanical essentials of the 3Com Watchport/V. This is a nice security webcam that lists for \$150 but regularly auctions on ebay for \$10 to \$35, including shipping. I like the 12mm focal length f/2 lens. You take pot luck on which lens comes with it but you can get lens sets for it on ebay. The lens thread is M12-0.5. The active CCD area is 3.6mm x 2.7mm. And it is very close to CS format as I measure with calipers. Four Torx T9 screws hold the covers together and two Torx T8 screws hold the lens mount in place. Windows drivers and standalone software are sometimes included on CD but it is also on the internet for free.

> Well I better go off and start reading my homework.

Be careful! If you fall asleep while reading about Scheimpflug you will have Scheimpflug nightmares. ;-)

Tom Hubin
Title: Re: setting up cammera and laser
Post by: TomHubin on February 21, 2008, 06:56:18 AM
Hello Mark,

Ok so I need to make one of these :
http://www.oxfordlasers.com/imaging/accessories/scheimpflug_mount

In principle, yes. In practice, no.

The camera above is adjustable to accommodate any angle that the photographer needs. For a laser triangulation gauge there is only one angle and that is determined by your design.

A typical design would have the laser pointed straight down (parallel to z) and the lens up to the left 30 degrees CCW from the z axis. This would mean that the object (the laser) is tilted 60 degrees CCW from perpendicular to the optical axis. Assume you have a lateral magnification of -0.2. Then the ccd array would be tilted 19.107 degrees CW from perpendicular to the optical axis. Plug the CCD array into the drawing and trace the endpoints through the lens center to see where they intersect the laser.

This assumes that you know the lens focal length and that the lens is thin. To really nail it down you need to ray trace through the lens prescription...if you can get the prescription.

Are you in Australia?

Tom Hubin
Title: Re: setting up cammera and laser
Post by: Ian Ralston on February 21, 2008, 07:09:27 AM
The penny, I hope, drops at last!
I have been watching this thread as I have an interest in scanning and purchased a line laser but I was having a problem understanding this discussion. Scheimpflug! Now I can relate it to photography. In the days of technical plate cameras, it was usual to have a rising front lens plate or a tilting back plate holder. The idea was to be able to get architectural photos without the building looking as if it tapered to the top of the picture. Olympus even did a fancy lens for their OM series SLR cameras to achieve this effect.
You could also get the same correction by tilting the baseplate of the enlarger when printing but you needed to stop the lens right down to get the depth of field to keep the focus sharp.

So, please tell me if I have got this right.

The center of the object, lens and CCD should all be on one line. The planes of the object, lens and CCD should all intersect at one line. The problem then is to set the webcam at 45 degrees and make a lens mounting that fulfills these conditions. This should be only a matter of allowing for some lens tilt and ability to bring the lens onto the centerline - a relatively easy mechanical design problem. This will enable the laser line to be in focus across the CCD.

Or have I got it wrong again!

Ian
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 21, 2008, 04:25:40 PM
Hi guys

The penny dropped for me when I saw the plate cameras also in the Wikipedia description of Sheimpflug (Did this guy invent his name just to make it hard for the rest of us to say it or what!?!)

Yeah Tom I'm a Cunuck in the land down under.

The problem between in principle and in practice makes me think an adjustable (although not with a huge amount of range) mount may still be desirable that way if you don't have all the specs for the optics you can shoot for ball park then tweak to get it spot on like I believe you do with plate cameras.

Happy testing.

Cheers

Mark
Title: Re: setting up cammera and laser
Post by: TomHubin on February 21, 2008, 08:53:17 PM

> In the days of technical plate cameras, it was usual to have a rising front lens plate

This method keeps the object, lens, and image planes parallel. This method introduces no distortion. However, the lens must be optimized for wide angle fov. That can mean a very expensive lens.

> or a tilting back plate holder.

This method introduces distortion due to perspective. However, the lens is conventional and the depth of focus need not be high. Hence it is a purely mechanical solution.

> The idea was to be able to get architectural photos without the building looking as if
> it tapered to the top of the picture.
> Olympus even did a fancy lens for their OM series SLR cameras to achieve this effect.
> You could also get the same correction by tilting the baseplate of the enlarger when printing
> but you needed to stop the lens right down to get the depth of field to keep the focus sharp.

I think that the solution for printing is to reverse the process by tilting the film and print paper appropriately to reverse the distortion back to normal.

> So, please tell me if I have got this right.

Yes, but the devil is in the details.

> The center of the object, lens and CCD should all be on one line.

Not actually the centers. The optical axis is perpendicular to and centered on the lens. The optical axis intersects the object and image planes but generally not in their centers.

> The planes of the object, lens and CCD should all intersect at one line.

Correct.

> The problem then is to set the webcam at 45 degrees

or whatever angle you are designing for.

> and make a lens mounting that fulfills these conditions. This should be only a matter of allowing for some lens tilt and ability to bring the lens onto the centerline - a relatively easy mechanical design problem. This will enable the laser line to be in focus across the CCD.

Correct.

I would choose 60 degrees myself. Nothing wrong with 45 degrees but 60 degrees makes a smaller gauge, although it introduces more distortion than 45 degrees. So the choice of angle depends on your accuracy needs over the gauge working range.

BTW, I like to orient the lens so that its optical axis bisects the angular FOV. This minimizes lens aberrations by keeping the angle of incidence on the lens as small as possible.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: Ian Ralston on February 22, 2008, 07:06:36 PM
Tom,

Thanks for your input. I am well out of my comfort zone on this subject and will just have to make a test rig to get a feel for the problems. Art's scanning plug-in for Mach 3 and your technical posts have opened up a very interesting "can of worms."

Ian
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 23, 2008, 07:20:17 AM
Hi Guys

Am I right in thinking that my camera/lens mount should have the pivot point around the ccd plane? The lenses I have are variable focus which  (again if I'm reading this right) will have the effect of pivoting the image plane so I may be able to use this to fine tune the focus across the whole ccd. The other thing this Panasonic camera has which may be helpfull in alignment is the ability to move the CCd inside the camera independently from the body of the camera. I also assume you would want to open the aperture fully to decrease the DOF.

Have done a few really rough tests to get my head around the camera /lens / object alignment and voila it actually works :) I got the video into MAch also using a cheap usb video converter (Kworld USB2800 D)

Tom do you know off hand the formula for theoretical spot size? From memory it had the focal length the aperture and the wavelength as a ratio which would give you the minimum waist dimension for a given beam. I only remember this as that is why the went to blue wavelength lasers as they can achieve a smaller spot (hence greater capacity on a DVD) and may make a choice on which laser wavelength (colour) would be better.
Is this the same for a line generator optic? Does it need to be collimated to a small size or just have a long but narrow waist of a focused beam make it thinner. From what I can make out the maximum depth of measurement will be around 2" so as long as its tight for that much will a focused beam be preferable? Or is any of that really that critical given the design envelope we are working under?

What sort of resolution do we want to achieve?

I know for our machine vision systems that vibration was a real quality killer so a sturdy mount would be advisable.

While I'm thinking about it, did Art figure out what was causing that Z-stepping in his scans? Occurred to me that if the step distance was the same as his FOV for each successive pass that it may have been due to a skewed laser plane. The beam would need to be perfectly vertical in the image (assuming camera on RHS and laser on LHS and scanning left to right) if not the measurements would not be linear across the CCD.
If I was to draw a mental picture it is like you are trying to draw a vertical line on a piece of paper with just 1/2" segments. If you draw each segment perfectly vertical you get a straight line if the segments are tilted you get a staircase. The scan he did of his hand looked like a staircase.

I hope Art is following this thread as there are some good ideas being bounced around.

Anyway just a bunch of off the top ideas and comments. BTW some may be way off the mark but if it promotes discussion then its not a waste on time.

Cheers

Mark
Title: Re: setting up cammera and laser
Post by: TomHubin on February 27, 2008, 08:43:57 AM
Hello Mark,

Sorry about the delay in responding. For now I just have a few minutes for the easy questions.

> Am I right in thinking that my camera/lens mount should have the pivot point around the ccd plane?

Yes. That point will be near the center of the array but usually a little off center. There are choices that you can make but I like arranging the optical axis as the bisector of the angular field of view. That minimizes the effect of lens aberrations by keeping the angle of incidence on the lens as small as possible.

> The lenses I have are variable focus which  (again if I'm reading this right) will have the effect  of
> pivoting the image plane so I may be able to use this to fine tune the focus across the whole ccd.

Do you mean variable focal length or just movable for best focus?

> The other thing this Panasonic camera has which may be helpfull in alignment is the
> ability to move the CCd inside the camera independently from the body of the camera.

Is that movable in z for best focus or is that movable to shift the center in the horizontal and vertical?

> I also assume you would want to open the aperture fully to decrease the DOF.

Yes, assuming that the lens aberrations are small at full aperture. A professional grade lens is usually pretty well corrected at full aperture. The \$10 webcam lenses might be a bit fuzzy at full aperture. But then, a cheap webcam lens won't usually have an adjustable aperture.

> Have done a few really rough tests to get my head around the camera /lens / object
> alignment and voila it actually works :) I got the video into MAch also using a cheap
> usb video converter (Kworld USB2800 D)

Great.

> Tom do you know off hand the formula for theoretical spot size?
[snip several laser related questions]

Yes but there is a lot to discuss just on laser focusing so I think I will start another topic for that. Might be a couple of days before I sit down to do that. Meantime, if you are eagar, you can look up the following subjects:

LaGrange Invariant (sometimes called Optical Invariant)
Etendue
Photometric Brightness
Optical Throughput

> What sort of resolution do we want to achieve?

The real question is "What sort of resolution do YOU want to achieve?" Each of us has some project in mind and probably no two of us agree on the necessary range and resolution. In general, with inexpensive webcams and laser modules, I would expect to get something close to 1% of the working range. I would loosely define working range as the range parallel to the z axis.

With better cameras and laser modules and lens choices I would expect more like one thousandth of the working range. That takes the price out of the amateur range but all of the principles are the same. So this is an inexpensive way to learn how laser triangulation works.

> I know for our machine vision systems that vibration was a real quality killer so a sturdy mount would be advisable.

Sounds reasonable but I don't expect my Sherline mill to vibrate much. The machine should not be in motion when the image is formed just before grabbing the frame.

> While I'm thinking about it, did Art figure out what was causing that Z-stepping in his scans?

Art described his setup as pretty arbitrary. I don't think the laser is imaged onto the CCD array. The calibration procedure and the distortion correction math could also be off. I don't really have enough info on his setup so I can only speculate.

> Anyway just a bunch of off the top ideas and comments. BTW some may be way off
> the mark but if it promotes discussion then its not a waste on time.

I think you are catching on just fine.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on February 28, 2008, 06:39:30 AM
Hey Tom

I was starting to worry that my last post aimed at stimulating disscussion had, in fact, killed it :(

No need to apologize I'm sure everyone following this thread is appreciative of you knowledgable input.

The lens is variable focus and this was actiually a source of grief in its previous use as a machine vision feedback system as the slack in the lens could cause the image to move and thus falsely represent the position of the target it was trying to adjust. I intend to clamp it down once everything is setup.

CCd is moveable in the Z only so some shift adjustment may be necessary in my mount design to ensure the image is in the center of the detector.

Oh No! more homework!

The resolution question is one more related to the final use of this scanner which I assume is for reproducing things on ones CNC so I would hazard a guess that a scanning resolution of twice the machining resolution would be ideal, 1:1 would be adequate and 2:1 poor, Given this assumtion I would think a resolution of say 0.0005" would be great fo a real CNC doing metal work while 0.01" would be fine for wood carving. What do those of you with working machines want?

Happy testing

Cheers

Mark

Title: Re: setting up cammera and laser
Post by: mhasting2004 on April 11, 2008, 10:23:50 PM
Geez it's been quiet in here since my last post.... maybe I did kill it :(

Here's another question to those out there that are testing this plugin and/or  also to Art and co on how it works.

Using the camera and lens setup I have the field of view is only 15mm , is this going to be an issue for the plugiin? i would like to keep this setup as it will have very good resolution per pixel and also hopefully  limiit any specular noise outside the central image.

Am I right in assuming that the point cloud is made up of single captured pixels from each frame grab? I.e it is looking at the height coordinate given by the intercept of the laser line and a vertical stip  of the video image with the X and Y coordinates given by the know CNC position (many snaps). Or, is it storing the whole vector seen in the FOV and is building an image by merging these short vectors (fewer snaps but more susceptible to lens duistortion errors).

I need to get my head around this a bit as the machine I'm building is comming together and it will have an impact on how I mount my unpronouncable schemflug (sp) mount and laser. That is if I will still be able to import one here in Oz since some dickheads have been out targeting planes on final approach with high power ones! Media has been making out that laser pointers are the problem not the 100mW plus ones I've seen videos of.

Cheers

Mark

Title: Re: setting up cammera and laser
Post by: TomHubin on April 12, 2008, 01:22:19 AM
Hello Mark,

> I need to get my head around this a bit as the machine I'm building is coming together and it
> will have an impact on how I mount my unpronounceable schemflug (sp) mount and laser.

I think they end up with shine-floog or maybe shine-flook if you want to sound a little more German.

I'll comment on the technical stuff after I have some dinner. I know it's after 1am but I keep weird hours.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: TomHubin on April 12, 2008, 02:23:27 AM
Hello Mark,

It would be helpful to have some numerical specs on the camera, camera lens, and laser.

What camera are you using? Can you provide a link to specs?

What camera lens focal length and fNumber? Can you provide a link?

What laser? Single point or line generator? Can you provide a link? You will get better accuracy with a single point laser but it will take longer to scan an area with a single laser point than to scan with a laser line. Trying to discuss setup and use for both single laser point and for laser line will be difficult. The single laser point is easier to explain and understand and it is also more accurate. So that is where I prefer to start.

I describe laser focusing elsewhere in the Video Probing forum. Have you read that yet?

> Using the camera and lens setup I have the field of view is only 15mm

Field of view is usually an angular measurement for the camera and lens combined. So I presume that you mean 15mm FOV at a convenient distance from the camera. What is that distance? The distance is usually referenced to a particular plane on the camera or on the lens. For now, just a good guess will do. Maybe something like 100mm from camera lens to laser?

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on April 12, 2008, 03:00:26 AM
Hi again Tom (not another shift worker!)

I did post this info somewhere but to recap 90% of my CNC build including the cameras and lenses are for salvaged platemaking (printing) and film setter (Autologic/ECRM) gear that they were throwing away at work. It may turn out the they are not suitable for the purpose but thought I'd give they a try.

I have two types of cameras (both b/w) that where originally used for machine vision in an automatic bender

the better one :
Panasonic WV-BP554 Super Dynamic
and
Unsure of brand but has a smaller CCD has Sony internal components

Lenses:
Computar brand TV lens 50mm 1:1.8

Using a 20mm tube extender the focal distance is around 150mm  (lens front to object) This also would be the approximate distance (20mm tube extender) that will be present once i make the Scheimpflug lens mount

This gives a FOV (in mm) if the object plane is parallel to the image plane of approx 15mm

USB interface/capture card :

Kworld USB2800D (DVD maker)

At this point I do not have a laser pointer or line generator although I do have some pretty good optics and 5mw laser out of the imagesetters (however will probably purchase a line gen from Edmund or similar in future)

I finally got my head around the manipulation of the focal plane from your very helpfull pointers and a bit of reading on the net. Its more how Art has written his plugin to work that I am fuzzy on. From the descriptions in the forum it would appear most have quite wide FOV and can see the laser line across their calibration blocks in a single frame. That would not be the case with my present setup and I am curious if this is an issue for him.

Cheers

Mark

Title: Re: setting up cammera and laser
Post by: TomHubin on April 12, 2008, 06:37:00 AM
Hello Mark,

> (not another shift worker!)

No. Just a night person.

> I have two types of cameras (both b/w) that where originally used for machine vision in an automatic bender

> the better one : Panasonic WV-BP554 Super Dynamic

I just downloaded the PDF manual and skimmed through it. Output is 1vpp video...not USB. Otherwise looks good. I see below where you mention a video capture to USB device.

> and Unsure of brand but has a smaller CCD has Sony internal components

Can you find out what that is?

> Lenses: Computar brand TV lens 50mm 1:1.8

High quality. That is good.

Using a 20mm tube extender the focal distance is around 150mm  (lens front to object) This also would be the approximate distance (20mm tube extender) that will be present once i make the Scheimpflug lens mount

The lens is probably designed for objects at infinity. How is the image quality for an object distance of 150mm?

> USB interface/capture card : Kworld USB2800D (DVD maker)

Does this take video from camera and convert to USB for the computer?

> At this point I do not have a laser pointer or line generator

AixiZ sells some cheap laser diode modules on eBay. I tried the 3.2vdc, 650nm, 5mw module for \$8 with a 60 degree line generator lens for \$3.40. \$4.00 to ship. These are the 12mm diameter, 30mm long metal tube. I used half inch shrink tube over the module and lenses to stabilize the lenses once I got it all set up. otherwise, the lenses tend to wiggle around and would probably fall off after enough vibration.

I hope to use the 3-5vdc version and tap 5vdc from a USB hub on the laser triangulation gauge. There has been some confusion in ordering the laser modules. They sent me the wrong modules, I returned them for exchange, they sent me something else completely, then they gave me full refund so I could start over, then ebay reordered my previous order along with my new order. As it stands now I am not paying until somebody straightens this mess out.

> I finally got my head around the manipulation of the focal plane from your very helpfull pointers and
> a bit of reading on the net. Its more how Art has written his plugin to work that I am fuzzy on.

I cannot tell how Art has arranged his camera and lens. I think he is just setting them up so that they overlap at an arbitrary angle somewhere in space. Not imaging the laser plane onto the ccd array would account for a lot of his problems with getting good data.

> From  the descriptions in the forum it would appear most have quite wide FOV and can see the laser line
> across their calibration blocks in a single frame. That would not be the case with my present setup
> and I am curious if this is an issue for him.

I think you can use any size cube as a calibration standard. It does appear that the line must cross the full cube width and maybe even reach down to the bottom so the calibration can cover Y and Z.

Objects with a matte finish are easier for the camera to see than mirror-like objects. Ceramic makes a good target since it scatters light pretty evenly. Gauge blocks would probably be bad because of the mirror-like finish. Talcum powder on a gauge block might work. Sandblasted surfaces work well.

My gauge design is complete. Now I need to order materials and tools and then find some time to make chips. This one will not be like yours, with the laser pointed straight down the z axis. This one will be closer to what I think Art is doing but the angles will be carefully chosen to image the laser plane onto the ccd array. My plan is to build three of these and donate one to Art for testing and developing.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on April 12, 2008, 09:08:12 PM
Hi Tom

Still trying to pull up the specs of the other camera but it would be similar to the Panasonic as they were for the same purpose. It is a little less fancy that the Panasonic in that it doesn't have all that alarm and image masking hardware (which may be handy in excluding all the laser line except the region of interest)
It has an adjustable shutter from off to 1/20000
Same video output

The lens image is fine at this distance with no discernible distortion but I haven't looked that close. I have been playing with angles while imaging a steel ruler obliquely to get a sharp focus across the full frame.

I didn't intend on having the laser plane along the Z but more in line with what you have been saying with the camera and lens setup in an adjustable mount to tilt the image plane correctly onto the CCD. The lens by themselves are intended for a focal length of between 1m to infinity that's where the tube extenders come in to shorten this down.

The Kworld is the Video capture device which takes NTSC or PAL or even SECAM input and puts it into the USB port.

I'll check out that site for line generators as the good ones at Edmund don't come cheap. BTW I have access to a Beamscan XY spot size meter so when I do get a laser (in the 670nM range) I'll be able to tell you exactly how gaussian and wide my beam is :).

The main disadvantage I see with using my current lenses is that range of Z measurements will be greatly reduced than with a wider angle lens. If I have a 90 degree included angle between the laser plane and the optical axis (equally spread each side ie. laser plane intersects the table at 45 degrees) then that will only give me sqrt 2 (1.4) times my measured FOV of 15mm or around 20mm of Z depth measurable.  This would be increases the more oblique the optic axis to the bed became but there are limits with this too as one need the camera not to run into the object its scanning not be too blind to the shadow area... decisions decisions.

Depending on what I wish to scan this may be way too small  I would be happier with am max depth scanable of 150mm. One could do slices by indexing the scan head down but again I am not sure how either Arts s/w would cope with this or how I would join the separate meshes latter (probably using Gmax or similar)

I do not believe Art's software works like the David stuff which needs to see the reference background planes to interpolate the height information, but I may be wrong. I really need to get the plugin working so that i can figure it out for myself but I've been concentrating on building my machine of late and I now have a windows\driver\mach3 conflict somewhere on my new laptop that crashes big time everytime I launch a video plugin from mach (blue screen of death) . I'll probably fall back onto the old desktop to experiment.

What kind of ballpark numbers for laser plane and optical axis (plus FOV ) are you shooting for?  Does my scanning resolution versus machine resolution of 2:1 sound right (ie why scan at a higher accuracy than on can then machine?).

Cheers

Mark
Title: Re: setting up cammera and laser
Post by: mhasting2004 on April 13, 2008, 01:32:04 AM
Hi again

Just bought a Cosmicar 25mm C mount lens to try for a wider FOV. First ebay purchase \$5.50 :)  happy camper

Cheers
Mark
Title: Re: setting up cammera and laser
Post by: TomHubin on April 13, 2008, 05:02:06 AM
Hello Mark,

Taking a break from sorting income tax info.

> Still trying to pull up the specs of the other camera

> it doesn't have all that alarm and image masking hardware (which may be handy in excluding all
> the laser line except the region of interest)

I would think that the meshing software will allow you to delete regions that are properly measured but not of interest...like the table that the object is sitting on. There should be no data outside the laser plane bounded by the camera's field of view. The laser is so much brighter than any other lighting that a short exposure time, like 1ms, will black out everything but the laser wherever it intersects the object.

> It has an adjustable shutter from off to 1/20000

If auto exposure is used it should be based on peak value and not the customary average over the entire view. Peak AGC would show the laser and black out everything else.

> The lens image is fine at this distance with no discernible distortion but I haven't looked
> that close. I have been playing with angles while imaging a steel ruler obliquely to get a
> sharp focus across the full frame.

> I didn't intend on having the laser plane along the Z but more in line with what you have
> been saying with the camera and lens setup in an adjustable mount to tilt the image plane
> correctly onto the CCD.

The payoff to allowing the CCD to be tilted is that you can locate the laser just about any way that you want to. Consider a simple laser pointer that is pointed straight down the Z axis and focused to a small diameter on the target 100mm below. Locate the lens off to the left of the laser about 75mm. Point the lens optical axis at the laser waist at the target. The object distance is 125mm since the laser and the lens and the target form a 3:4:5 right triangle.

Calculate the image distance and the image tilt.

clfl = camera lens focal length
od = object distance
id = image distance
latm = lateral magnification
otilt = object tilt (zero degrees is perpendicular to the optical axis)
itilt = image tilt (zero degrees is perpendicular to the optical axis)

Given:

cfl = 50mm

od = 125mm

Calculate:

id = 1/(1/clfl - 1/od)  = 1/(1/50mm - 1/125mm) = 83.333333mm

latm = -id/od = -83.333333mm/125mm = -0.667

otilt = atan(100mm/75mm) = 53.1301 degrees

itilt = atan(m*tan(otilt)) = atan(-0.889) = -41.634 degrees

Since the laser is the center of symmetry the camera can be located on the left or the right or front or rear or several cameras all around.

> I'll check out that site for line generators as the good ones at Edmund don't come cheap.

Also checkout Thorlabs. Not cheap there either but many more choices for laser, housing, lens combinations.

> BTW I have access to a Beamscan XY spot size meter so when I do get a laser
> (in the 670nM range) I'll be able to tell you exactly how gaussian and wide my beam is :).

That is great. I don't suppose we are neighbors. I am in Laurel MD (between DC and Baltimore MD).

> The main disadvantage I see with using my current lenses is that range of Z measurements
> will be greatly reduced than with a wider angle lens.

You can expect to get accuracy about 1% of your fov. To get better than that you will need to design and build everything just right. Since you are scrounging and making compromises you should be proud if you get 1% of your fov as accuracy.

> If I have a 90 degree included angle between the laser plane and the optical axis
> (equally spread each side ie. laser plane intersects the table at 45 degrees) then
> that will only give me sqrt 2 (1.4) times my measured FOV of 15mm or around
> 20mm of Z depth measurable.

Actually, I think you need to divide by the square root of two. That makes it closer to 10.6mm z combined with 10.6mm x.

>This would be increases the more oblique the optic axis to the bed became but there
> are limits with this too as one need the camera not to run into the object its scanning
> not be too blind to the shadow area... decisions decisions.

This is the way that I am doing mine. A 90 degree included angle means that you really cannot have the laser vertical because that would require the camera to be horizontal. I am setting the laser 30 degrees cw of the vertical and setting the camera 60 degrees ccw of the vertical. The advantage to this approach is that I can swap lenses to change my fov since the ccd array is not tilted with respect to the optical axis. And since I am interested in teaching it is easier for amateurs to copy and vary. The disadvantage is that x and z both depend on the h and v camera coordinates.

However, the professional method is to point the laser straight down the z axis. Then z depends on either the camera h or v coordinate (depending on camera orientation) while x and y are just taken from the cnc machine's DRO. The disadvantages are that it is more difficult to understand and design and build, the image will be distorted (but predictable) so must be corrected in software, changing the lens focal length changes the image tilt.

> Depending on what I wish to scan this may be way too small  I would be happier with am max
> depth scanable of 150mm. One could do slices by indexing the scan head down but again I am
> not sure how either Arts s/w would cope with this or how I would join the separate meshes
> latter (probably using Gmax or similar)

You get accuracy by having a small fov and scanning over as large a volume as necessary, as you suggest, to accumulate the point cloud shifted by machine coordinates so that it is relative to absolute space.

Also, accuracy depends on methodology. Two points can be uncertain by 0.010 inches and used to define a straight line. It would be best if those two points are as far apart as possible. Even better, many points taken along the length of the line reduce random error by a factor equal to the square root of the number of points. So 100 points along the line can reduce the error by a factor of 10.

> I really need to get the plugin working so that i can figure it out for myself but I've been
> concentrating on building my machine of late and I now have a windows\driver\mach3 conflict
> somewhere on my new laptop that crashes big time everytime I launch a video plugin from
> mach (blue screen of death) . I'll probably fall back onto the old desktop to experiment.

I am about to do that myself. I now have three laptops that will run Mach3, or the camera vendors software, or both side by side. I can access the camera with the Mach3 video window plugin but after that Mach3 slows to about 1% of its normal speed. I have to exit Mach3 and restart it to get it working right again.

> What kind of ballpark numbers for laser plane and optical axis (plus FOV ) are you shooting for?

Similar to yours. I started with a goal of one inch but scaled it down a bit so that I could make a one piece frame on my little Sherline 5410 CNC mill.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: mhasting2004 on April 13, 2008, 07:11:35 AM
Thanks again Tom

I am very visual in my way of understanding things and your descriptions have helped me paint that picture. Takes a while for the penny to drop but I usually get there. I always need to draw sketches when I'm explaining something and I find it difficult to decipher ideas from words alone sometimes.

I was looking at the way i was imaging my tilted ruler backwards in that I was thinking the laser plane was coming from the other side  (ie pointing towards the camera and at an oblique angle to increase my FOV and Z measurment ability) not from the near side and at an acute angle to the lens axis. I may not be describing this well but I understand now the idea of having the laser plane vertical and the camera lens mount off to one side tilted to bring the laser plane into focus.  I also get the wider aperture as possible to stop occlusion by having the lens tilted.

Hmm am I close... well I'm between Sydney and Newcastle in NSW Australia so that would be a no.

I would like to see Art use a wedge rather than a block for calibration as this would take lens distortion into account.... maybe he's listening :)

Yeah its a weird bug with the drivers I have on this beast laptop. I'll figure it out eventually (bloody windows!). I've gotten into my head that I want to run my machine using a smooth stepper usb interface card running off a wireless usb extender hub (made by Belkin http://catalog.belkin.com/IWCatProductPage.process?Product_Id=377793) with my nice laptop safely far away from the noise and mess of the CNC.

Make sure you post some pics of your setup once you get it going. Well I better get to bed early as I am a shift worker and I start early tomorrow.

Cheers
Mark

Title: Re: setting up cammera and laser
Post by: sshneider on April 13, 2008, 12:03:10 PM
Hi Fellas,

I have been watching this thread for a while now but honestly I can only follow along with about 1/2 of what you are talking about.  Obviously you both seem to have about 100X more technical knowledge on this subject but, I thought I would jump in anyway.  Excuse me if I sound like a nitwit but all I have is my experience during the past week of 'playing around'.

I totally agree with you that the sharpness and location of the laser and the quality of the camera play a huge role in the acquisiton of data but using the low end stuff I have been able to generate some really good preliminary results.  The clouds I have been able to generate are so rich with data that one of my problems has been that I acquire TOO much data (points) and this makes thing really hard on the meshing software.  Funny thing is, Art's plug in allows for the user to acquire even more data.  I don't know what one would do with all of these points.

Which leads me to my next question...  What do you guys plan on scanning?  Is it bigger than a 'breadbox'? Or are you guys looking to scan really small stuff like coins?  The reason I ask is because I think that the type of subject matter has a bearing on how you need to  up your camera/laser ( i.e. small stuff = low/close camera laser).  I need to start messing around with this myself.  I have already scanned small things and hopefully will try some bigger stuff this week.

The camera laser are obvioulsy important but so far, I have been able to get good looking clouds.  IMHO the next roadblock is what to do with them after they are clouds.  You will soon see that depending upon what you scan that although you get good clouds they often have holes or other areas that need to be edited.

Mach Cloud is pretty good and you can't beat the price but, due to its 'work in progress' nature and the demands on Art's time I think it will be a while before we see some of the features that I think it needs to be really useful.  So, that put me to RHINO.  That program is cool and does WAAAY more than I think most people need.  Plus it's kinda hard to swallow the \$ price tag  when it won't generate useful toolpaths unless you 'pony up' more \$ for their plugin.

After you generate meshes, then you need to generate toolpath.  Again, there are not too many software options there.  Meshcam has produced some pretty encourgaing results and I think I'll buy it because I can't find much else but it does crash and 'bog down' depending upon the detail of the mesh fill I 'feed it'.  Depending upon how detailed your mesh is, toolpath generation can consume computer processor time like 'carter's got liver pills'.  If you've been thinking about upgrading your processor and memory- now would be a good time.

There are so many variables to this process that it's hard to focus on just which one will improve the end result.  I'm not really sure that it's all in acquisition.  While that is no doubt important, at this point in my experimentation I would say that it's only about 30% of the whole pie.

Regards,
Sid
Title: Re: setting up cammera and laser
Post by: mhasting2004 on April 13, 2008, 10:28:37 PM
Hi Sid

First off never apologise for asking questions. I was pretty lost at first too until  the penny finally dropped from Toms explanations and a google about how to focus View cameras. BTW IMHO it is Tom that is the resident expert on this. I'm just a guy "with all the gear and no i dear" :). well maybe a little.

Anyway I think you are right in stating that the getting of the data is only half  (or less) of the story and what you do with it can be the bigger task. However remember "********* in, *********t out" so the better the data one can get at the beginning the easier it should be to create a good mesh at the end. I would look at using something like Gmax to manipulate the mesh as its s/w made expressly for this. I have no experience with it yet but its free and sounds like the go to clean up a mesh and reduce the number of vectors before importing it into a CAD program.

I am still at the begining of my CNC router build but I hope to do all kinds of stuff with it once is finished. The types of things I see myself wanting to scan will be anything from small figurines to large foils like rudders. Ideally I would like a setup that can measure depths up to the limit of a cutting tool so at least 100mm. To do this I need to balance the FOV of the camera lens and the pixel resolution of the image that this FOV dictates. Range versus resolution.  I think I just answered my own question,...hmmm if I want say 0.1mm resolution then times this by the pixel resolution of the CCD to give me my max FOV.

I also think that this video scan setup could be used as a non contact zero finder with a bit of work. I think it is because of the scale issue you mention that Tom is planning to have the camera perpendicular to the image/laser plane as this makes changing lenses easier.  A Scheimflug mount complicates things a bit as the change in focal length also effects the image focal plane tilt.

The idea is to get a good setup that doesn't cost the earth and is fairly easy to build. (good, fast, inexpensive pick any two out of the three). I just happen to have some security style cameras and lenses so thats what I'm using. Having said that they are not that expensive of Ebay from what I've seen.

I do think many people may be overlooking the impact that getting the laser plane and the optical plan angles correct as possibly they see it as being too dificult. Get your head around how a View camera works and it will all become clear (pun :)) That is the gist of what Tom has been saying all along and I think he's right.

Happy testing

Cheers

Mark

Title: Re: setting up cammera and laser
Post by: TomHubin on April 16, 2008, 09:23:36 PM
Hello,

Here is a general drawing of my design. I wanted to keep it simple for discussion so I deleted a lot of the details that make it easy to orient and machine in a fixture.

Note that the included angle between the laser and the camera is 90 degrees. That allows the lens to be attached to the camera in the normal way. Then rotate the the threaded lens to image the laser plane onto the ccd plane.

The camera will have a visible signal if the target crosses the laser plane within the camera's field of view.

A shorter focal length lens will have a greater angular field of view so will be less accurate. Also, inexpensive wide angle lenses are more likely to produce an image with barrel distortion. Barrel distortion can be corrected in software but that requires more complicated calibration and calculation methods.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: sshneider on April 18, 2008, 11:52:38 AM
Hey Fellas,

Yesterday I tried to relocate my camera and laser per Tom's drawing.  I can't totally explain why but, I wasn't able to get any good results.  I understand the principle behind calibrating this way but, for some reason it just doesn't work with my setup.

Here are a couple of observations  when I mounted my camera as shown on the drawing it is upside down.  This results in the my calibration line for my cube showing up lower rather than higher as the table (Zero).  Now, that I am sitting here typing this I am wondering if I could have used a - (neg) value in the cube size setting box?  But that's not what I did  ::)  Instead I used a setting in the camera driver to 'flip' the image so it appeared correctly on the screen.

While this fixed the problem with my Y axis, it didin't invert my X axis.  So, when doing a single pass scan in the Y, I did get a cloud that looked OK.   But I have been expanding my horizons as of late and have started to scan objects as long as 6 Feet using the X scan/step.   When I did scans that required multiple passes in the X, the cloud was 'confused' and the stripes could not be aligned.

BTW- here's a little 'Gem' of info... I discovered that Rhino is able to open striped clouds and AUTOMATICALLY align the striped segments almost perfectly.

I have also noticed that there are definite "Sweet Spots" in camera & laser positioning.  At this point I have tried around 10 different positions/configurations and seem to always come back to a certain range where things look good.  I suspect this just has to do with the way this Plug in was written in terms of the calibration on the cube process and the angle/height calculation.

No matter!  I have been getting some REALLY super results.  I don't have time right now to post any pix (I have to go out and try and make some \$\$\$ today to support my CNC "habit"  :D ) but, I will try later.

IMHO,  even though the plugin is not 'perfected',  it is really pretty damn good at doing what it supposed to do.  I do have a list of things I have noticed that are 'funky'  but so far, I have been able to find ways to work around most of the issues.  Hopefully others will see this also when they start generating clouds.

I would like to see just a tad more functionality added to this plugin.  I don't know if this is possible but it would be great if you could control the STEP in scan quadrants (like one has the ability to control the Feed Rate at different lines of G-Code).  I've noticed that fo some of the things I scan some areas require a 1mm step to get good resolution and other areas can get away with 10mm because there is not a lot of detail there.  Currently one can not do this so you would have to use the 1mm step for the whole scan.  This results in a HUGE point cloud file which is a little unwieldy.  I suppose if someone was good with RHino, you could peice multiple scans together to accomplish this but, this takes more time.

Gotta run now- I'll try and post some pix later.

Sid

Title: Re: setting up cammera and laser
Post by: TomHubin on April 18, 2008, 02:10:45 PM

Here are a couple of observations  when I mounted my camera as shown on the drawing it is upside down.  This results in the my calibration line for my cube showing up lower rather than higher as the table (Zero).  Now, that I am sitting here typing this I am wondering if I could have used a - (neg) value in the cube size setting box?  But that's not what I did  ::)  Instead I used a setting in the camera driver to 'flip' the image so it appeared correctly on the screen.

Hello Sid,

I have mentioned the camera orientation options in another thread.

While you can rotate the camera at any angle from 0 to 360 degrees, it is more likely that the camera will be oriented in one of four positions. Rightside up, upside down, rotated +90 degrees, rotated -90 degrees. In addition, you might end up using a mirror someplace and that would produce a mirror image of one of these four. So there are 8 likely setups.

All of these can be handled with only three operations. Mirror X, Mirror Y, Rotate 90 degrees...in any order. Flipping an image is mach3's term for mirroring an image.

Tom Hubin
Title: Re: setting up camera and laser
Post by: TomHubin on May 02, 2008, 04:44:51 AM
Hello,

Here are two photos of my laser triangulation gauge installed on my Sherline 5410 CNC mill. It is mounted on a Sherline spindle spacer block and that, in turn, is installed in place of the spindle and motor.

The third photo is the underside of the laser triangulation gauge with the camera on the left end, the laser on the right end, and the Sherline spacer attached near the center of the rear face.

I took some photos of the finished metalwork but the lighting was bad. I will retake those and post them another day.

I took some photos of the video display. They are ok but I would prefer a snapshot of the screen. How do I capture the screen as a gif or a jpg or other acceptable file format?

I also have some photos of focus procedures and experiments with agc methods. The photos need to be organized before posting so that will happen some day after another day.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: elkaholic on May 02, 2008, 10:39:41 AM
Tom,

To screen capture In windows, I use the <Alt> and <Prt Scr> keys held down together to copy the "active window" into the paste buffer.  Note: just using the <Prt Scr> key will copy the entire display.

Then go to Paint, Paste it and edit away.

Elkaholic
Title: Re: setting up cammera and laser
Post by: sshneider on May 02, 2008, 10:42:08 AM
Pretty Nice looking camera mount Tom!

Press and hold the 'Alt' button then press the 'PrtScn' button- this will capture your screen to the clipboard.  You can then usually open a graphic editor (like paint) and paste the clipboard, save the file & upload.

Sid
Title: Re: setting up cammera and laser
Post by: TomHubin on May 10, 2008, 04:54:30 AM
Hello Sid,

> when I mounted my camera as shown on the drawing it is upside down.
> This results in the my calibration line for my cube showing up lower rather than higher as the table (Zero).
> I used a setting in the camera driver to 'flip' the image so it appeared correctly on the screen.

I think I am having the same problem. My image needs to be inverted too. I can do this with the camera vendors software and I can do this with MS Photo Editor. Where did you find this control within Mach3?

> While this fixed the problem with my Y axis, it didin't invert my X axis.

Some camera software uses ROTATE 180 DEGREES to invert both axes. Others mirror horizontally and mirror vertically. These mirror options might be labeled MIRROR or FLIP or one of each.

Tom Hubin
Title: Re: setting up camera and laser
Post by: sshneider on May 10, 2008, 06:29:14 AM
Hey Tom,

I fouund (and used) the flip feature in the camera's driver software settings.  You can find that in Mach by clicking the stop video, then camera source- should bring up the camera settings.  Remember to Start the video again when you exit out of settings.

Good Luck!

Sid
Title: Re: setting up cammera and laser
Post by: TomHubin on June 01, 2009, 09:48:18 AM
Hello Sid,

> IMHO,  even though the plugin is not 'perfected',  it is really pretty damn good at doing what it supposed
> to do.  I do have a list of things I have noticed that are 'funky'  but so far, I have been able to find ways to
> work around most of the issues.  Hopefully others will see this also when they start generating clouds.

Try Scan3d, my new Open Source 3d Video Probe plugin.

http://www.machsupport.com/forum/index.php/topic,10959.msg68643.html#msg68643

Tom Hubin
Title: Re: setting up cammera and laser
Post by: GAWnCA on June 01, 2009, 09:56:52 AM
Hi Tom,  I just found this thread and am very interested in scanning 3D images but have yet to get set up for that.  What would you use to edit the images once they are scanned?
Title: Re: setting up cammera and laser
Post by: TomHubin on June 01, 2009, 10:21:29 AM
Hi Tom,  I just found this thread and am very interested in scanning 3D images but have yet to get set up for that.  What would you use to edit the images once they are scanned?

Hello GAWnCA,

I would like the answer to that one myself. My area of expertise is the optics.

I use Rhino to show the point cloud but have not had time to go beyond that. I figure the folks that work with touch probes should have a solution to share. Maybe you should start a new topic to search for point cloud to something-or-other converters.

Art was working on Mach Cloud to convert point cloud files to more CNC friendly files but I never could get that to work. Point spacing might have been a problem. Also, Art used metric for his demos and I used imperial for my data. Could be a mismatch of some sort there.

Tom Hubin
Title: Re: setting up cammera and laser
Post by: GAWnCA on June 01, 2009, 10:35:14 AM
Are you able to create a file with the point clouds.  I guess I need to set up so I can play around with your plugin and the hit up Art to see where he's going with his project.

Thanks,
Greg
Title: Re: setting up cammera and laser
Post by: TomHubin on June 01, 2009, 10:51:45 AM
Are you able to create a file with the point clouds.  I guess I need to set up so I can play around with your plugin and the hit up Art to see where he's going with his project.

Thanks,
Greg

Hello Greg,

Scan3d creates 3 files. There is no provision yet for making up the file names yourself.

Scan3d.ini is used to save the setup and values for the plugin.

IIRC Scan3d.pts is raw data used for calibration. I won't swear to the full name but it is Scan3d.something-or-other.

Scan3d.xyz is the point cloud created during the scan. Rename it to save it.

Tom Hubin