Focus Stacking with a Raspberry Pi – One year On

    It is more or less a year since I got my focus stacker working, and there have been many developments and changes to the set-up during this time.

    What’s good?

    • Interfacing with the RPi using a laptop running MobaXterm is straightforward and the built in editor is really handy
    • The concept of moving the specimen and not the camera works well – the moving parts are very light weight with hardly any inertia, and vibration is not an issue.
    • The Componon 28mm lens is a dream – so sharp
    • Continuous lighting using a light box lit from below is a simple solution to provide even diffused lighting
    • The whole focus stacker rig works, and produces very acceptable extreme macro images
    • It has kindled an interest in entomology and insect anatomy

    What’s not so good?

    • Getting real time into the RPi automatically – should be easy!
    • Setting up the specimen is still fiddly – but not as difficult as it was before the jack and the rack
    • Cleaning and mounting the specimens – and there is nothing that can be done about that other than doing it!

    What next?

    • Fix RPi real time – somehow DONE
    • Build a bigger light box to give more room around the specimen for adjustment DONE
    • Take more stacks
    • Improve my insect identification and understanding of  insect anatomy

    And then? 

    • A  3-axis (of spin) specimen mount – motorized – remote controlled – ha ha!

    Focus Stacking with a Raspberry Pi – The Quest for Repeatability and Predictability

    Repeatability  – (of an experiment, etc) producing or capable of producing the same result again

    Predictabilityconsistent repetition of a state, course of action, behavior, or the like,making it possible to know in advance what to expect

    ………………………………..wouldn’t that be nice?

    Last Tuesday at Tetbury Camera Club we had an inspiring talk by Jay Myrdal who explained how he made stunning commercial images back in the day before Photoshop when it all had to be done in camera – a plate camera quite often. The techniques he explained were fascinating and the results were truly stunning. Some of his images involved taking action shots such as an exploding light bulb – this would be just a part of the image but he would have to shoot it over and over again to get all the timings of the effects just right. He built a rig to automate and adjust the various factors involved so he could tweak the important parameters knowing exactly what he had done beforehand and so migrate towards an optimal set up. He also scrupulously calculated all the angles involved in multi-layered super-imposed images to get things to look right from the perspective point of view.

    Double fly
    Double fly

    This got me thinking that I needed to apply his philosophy to my macro photography, which up to now I have been carrying out on a rather hit and miss basis in terms of choice of lens configuration, and adjustment of stacking parameters. So I decided to apply some of Jay’s thinking to the matter.

    My rig is pretty much automated already, but the key issue here is recording all the parameters that I have used for each stack in enough detail to enable evaluative decisions to be made after processing (which may be some time later) so that the parameters for the next stack can be improved or consolidated. I already have lots of bits of paper lying around with scribblings of what I have done but no real way of tying these back to the images I have processed. And not everything is written down anyway. It needed organisation and preferably automation.

    I was already in the process of updating my Raspberry Pi Python software for my focus stacker to add refinements based on the last few months shooting. As a result, my mind was in tune (as much as it will ever be!) with Python 2.7 and Tkinter, and then two and two came together and for once made four! I decided to automate the logging of my focus stacks using my RPi.

    I won’t bore you with the details of how I did it – programming and more programming is all you need to know! But this is what it now does.

    There are some user interface windows to enter information that the RPi doesn’t know such as what camera is being used, the lens configuration, the subject matter, and the camera settings. You can also enter a note for each stack. The software gathers up all the info it already knows about the shoot such as the near and far focus points, focus increment and so on; date and time stamps the log, gives it the next shoot number and then (and only) when the shoot sequence button is pressed, the whole lot is appended to a .csv log file.

    The .csv file can be read by Exel and as long as the camera and RPi are telling the same time I can figure out which log goes with which image stack.

    One hiccup in proceedings is that the RPi is not on the internet, and so the RPi cannot find out automatically what time it is. That’s because it doesn’t have its own real time clock and battery (it apparently kept the cost down) and relies on the internet to reset its clock each time it is turned on. No internet, and the clock just restarts from where it left off last time it was on! Not terribly useful. At the moment I have to enter the time manually into the RPi when I turn it on – it is very easy [sudo date -s “Sat, October 18, 2014 17:21:00] for example. But I might forget.

    What would be better is to get the lap top to tell the RPI what the time is. That is all within the realms of possibility. I would have to set up the lap top as an NTP server which Windows 7 does support. It seems to require some mining in the registry to do this, something I am not too keen on doing. There is plenty of advice on the internet, but I will have to nerve myself up before trying this. Then you have to rummage in the RPi’s software settings too. I may have to get my (no-longer) resident expert to help me on this some time.

    Finally, I have also made some measurements to establish/check the exact magnifications of my various lens configurations, and have produced a chart to enable me to select the best lens configuration for a given subject size. It requires measurement of the subject height to get it right first time – something I had not been bothering to do. The chart is shown below

    lens data
    lens data


    Focus Stacking with a Raspberry Pi – Focus-Stacker Project Parts List

    I thought it was time that I set down the list of parts that were used to build my focus-stacker. The cost was less than £120. If you live in the USA you could probably do it for the same in dollars – or less!  And it does depend a lot on what you have lying around at home that you can use for this project. I have not included anything to do with lighting or camera equipment other than the IR trigger. Most of the parts were purchased on e-bay with some like the Pi  itself coming from Amazon. You do need to check when purchasing cheap electronic parts on e-bay to make sure they are not coming from Hong Kong if you want them quickly. Shipment from HK  can involve up to a ten week wait for the item to be shipped surface, though sometimes items arrive remarkably quickly. Factor shipment time from HK into you procurement and build schedule if going down that road.

    For the working parts – electronics, motor and rack drive:

    1. Raspberry Pi RBCA000 ARM 1176JZF-S Motherboard 512MB RAM – £ 27.39
    2. 8GB SDHC SD Card pre-loaded with Raspbian “wheezy” Linux operating system – £8.29
    3. iZKA® High Power Micro USB UK Dedicated Mains Power Wall Supply Charger For Raspberry Pi – (5V / 2.1A) – £6.99
    4. 40 wire ribbon cable Male to Female with ends broken out to individual contacts – £4.99
    5. 40 wire ribbon cable Female to Female with ends broken out to individual contacts – £4.99
    6. Arduino 5V 4-Phase Stepper Motor with ULN2003 Control Board – £6.90
    7. SainSmart 2-Channel 5V Relay Module – £8.00
    8. Micsc LEDs, resistors, switches, nylon stand-offs, nylon screws and bolts, solder pins, Veroboard, fibreglass sheet, and project boxes – approx £35
    9. Camera infrared remote control for Sony Alpha – £2.69
    10. Stalk for camera remote IR  – salvaged from flexible USB LED lamp £ 1.98
    11. DVD Rack – salvaged from old DVD player
    12. Misc Lego Technic gear wheels – approx £5
    13. Other miscellaneous electrical components and cable ties – from a box in my shed

    For the chassis:

    1. Aluminium channel 3/4″ x 3/4″, aluminium angle 3/4″ x 3/4″ and 1/8″ aluminium plate – all  from  my shed
    2. S/S and other hardware to hold everything together and three rubber feet
    3. Camera Rack – old Minolta rack lurking in my junk cupboard

    I will cover the software side of things in another post.

What’s it all about?

Here are my jottings about my photographic projects and activities. I have been working on a focus stacking macro photography rig. There are quite a few posts about that. In addition I write about other photographic activities as and when!


Category Specific RSS


Warning: A non-numeric value encountered in /home/public/mhp_blog/wp-content/plugins/ultimate-social-media-icons/libs/sfsi_widget.php on line 238