Hello Guest it is November 25, 2020, 05:54:35 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - TomHubin

Pages: 1 2 »
Video P*r*o*b*i*n*g / Scanning Coins
« on: May 27, 2009, 10:32:57 PM »

Note: I am having trouble attaching the files so they may show up on another message.

Here is another scan of a penny shown in a GIF file. This is about 63Kb. Rhino was used to import the xyz file and create multiple views. Then saved using Ctrl-PrtScr to copy to the clipboard. Then pasted into mspaint.exe. Then saved as a GIF file.

One of the options with my Mach3 plugin, Scan3d, is scaling for each axis. This can be used to exaggerate features. Negative scale values can be used to produce a point cloud file for a mirror image.

The Z data is exaggerated by a factor of 10. Oddly, it appears that the surface of the penny is bowl shaped.

The data is in the zipped xyz file. This is about 3Mb compressed and 12Mb uncompressed. It is plain text with space between numbers. Each line of data has x,y,z and total intensity and intensities for red, green, and blue components. The RGB components range from 0 to 255 each. The total intensity is the sum of color values and ranges from 0 to 765.

This scan was done with a Watchport/V2 camera using a 12mm f/2 lens.

Tom Hubin

Mach SDK plugin questions and answers. / Posting Open Source Code
« on: May 02, 2009, 05:18:58 PM »

I would like to post my c++ source code for my 3d video probe plugin. What do I need to include with my source files?

Tom Hubin

Video P*r*o*b*i*n*g / New 3d Video Probe
« on: March 23, 2009, 11:47:05 PM »
I have posted my first 3d Video Probe plugin. Calling it Scan3d.dll. No documentation yet. Iit should show the camera view.


Tom Hubin

Finished Plugins for Download / 3d Video Probe
« on: March 23, 2009, 11:40:31 PM »

Here is my first release of a plugin for 3d Video Probing.

File is called Scan3d.dll. Download to the Mach Plugins directory.

James Leonard's tutorial on writing Mach plugins was very helpful.

Start the plugin with Config. I don't know how to program it to start from the Plugins pulldown menu.

No documentation yet but you can plugin a webcam and see if there is video in the plugin. I have tested with Watchport/V, Watchport/V2 and Eyetoy (silver package). Watchport/V is older camera, doies not use compression, and seems to work ok if machine is fast but does not work well on the 800MHz desktop and the 800MHz laptop that I have tested. Watchport/V2 and Eyetoy use compression but seem to work ok on all the machines that I have gotten access to, whether compression is enabled or not.

Meantime, I will work on documentation.

Tom Hubin

Mach SDK plugin questions and answers. / File Zipping
« on: March 17, 2009, 04:56:18 PM »
My 3d video plugin is coming right along. I hope to post the plugin soon for trial.

Years ago I bought the shareware PKZIP and it saw a lot of use in the 1990s. Since it is limited to 8 letter file names it is of limited use with Windows long file names.

What free or inexpensive software is currently available for zipping files and folders?

Tom Hubin

Video P*r*o*b*i*n*g / Point Cloud File Formats
« on: February 24, 2009, 04:59:01 PM »

I am developing 3d video probing plugin software. I need to choose an output file type for the resulting point cloud.

MachCloud uses a .txt file. I like the fact that the data is in plain text so that anybody can read it or use it.  However, I would prefer to save my point cloud data to a file type that identifies the file as a pointcloud. Plain text if possible. Binary if necessary.

Maybe both text and binary and let the user choose?

Any suggestions for file types for a list of 3d points?

Tom Hubin

Mach SDK plugin questions and answers. / Video
« on: December 31, 2008, 04:13:07 PM »

I have been messing around with video plugins. In particular, I am interested in 3d Video Probes.

I found the AMCAP camera viewer source files in the DirectX 9.0 SDK. I have not yet figured out how to use many of those features in a Mach plugin. Having a template that starts with this, or a simpler viewer like PlayCap, would be useful.

Downloaded DX9SDK.exe (225MB) from


This is a self unzipping file. The default for the unzip is a hidden directory. So I made a directory called DirectX9 and unzipped it there. These directories and files are probably what would be on an installation CD.

Easy to find and compile AMCAP and PLAYCAP and a few other capture related samples. No formal installation necessary. Just use the unzipped files.

On my second machine I ran Install.exe and it created another directory called DXSDK and copied most of the files from my temporary directory to that directory. Also did a lot of whatever Windows likes for a real install. So far, no visible benefit from doing the formal install.

Anybody know what benefits come with running the Install program?

Tom Hubin

