Advertisements

Measuring Objects for 3D Modeling: USB Video Camera

A brace of “Fashion” USB video cameras arrived from halfway around the planet. According to the eBay description and the legend around the lens, they’re “5.0 Megapixel”:

Fashion USB camera - case front

Fashion USB camera – case front

The reality, of course, is that for five bucks delivered you get 640×480 VGA resolution at the hardware level and their Windows driver interpolates the other 4.7 megapixels. VGA resolution will be good enough for my simple needs, particularly because the lens has a mechanical focus adjustment; the double-headed arrow symbolizes the focus action.

But the case seemed entirely too bulky and awkward. A few minutes with a #0 Philips screwdriver extracted the actual camera hardware, which turns out to be a double-sided PCB with a lens assembly on the front:

Fashion USB video - case vs camera

Fashion USB video – case vs camera

The PCB has asymmetric tabs that ensure correct orientation in the case:

Fashion USB camera - wired PCB rear

Fashion USB camera – wired PCB rear

In order to build an OpenSCAD model for a more compact case, we need the dimensions of that PCB and those tabs…

Start with a picture of the back of the PCB against white paper, taken from a few feet to flatten the perspective:

img_3300 - Camera PCB on white paper

img_3300 – Camera PCB on white paper

Load it into The GIMP, zoom in, and pull a horizontal guide line down to about the middle of the image:

Camera PCB - horizontal guide - scaled

Camera PCB – horizontal guide – scaled

Rotate to align the two screws horizontally (they need not be centered on the guide, just lined up horizontally):

Camera PCB - rotated to match horizontal guide - scaled

Camera PCB – rotated to match horizontal guide – scaled

Use the Magic Scissors to select the PCB border (it’s the nearly invisible ragged dotted outline):

Camera PCB - scissors selection - scaled

Camera PCB – scissors selection – scaled

Flip to Quick Mask mode and clean up the selection as needed:

Camera PCB - quick mask cleanup - scaled

Camera PCB – quick mask cleanup – scaled

Flip back to normal view, invert the selection (to select the background, not the PCB), and delete the background to isolate the PCB:

Camera PCB - isolated - scaled

Camera PCB – isolated – scaled

Tight-crop the PCB and flatten the image to get a white background:

Camera PCB - isolated - scaled

Camera PCB – isolated – scaled

Fetch some digital graph paper from your favorite online source. The Multi-color (Light Blue / Light Blue / Light Grey) Multi-weight (1.0×0.6×0.3 pt) grid (1 / 2 / 10) works best for me, but do what you like. Get a full Letter / A4 size sheet, because it’ll come in handy for other projects.

Open it up (converting at 300 dpi), turn it into a layer atop the PCB image, use the color-select tool to select the white background between the grid lines, then delete the selection to leave just the grid with transparency:

Camera PCB with grid overlay - unscaled

Camera PCB with grid overlay – unscaled

We want one minor grid square to be 1×1 mm on the PCB image, sooo…

  • Accurately measure a large feature on the real physical object: 27.2 mm across the tabs
  • Drag the grid to align a major line with one edge of the PCB
  • Count the number of minor square across to the other side of the image: 29.5
  • Scale the grid overlay layer by image/physical size: 1.085 = 29.5/27.2
  • Drag the grid so it’s neatly centered on the object (or has a major grid intersection somewhere useful)

That produces a calibrated overlay:

Camera PCB with grid overlay

Camera PCB with grid overlay

Then it’s just a matter of reading off the coordinates, with each minor grid square representing 1.0 mm in the real world, and writing some OpenSCAD code…

