cross-posted from @[email protected]: https://lemmy.world/post/23787115

I’ve managed to do reverse engineering of circuit boards using GIMP and rough alignment of layers using images like the one pictured. I want to use images to reverse engineer parts in CAD, but the minor lens distortion of a camera on a phone at ~20cm high on top of a stack of objects to keep it eyeballed flat is not enough. The result is off in multiple planes. There are minor errors in my curves in the transparent CAD part pictured, but the hole pattern is correct. The picture has been calibrated to 20mm against the ruler. Any suggestions on how to make this usable for replicating the ellipse that crosses the holes ±0.05mm?

  • @werefreeatlast
    link
    1
    edit-2
    6 hours ago

    Mushroom*. Flatbed scanner. Telecentric lens…the only issue is that using a telocentric lens means that your object has to be smaller than the lens diameter.

  • @kitnaht
    link
    12
    edit-2
    4 days ago

    Flatbed scanner – takes a image along a single line, with no perspective distortions. Additionally, I believe I’ve seen some people set up cameras that can do the same thing, basically taking pictures overhead directly and laying all of that out as ‘layers’ on top of one another and getting rid of anything that was not in the ‘center’ of the picture in order to minimize distortions.

    I think there’s also some sort of trick with taking the photo from far away? I’m no photography expert, but I believe I’ve also been told that the further away you are from the object, the less perspective distortion you get. I’m not sure on this.

    • @officermike
      link
      6
      edit-2
      4 days ago

      As an engineer who sometimes has to reverse-engineer stuff to integrate with CAD, flatbed is the fastest, easiest way. You don’t even need to scan with a ruler or known scale either. If you scan at a known DPI, and you know the resolution, you can scale the image in CAD to (horizontal resolution/DPI) width by (vertical resolution/DPI) height. I don’t know how FreedCAD works in this regard with sketch pictures, but in SolidWorks it’s important to have an arbitrarily-sized, dimensioned piece of construction geometry in the sketch beforehand to lock in the scale (of there’s no existing sketches or solids). Otherwise, the scale can get fucked really easy with no way to unfuck them without starting over, as sketch picture dimensions entered when placing the image don’t turn into defining dimensions automatically.

      Edit: as for the camera, shooting with a long lens from really far away means the light rays entering the lens are nearly parallel rather than diverging. YouTuber “Stuff Made Here” has a recent video that briefly touches on this. https://youtu.be/aXfTgCCsRSg?si=FegiCAgFMKj6tDkv

    • astrsk
      link
      fedilink
      14 days ago

      Was looking for this comment. The camera and long focal length lens route does work, but short of spending hundreds or thousands on new equipment, $15-$25 for a cheap thrift store flatbed scanner will work wonders for years.

  • @CrayonRosary
    link
    English
    9
    edit-2
    4 days ago

    The easiest option is to take a photo from very far away with a long focal length lens. The longer the better. At least a 200mm focal length. You need a real camera and lens for that, and they aren’t free. And you can’t always get far away from your subject.

    Other people mentioned a flatbed scanner. Excellent choice.

    When I’ve needed to do this for something that didn’t fit on a flatbed scanner, I’ve used photogrammetry. Bonus is that you probably already have everything you need.

    Requirements:

    1. Any camera. A phone is fine.
    2. A computer with a GPU. An NVidia GPU is better for some software, but maybe times have changed, and this likely only affects the speed.
    3. Photogrammetry software. I used 3D Zephyr which has a free version limited to 20 input photos, and I’ve also tried Meshroom, which is FOSS, but I don’t remember if it worked well for me. (Thanks @[email protected] !)
    4. A ruler or something you can attach to the object for scale. I’ve often used masking tape with lines at a known distance, the father apart the better.

    Overall process:

    1. Tape a ruler to the object for scale.
    2. Take a bunch of photos from different angles.
    3. Load them into the photogrammetry software and let it do it’s thing.
    4. Take the resultant textured object into Blender and rotate it until it’s perfectly parallel to a coordinate plane. (This is actually not easy [1])
    5. Position the camera perpendicular to that plane and change it to orthographic rendering.
    6. Render an image.
    7. Use the image as a canvas in my CAD software, being sure to calibrate its size using the ruler contained in the image from step 1.
    8. Trace the image.

    This allowed me to measure the position of a whole bunch of really oddly placed screw holes on a 30x30" section of a wall with <1mm accuracy, allowing me to laser cut a thin sheet of plywood having holes in those same locations.


    1. Your object will be imported in a random orientaion, and your resultant mesh won’t have anything actually flat on it. You can’t just pick one poly of the mesh and say “make this poly parallel to my intended plane”. It will be rotated in some random way. Especially if the object is something random and bumpy like a brick wall. Even being off by a couple degrees ruins the result. I had to create a cube the size of my object and intersect it with my object, moving and rotating the cube until it visually appeared to be parallel to my object. It was like floating my object in water (the cube) until the surface of the water filled the nooks and crannies of my object more-or-less equally. Then I noted the rotation of that cube and applied the same negative rotation to my object. ↩︎

    • Rentlar
      link
      fedilink
      14 days ago

      I think the software you were thinking of is 3D zephyr.

      The best FOSS one imo is Meshroom. One tip when using that is to stop the process after the Structure from Motion process, add a bounding box around the main subject area so that there is less background modeled at the end.

      • @CrayonRosary
        link
        English
        2
        edit-2
        4 days ago

        Yes, that was the one. I tried Meshroom as well, at a later date. I forget if it was a success or not.

        Good tip, though! I have often had to clean up meshes after the fact using something like Meshmixer. (I am in no way skilled in Blender.)

  • @Cobrachicken
    link
    54 days ago

    I remember using a flatbed scanner then overlay the image in inkscape, scaling according to the scanned ruler. Don’t remember which menus there exactly, though. Was somewhat longish ago.

  • @Donjuanme
    link
    24 days ago

    Take a picture, or multiple pictures, while your object is on grid paper, then you can adjust the image to remove distortion.

  • @[email protected]
    link
    fedilink
    24 days ago

    A copystand, a used DSLR, and cheap autofocus macro lens that’s in the lensfun database should get you pretty close.