Video P*r*o*b*i*n*g / Scan Direction
« on: June 19, 2008, 07:55:46 PM »

For scanning an area or a volume I would like to have the user specify:

(xFirst, xLast, xStep, xOrder)
(yFirst, yLast, yStep, yOrder)
(zFirst, zLast, zStep, zOrder)

Where First designates the first point for that axis and Last designates the end of the scan. This would allow for scanning in either a positiive or negative axis direction.

Step designates the scan step size for that axis. This would be shown unsigned or the sign shown taken from the direction from First to Last. An alternative might be to specify the number of steps rather than the step size.

The Order designates the order in which the axes are incremented. Order=1 would be the innermost loop and order=3 would be the outermost loop for three axes. Zero would mean to exclude that axis from motion. 
Tom Hubin

Video P*r*o*b*i*n*g / Calibration
« on: June 19, 2008, 07:51:30 PM »

My probe is at the CNC Workshop in Illinois this week so I cannot do any serious testing until I get it back. However, I have given calibration some thought and I did do a few simple experiments during the brief time that I had it.

The present calibration scheme requires a square bar of known dimensions to be placed on the table parallel to the Y axis, and the camera and laser in the YZ plane and the target scan in the XY plane. No motion is used in the calibration so data is captured in a single position.

This static scheme does not allow for:
misorientation of the probe,
misorientation of the calibration bar,
inaccurate calibration bar dimensions,
radial distortion due to camera lens,
rectangular distortion due to non-square detector pixel layout,
keystone distortion due to laser and camera axes not perpendicular,
preferring a different arrangement of probe and target.

I would propose using a single point as a target. This could be the pointy end of a nail or pin or it could be the apex of a cone. If it is a cone then the apex angle would have to be sharp enough that the camera cannot see where the laser hits the cone except at the point. For example, in my setup at http://www.machsupport.com/forum/index.php/topic,5023.msg42913.html#msg42913, with the laser 30 degrees off the Z axis, the calibration target cone point would need to be less than 60 degrees.

I would jog until the point shows up near one corner of the screen then save the (X,Y,Z) coordinate from the machine axes and the (H,V) pixel horizontal and vertical coordinate from the CCD array where the center of the bright spot appears. I would do this for three corners to get three points as far apart as possible. This would create the data set:

(X1, Y1, Z1, H1, V1)
(X2, Y2, Z2, H2, V2)
(X3, Y3, Z3, H3, V3)

Three points are sufficient to define a plane so this is sufficient to define (H,V) points on the CCD plane in terms of the (X,Y,Z) points of the machine axes.

More than three points would permit a least squares fit which would be more accurate. Many more points, spread over the array, would allow for correction of distortion.

This scheme allows the probe to be installed in any orientation, even off axis orientations to get better data from odd shaped targets.

The probe could even be installed on the Z axis and pointed toward the front of the machine rather than down at the table. For this arrangement the point used for calibration would have to be setup so that it is pointed at the Z column. Then scanning the side of something would be possible.

Or side scan a target on a rotary table.

Or hang the probe on an articulating arm any way you wish.

Tom Hubin

Video P*r*o*b*i*n*g / Laser Focusing
« on: February 28, 2008, 05:06:42 AM »

Gaussian Beam:

The ideal light source is a Gaussian beam. Many lasers provide such a beam. Not all lasers, though. Furthermore, if the optics are not appropriate the beam characteristics may be altered so that a Gaussian beam entering the optics may exit as non Gaussian.

A Gaussian (bell shaped profile) beam is described by the waist diameter as measured at the 1/e squared irradiance. The waist is where the beam is narrowest. The waist may be accessible or it may not. Sometimes the waist is inside the laser itself where you cannot easily measure it.

Irradiance is power divided by area. Also commonly known as power density. 1/e squared is (1/2.71828)^2 = 13.5%. Few amateur machinists have any way to actually measure that so we just look at the beam with the naked eye and a rule,r or maybe with a microscope, and estimate the diameter. This usually results in estimating the diameter too large since the beam may be bright enough to saturate the eye or camera. 

One way to spoil a Gaussian is by passing the beam through an aperture that is too small. This is known as clipping the beam. Only 86.5% of the beam energy is contained within the 1/e squared diameter and 13.5% of the beam energy is outside the 1/e squared diameter. Since the beam trails off beyond the 1/e squared diameter it is necessary to have aperture diameters at least 1.5 times the 1/e squared beam diameter with 2.0 times the beam 1/e squared diameter being preferred. This will assure that 99% of the beam energy passes through the aperture unperturbed.