Advertisements

  1. #1 by Gary on 2013-08-12 - 09:28

    Good ideas that help fill the middle between similar start and end points.
    I’m thinking bed scanner for model and grid > Autodesk Inventor > 3D print on MG M2.

    • #2 by Ed on 2013-08-12 - 11:29

      bed scanner for model

      I’ve had mixed success with scanners; they don’t work well with points on objects more than a few millimeters off the glass. For flat things like PCBs (minus projecting parts!) they work fine.

    • #3 by smellsofbikes on 2013-08-21 - 01:32

      I need to mill some intake/exhaust headers. Current thinking: put exhaust gasket on scanner, use ubuntu’s simplescan to produce a pdf, run that through pstoedit to get a dxf, and move that into a 3d modeling program or even inkscape, which can directly produce gcode for milling.

      • #4 by Ed on 2013-08-21 - 08:51

        It seems like an unsteady ziggurat of software, but it ought to work.

        Inkscape has a trace-the-outline function that might produce better vectors directly from a high-contrast scan. Then you hand it directly to the Gcode Tools extension and away you go.

        I used an earlier version of the Gcode Tools to do some engraving; it works really well. Engraving text required a precise sequence of gymnastic steps that I got right almost all the time…

        • #5 by smellsofbikes on 2013-08-21 - 11:14

          I used inkscape with hersheytext and gcode to engrave all our wedding invitations, and it did a great job. Skipping the pdf-dxf steps would be awfully nice. I’ll give this a try.

          • #6 by Ed on 2013-08-21 - 11:58

            inkscape with hersheytext

            Thanks for nudging me; I need a stick font for an engraving project and Hershey should work fine…

        • #7 by smellsofbikes on 2013-08-21 - 13:12

          So the reason I was thinking about going through ps2edit was to get a dxf that I could pull into qcad and dimension, to make sure the distances between two measured points reflected actual dimensions, and that no sneaky scaling had crept in. I don’t know inkscape well enough to know if it can show point-to-point dimensions, although I trust its ability to scale.

          • #8 by Ed on 2013-08-21 - 13:31

            I don’t know inkscape well enough

            Me, either. I suppose you could go both routes, with one for dimension checking and the other for cleanliness of tracing, then compare the answers. Use all the software!

  2. #9 by Keith Neufeld on 2013-08-12 - 10:09

    I like to put a ruler into the photograph so I can scale before cropping. Somehow it feels like less work than having to leave the world of the computer and reenter the physical world to caliper the object. :-)

    • #10 by Ed on 2013-08-12 - 11:30

      a ruler into the photograph

      I trust my digital caliper much more than my eyeballometric ruler-fu… [grin]

      • #11 by Keith Neufeld on 2013-08-12 - 11:32

        I trust my ruler-fu about as much as I trust my 3D printer. :-)

  3. #12 by smellsofbikes on 2013-08-12 - 12:40

    I did this the old way with a cam for the door latch in my Triumph Spitfire last month: put item on graph paper, trace with a mechanical pencil, read off the numbers, print. I’d really like to do this automatically, though. I’ve built a touch sensor for the cnc mill but have yet to spend the time/energy to get it working, although there’s a lot of interesting stuff being done right now by people who are touch-sensing pcb height for cnc pcb milling and their code would be a good starting point for a 3d touch-scan. (I believe linuxcnc has a touch-scan routine on one of their pages, too, don’t they?)

    • #13 by Ed on 2013-08-12 - 14:00

      put item on graph paper

      How quaint! [grin]

      Probably worked better than the storm door latch cam I made on the Sherline CNC mill, though. [Censored] thing had a square hole down the middle that I gnawed out with a square file and swore never again… except that I’ve replaced three identical latches on the three outside doors so far. I’ll definitely use 3D printing next time, even though plastic doesn’t have The Right Stuff.

      touch-scan routine

      Both for mapping an object and, more important for me, compensating for platform inclination / non-flatness through the probekins kinematics module. Most of that stuff gets buried in the LinuxCNC Wiki and requires considerable persistence to unearth… but the truth is out there!

      I think the gotcha with general 3D probing on an XYZ machine is having the point cloud describe only the top surface; I vaguely recall nested XY loops that cover the anticipated range at some reasonable resolution. Given that the top is the only surface you can mill, it might not be such a Bad Thing, but I don’t know how / if you could combine that cloud with a similar touch scan of the bottom surface (and sides?) to get a good solid model.

      • #14 by smellsofbikes on 2013-08-12 - 16:05

        In my case the graph paper approach made sense as I did the whole process on a car ride with no access to a computer. However, today I was poking around looking at dry sump systems design discussions and found some people who had scanned an oil pan, and then used SolidWorks to just eyeball-outline the dimensions to get a cnc drill file, which is another reasonably nice approach.

        I’ve a friend who designs 3d scanning hardware. I’ll run the solid model question past him.

        btw I’ve had some luck with 3d-printing shapes, then cutting brass or bronze bushings on the lathe, heating them up in boiling water, and pressing them into bores in the 3d print and chucking the works in ice-cold water.

        • #15 by Ed on 2013-08-12 - 16:30

          cutting brass or bronze bushings

          I like it!

          Something like that might work for the cam: the square hole has plenty of meat around the edges for a plastic shape and maybe I could embed rods in the sliding surfaces to take the friction. It’s a pretty simple design, with a stamped-and-bent steel bar (which I’ve also replaced) sliding against the brass cam. Guess what wears away after half a century?

          Thanks for the hint…

  4. #16 by Red County Pete on 2013-08-12 - 17:25

    Yet another thought on the storm door cam/bar combination. Is it practical to make a bar with a sacrificial wear pad out of Delrin or such? Sounds like the cam is a PITA to reproduce, and if some easier-to-fix element can be designed to go first, it would help. (I can tell I’m getting wiser older–I’m paying more attention to how to fix what I’ve already fixed before.)

    • #17 by Ed on 2013-08-12 - 19:04

      a sacrificial wear pad

      OK, I’ll write up what I’ve done and you folks can poke holes in it… [grin]

  5. #18 by smellsofbikes on 2013-08-21 - 13:35

    since we’re too deeply nested to reply in the right place: http://wiki.inkscape.org/wiki/index.php/Frequently_asked_questions#How_do_I_measure_distances_and_angles.3F
    so it looks like I’m set. I’ll give it a run tonight if I have time.

  1. Storm Door Latch: Repair Parts | The Smell of Molten Projects in the Morning