Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Make deep focused macro images with Raspberry Pi

If you ever tried to make macro photography you noticed that it is hard to focus 3D objects. Only at some depth you get clear view where other areas stay blurred. Of course there are expensive equipment available that helps expand field of depth, but who would want to spend money for non professional purposes. David found another solution to solve this problem. And this only cost a Raspberry Pi. His experiment consists of camera, old flatbed camera and Raspberry Pi.

Deep focused macro image

So he took scanner top and placed camera on a rail so it could move along. Connected RasPi to motor through stepper motor driver using four GPIO pins. Another pin he used to control camera shutter. The rest secret lies in Python script where wiringpi library is used to access I/O pins. The stand takes 42 stacked images at 6 fps rate. Each image is taken while camera is moving slowly towards object with fixed focal length.

So in all taken photos the object is covered with correct focal length at different points. After pictures are taken, they are combined using CombineZM software.

[..Source link..]

Bookmark the permalink.


  1. Just a note:
    I bought a Canon T3i and online they offer a SDK download. The camera is able to be fully controlled via the USB port (with the exception of the lens zoom).
    Even with the stock software, could use a mouse recording program to perform the capture portion of this task.
    Being that this is an embedded sight I understand that the end operation was not the goal. This is just a heads up that there may be an easier way to do this.

  2. No extra equipment, not even a stepper motor would be required because the lens in this article has auto-focus and the aforementioned, FREE, control software can step the AF motor (already built into the lens). With the camera in the article and $0 extra this can be done and you can use your raspberry pi for something more useful.
    I understand that the author thinks the DoF issue is there for all cameras and they think this is novel fix for a uniform problem. That’s not true though, the sensor size and f-stop for point-and-shoots are not restricted to narrow DoF in macro like the Cannon DSLR used in the article. Therefore this motorized contraption is even necessary until one approaches a f/4 or larger on a full frame sensor.

  3. Hi,
    The original authors name is David, not Daven. Also, it would be nice of you added a link back to the original source.

  4. Sorry David, for messing the name. Its fixed now. The link to original was always there as [Read] button.

Comments are closed