This rule also applies to lens and mirror diameters. Lenses need to be well corrected, and mirrors very flat, over a diameter at least 1.5 times the 1/e squared beam diameter as it passes through optic. 


Collimation is a word of convenience and is not well defined. A collimated beam is loosely defined as one that has a low enough divergence that it is suitable for your application.

No beam is ever truly collimated in the sense that it can propagate an infinite distance and never grow. Light is a wave and waves spread. The exception would be a beam that has an infinite waist diameter. However, that would require an infinite amount of energy.

A Gaussian beam propagates according to the following equations. 

theta = (4/pi) * (lambda/w0)

w(z) = sqrt ( w0^2 + (theta*z)^2 )


pi = 3.14159...
lambda = wavelength in meters.
w0 = waist diameter in meters.
theta = beam divergence in radians.
z = distance from waist in meters.
w(z) = beam diameter at z distance from the waist.

Rayleigh Range:

Rayleigh range is defined as the distance over which the beam propagates to expand its diameter to sqrt(2) times the waist diameter. This is similar to the definition of depth of focus in photography. For locations between the waist and the Rayleigh Range the beam diameter is dominated by the waist diameter so is nearly constant. For propagation distances beyond the Rayleigh Range the beam diameter is dominated by the divergence so is growing rapidly.

The working range of the beam, over which the beam is collimated enough for our purposes, requires that: 

w0 = sqrt( lambda * wr * 2 / pi)


wr = working range in meters.

This will give you some idea as to what you need to have in a laser triangulation gauge. If the beam is not Gaussian then the waist will be much larger than that calculated above. So we try to start with a Gaussian source and maintain it as a Gaussian as it propagates through optics like apertures, lenses, and mirrors.

Laser Diode:

A laser diode is a very small Gaussian source. A typical source size is 3um x 1um. Such an elliptical source gives rise to an elliptical divergence. For a 650nm wavelength you can expect divergence of about 15 degrees x 45 degrees with the 3um width diverging at 15 degrees and the 1um width diverging at 45 degrees.

Let's say that you want a working range of 20mm. The working range for this diode, with no optics, would be about 22um for the 15 degree divergence. At a distance of 10mm the beam will have grown to 2.8mm diameter. Definitely not collimated enough for this laser triangulation gauge.

What we need is a beam diameter of 90.9um. We can do that my imaging the emitter with a lateral magnification of 90.9/3=30.3 .That would produce a waist of 90.9um x 30.3um with a divergence of 0.522 degrees x 1.565 degrees. The smaller divergence has a working range of 20mm while the larger divergence has a working range of only 2.2mm.

Line Generator:

Line generators are optics that spread the beam in one dimension. In other words, a line generator deliberately increases the beam divergence in one dimension while having little or no effect on the other dimension. The line generator needs to be installed so that it spreads the beam in the dimension that is already spreading more so that the skinny dimension can be as skinny as possible over the working range.   


You can get an inexpensive laser module on ebay for about $10. You can also get power for it for another $10 or you can get a 5vdc version of a module and tap power off the camera USB cable.

Remove the lens and line generator from the laser module and put the module in a Vblock. Rotate the laser module until the large divergence is vertical. Install the lens. Focus until the beam is very small at your target distance. A paper target is sufficient.

Install the generator and rotate it gently (so as not to disturb the lens) until the generated line is vertical. You should now have a very skinny vertical line on your target.

Move the target closer and farther to see if the skinny beam width increases noticeably. This will define the working range as you have it set up.

If the working range is too short then the distance from target to laser is also too short. Increase the distance between target and laser and adjust the laser lens to focus on the target and try again.

If the working distance is too long then the distance from target to laser is also too long. Decrease the distance between target and laser and adjust the laser lens to focus on the target and try again.

Design Problem:

As a professional, I would have more control over the design. I would know the laser diode characteristics from a data sheet and I would have the lens prescription, or at least the focal length, so that I could do the math. If I don't like the result then I would choose a different lens or rethink my layout or discuss alternatives with the client. As amateur machinists scrounging cheap laser modules off the internet we have very little design data so more experimenting is needed.

Hardware Problem:

I have noticed that the lens and line generator that I have are a loose fit on the module. These items tend to wiggle too freely for my taste. They should have lock nuts or set screws but they do not. Locktite might be useful to prevent wiggling.

Electrical Problem:

Laser diodes often have the case connected to one power lead or the other. You need to be sure that the case is isolated if you plan to share power sources. Use an ohmmeter to check for continuity between each lead and the module housing.

Tom Hubin

Pages: 1 2 »