View Full Version : Webcam centre / edge / hole finder
alan T 07-02-2007, 09:45 AM Hi there from the UK. This is my first posting, apologies if it has already been covered but I've not seen it mentioned before on here?
I am a UK based clockmaker / model engineer with an extensive workshop incl Myford S7 and Centec 2A mill, both with Ortec digital readouts (no CNC as yet:-{{ )
Model Engineers Workshop, an excellent magazine published over here recently had a couple of articles on converting cheap Webcams into centre / edge/ hole and corner finding devices, similar to centering microscopes but displaying a highly magnified image of your component on a laptop screen. I have used centering 'scopes for years but they are often difficult to use in akward set-ups. This camera REALLY solves the problems.
It uses the lens and PCB of any cheapo 640 x 480 pixel webcam ( I used a cheap Logitech, about £10.00 US$20 ish.) Machining up a simple body and and adaptor to suit your spindle is real easy and the free software download gives you several options of crosshairs, circles, parallell lines and even a distance / angle measuring option!! There is also an optiion for LED illumination of the job.
I made one immediately, it took a day to make and I can honestly say it is the best machine accessory I have made for years, real easy and VERY ACCURATE :-}} Thoroughly recommended.
Check out www.miketreth.mistral.co.uk/centrecam.htm for full description and software download.
alanT
Your link has an error. You need .UK not .KK
There was a thread about this type of thing a while back but the one you link seems a more complete package and description.
ISO Coder 07-02-2007, 11:13 AM Absolutley exellent hack.
But one thing that first came up in my mind, how do you make sure that the ccd centre ends up alined with the spindle centre, this is important if you cant put the camera oriented exactly in the same place in the spindle every time.
SmartArt 07-02-2007, 11:44 AM All you need is to do is add a correction offset.
harryn 07-02-2007, 11:49 AM Hi, That is a neat idea. I could really use something like that.
I looked at the pictures on the site. Very nice. This is probably obvious to an experienced machinist, but could you please provide a little more explanation of how to do the alignment of the camera so it is properly centered ? Thanks
OK, I read some more in the software area - that is a nice concept for alignment using the software.
Is it assumed that the camera will remain "aligned" if it is mounted slightly rotated from the original location ?
Any chance you are going to sell these ?
Take care
Harry
SmartArt 07-02-2007, 12:06 PM I hope I understand the process properly.
in principle, First, drill a small hole. Then, without moving in x and y use your webcam setup. The moves you do in order to center your camera are your offsets.
alan T 07-02-2007, 01:00 PM Hi again,
I'm amazed at the number of replies so far, excellent and glad you like it.
As all my machines have No 2 Morse taper spindles, I machined all the body including the mounting hole at one setting to ensure mechanical concentricity and fitted a morse taper arbor so it always relocates accurately in the spindles. Alternatively, machine as above, fit a parallell arbor and hold the camera in a collet / end mill holder.
There is a facility in the software to align the CCD accurately. Simply put a hard centre in the machine spindle, bring it down hard on to a piece of scrap clamped in the machine to make a fine "centre punch mark" replace with the cam and align the crosshairs to suit, thus automatically resolving any offset problems.
I have performed repeated point, edge, corner and hole alignments and they have been spot on if you follow the info.
Of course, camera FOCUS and DISTANCE OF THE CCD FROM THE WORK SURFACE both have an effect on accuracy, especially if the CCD is "squinting" at the job ie. not dead square on but looking at an angle.
This is easily resolved by setting up in the first place using an accurate spacer block between the end face of the camera and the work surface. I use a standard 1 inch slip gauge block but any measurement around 1" will prove OK. Keep your block with the camera and ALWAYS use the same block for setting up.
When setting up, adjust the focus / height of the camera until the image on the screen just fills the box on the screen exactly. The camera MUST BE 640 x 480 resolution then 1 pixel equals 0.001"
Hope this helps. No real poiint in selling them, they are so easy and cheap to make and set up :-}} email me or post on here if you need any further help.
By the way, the software is a free download, it just has "Demo version" across the screen, but it is so neat it is well worth registering for his efforts and any future upgrades!! ( I have no connection whatsoever, just a satisfied end user.)
Best wishes,
alanT
scubasteve_911 08-20-2007, 11:23 PM I'm currently working on the same sort of deal, but with less interface and more image processing. The program will have to run in Matlab, but it will take snapshots from any source and input the hole diameter range. Then, it will find the center of the circle automatically with the hough transform. After an offset is programmed in, it will be able to tell you the distance from center.
I have played around quite a bit, but I don't have the hardware built yet. After a lot of fooling around with relaxation parameters, I have gotten it to be very repeatable and provides accurate information about where the holes are located with respect to eachother. I will know for sure when the hardware is built and I can make real measurements. I will post the Matlab code if anyone is interested.
Regards,
Stephen M
Lakehead U
Switcher 08-21-2007, 07:45 AM How about this (Mach3)?
http://www.artsoftcontrols.com/forum/index.php?topic=2519.0
.
Oldmanandhistoy 08-22-2007, 05:52 AM More and alternative information in this thread :)
http://www.cnczone.com/forums/showthread.php?t=42313
John
scubasteve_911 08-22-2007, 11:39 AM Hey,
I have to critique this hardware solution in hopes of product improvement. First of all, is this a 1.3M optical sensor? These are readily available and would provide more accuracy at little extra cost.
Furthermore, the mount should include white LED lighting run off of the USB port or external power supply. I discovered through several tests that adequate lighting around the features was indisposable for feature recognition. It's the only good way to give enough contrast to distinguish fine lines and circles.
As a followup, attached is the result from the hole finding program I have started writing. I specified a particular pixel radius and it returns all found holes displayed as a picture with the guessed radius and centers.
Here are the X and Y coordinates of each hole found.
131.7250 269.2802
382.2941 261.6078
394.4105 101.8659
586.1414 96.4520
This is my no means an optimal setup and once I get the hardware finished (another month), then it will be clear whether or not the program will work.
Steve
Switcher 08-22-2007, 09:04 PM You need to add a dimmer control to the LED lights, thats what we use on a Pro. setup at work, it works very good.
The reason for the dimmer control, is because of reflection of the light on some material.
.
scubasteve_911 08-22-2007, 11:20 PM Switcher,
It's funny that you mention that because I had run into problems tonight during experimentation with another image processing algorithm. The problem occurs when thresholding the image to a binary format meant for shape recognition, it simply thinks that the reflection is what should be thresholded.
I have decided that I want to pursue this application further and develop some advanced code. I want to provide a means of automatic centering along edges and holes. The program must be calibrated via a white card with a black square. It also needs information about where your X and Y step-dir signals are located on the parallel port. I want the program to self-calibrate, then find the correct hole (based upon approximate diameter input from user), then move to either an edge, corner, or center of a hole.
The entire concept is fairly complex, but it seems doable. I will let people know how progress is going as I continue. As I had said, I really need to get the hardware up and running first.
Steve
CarbideBob 08-23-2007, 12:15 AM Steve,
Welcome to the world of machine vision, I've got a little experience in this. A couple of thoughts.
Unless you use optics designed for measuring your magnification (and calibration) will be different at the sides of the image than in the center.
If you use telecentric optics you will not see the sides of the hole when it is off center.
Cheapo sensors are CMOS color devices. These use a color filter to split the RGB across 3 photosites. Because of this the measuring capability is less than than the sensor resolution.
Your sensor will not be square. Be aware that you will need different calibrations for X and Y.
Edmund Optics is the best source for optics and calibration masters. Get one of their catalogs. Full of good information on lenses, calibration, and lighting techniques.
Yes, this is very doable. I'll be interested to hear about your progress.
Bob
scubasteve_911 08-23-2007, 12:27 AM Hi Bob,
Thanks very much for your input and encouragement, first-hand advice is always appreciated.
I'm having to draw the line here in terms of cost and availability. I have learned very painfully from experience that things can always be done better and it nearly always comes at an exponential cost. 1.3M webcams are extremely cheap and readily available, albeit extremely cheap plastic optics and the problem of RGB splitting on the array itself.
Edmund optics does make excellent stuff, I must admit. Their prices are fairly reasonable with the exception of the more highly integrated things. I was actually sponsored by Edmund when I was 17 to build a laser range finder, they're great people!
I had once used a Micron 1.3M B&W CMOS image sensor capable of full resolution at 30FPS on a custom-made four layer PCB with a FPGA for interface and processing. I remember how much of a pain it was to find focusing optics that would fit the sensor.. It ended up costing well over 100$US just for the sensor and cheapie optics. If I had wanted to go all out, I could have gotten a housing machined and used some high grade optics from Edmund and would have spent over 250$US. That would probably be an ideal solution for this project, but I don't really want to get into having to make a USB / slow RS232-based interface.
I guess I am going to try my best with software and determine whether or not it is acceptable by experimentation.
Steve
scubasteve_911 08-23-2007, 01:24 AM Hi Bob,
I found an okay webcam to use, which is a step above a typical webcam. It's a cheapo chinese webcam, but I think it will be fine.
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=120148423323
The unequal lighting kind of upsets me, but I guess it is better than having to make a mount for LEDs and my own dimming circuit. Apparently, the lens is "German-Made" and is glass. It's funny, I used to work as a Kitchen Appliance salesman (another lame student job) and we used to use that line "It's German-made" and people would be immediately impressed! To me, where something is made and the brand name means nothing, just specifications count.
We will just have to see how this pans out, I will keep updating, maybe in my own post :)
Steve
abasir 02-15-2008, 01:19 AM Found this thread recently... Just to share my setup ... USD15 webcam quickly modified for the purpose... works very well... will be making a new mounting soon... more details at my blog...
lvittori 03-04-2008, 02:40 PM Here is my version. I do a lot better with this than a center finder.
joejared 03-19-2008, 04:56 PM Hey,
131.7250 269.2802
382.2941 261.6078
394.4105 101.8659
586.1414 96.4520
This is my no means an optimal setup and once I get the hardware finished (another month), then it will be clear whether or not the program will work.
Steve
Speaking as someone who has designed laser and structured light 3d scanners, I find it difficult to believe anything from the 3rd digit on, especially given the size of the holes you are centering over. You might get some improvement using subpixel resolution, but at best you'll probably get no more than 1/4 pixel improvement. My own edge finder implementation is described on http://www.oretek.com/micromill/user.shtml#edge and works in conjunction with a proximity sensor to provide a means of setting depth without making actual contact with the end of the tool. See also: http://www.oretek.com/micromill/user.shtml#proxy . For purpose of calibration, I simply "touch down" on the proximity sensor with the edge finder, change tools, and touch down onto the proximity sensor with the tool to be used. At this point, an offset is applied per previous calibrations determined by performing the same action onto a digital depth gauge and recording the results. The only real downside is that there is a minimum limit to the diameter of cutting tools that can be used, and if there's a hole in the middle of the tool, there's nothing to reference. For tools with a hole in the middle, it would be a simple matter to design an alternative proximity sense with an offset so that the sensor is in close proximity with the actual metal. As for accuracy, it would appear from test results that I can get within +-0.0015" in terms of accuracy with this method for depth, and whatever the accuracy of the edge finder is in terms of X and Y. The only real problems I've found with the electronic edge finders is in the fowler brand. Typically, I have yet to find one more accurate than 0.005 and have indicated them on my lathe to confirm they are not well made. The ball style from PEC tools is much better, but also much more fragile. I'm tempted to make a repairable form of the ball type for just this reason.
My high quality camera lcd busted but in the mean time, here are some cell phone videos, just barely clear enough to show the operation:
http://www.oretek.com/micromill/edge.mp4
http://www.oretek.com/micromill/proxysetup.mp4
Normal proximity operations are purely vertical as it is simply a machine setup issue to center onto the proximity sensor. I don't really know how critical the magnetic field is but suspect it's a good idea to have the tool centered over the sensor to provide repeatability and reliability.
As for centerfinding, I simply position the edge finder inside of the hole to be centered, after at first possibly hopscotching from known corners and then issue a command from my own software:
edge c+ 0.00
The above is functionally equivilent to edge x+ edge x- and centering on the results, and then performing the same operation for the y axis. Generally, I perform this command twice for greater precision.
I wouldn't have the first clue how to implement a similar command in G codes and only know just enough to be really dangerous when it comes to those codes.
As to cost, it's mostly the cost of the electronic edgefinder itself. I've used everything from the cheap $20.00 barely electronic units to the $70.00 unit from wttool.com. It hurts more when the idiot doing the programming for it breaks one. (me)
There's one on Ebay selling for between $199 and $900.00. AND it doesn't appear to be able to be adjusted either. It's got some software that was custom written for it and can be outfitted with a laser for edge finding.
It doesn't look quite as fancy as some I've seen here. But it does come with a magnet and a convenient carrying case.
|
|