Automating EOS Utility with Apple Script Editor

Every once and a while I have the need to focus stack a slightly larger object than my normal macro lenses will allow. In these situations I will just use a normal lens mounted on my camera, sometimes with a diopter on top. This can become both a blessing and a curse. A blessing because turning the lens focus ring is normally better than moving the whole camera. A curse because that means I shouldnt use Focus Stepper.

While there are a few paid solutions for stepping focus automatically with the camera's auto focus, I have found it more reliable to script EOS Utility to do it.

To beguin we just need to open up the Script Editor, EOS Utility, and finally UI Browser, The trial version works well enough for our needs, and can be found at http://pfiddlesoft.com/uibrowser/ . Apple also provides an Accessibility Inspector, but scripting with AX elements can be finicky some times, so we'll avoid that. When you first launch UI Browser, you need to go to System Preferences > Security and Privacy > Privacy > Accessibility and select it to allow it to control your computer. You also will need to do the same thing with Script Editor.

With everything open and running, step one is to identify the UI elements we want to control. Click "Switch to Screen Reader" in UI Browser and hover over the focus buttons to get the button names and the window.

Button and Window names, and we are all set!

Now that we have the information we need, we can start scripting.

Ill start by making a dialog that lets me set the number of images and which focus button to use. Since I only ever shoot front to back, I wont worry about the reverse focus buttons.

set DIALOG_1 to (display dialog "Number of images" default answer "100" buttons {"Fine", "Medium", "Course"} default button 1)
set repeatNumber to text returned of DIALOG_1
set btnPress to button returned of DIALOG_1
delay (6)

With the dialog out of the way, we can do the actual work. We will take the repeatNumber we set in the dialog and repeat out action this number of times.

repeat repeatNumber times

Then we need to make sure EOS utility is in focus using the activate command. I do this in the loop so that incase I accidentally click away from EOS Utility while the script is running, it will switch back when it needs to. Next we take out first photo before we step focus. The space key takes an image in EOS Utility, so I use that keystroke instead of fiddlign aroudn with the shutter button in the UI. Finally a short delay to let the camera to do all its mechanical stuff.

activate application "EOS Utility 3"
tell application "System Events" to tell process "EOS Utility 3" to keystroke " "
delay (2)

Now To step focus based on what we pressed in the dialog. There are a few options for doing this, but I ended up putting the elseif inside of the loop. A smarter person in less of a rush would have added the elseif before the loop and assigned the result to a new variable. Then used that variable inside the loop. It aint scripting if your doing it right šŸ˜‰ Then a small delay. This is so we have a short rest period between when the lens moves and when the shutter fires.

tell application "System Events" to tell process "EOS Utility 3"
if btnPress = "Fine" then
click button 14 of window 1
else if btnPress = "Medium" then
click button 11 of window 1
else if btnPress = "Course" then
click button 12 of window 1
end if
end tell
delay (0.75)

End our loop

end repeat

And let us know that the script has completed

display dialog "Complete" buttons {"OK"} default button 1

Improvements you can make!:

  • User specified number of times to move the focus before each image
  • Put the button selection loop in a intelligent place
  • Allow the user to cancel the dialog
  • Or if you are even lazier than me, you can download the script HERE

    Sensor-Film review

    Cleaning my camera sensors is not something I care for. It is a bit of a chore and can be costly in the case of solutions like sensor swabs. Though I can never solve not wanting to clean my sensor, I can try and find alternate methods for sensor cleaning that are effective and cost efficient.

    Sensor-Film is a paint on polymer made mostly out of PVA. It is water soluble and as such will only be able to clean debris that is not oily. If there is grease or oil on the sensor, it will need to be cleaned with a solvent like methanol. Ā Sensor-Film comes in two different types, one for sensors who's AA filter is fluoride coated and one for AA filters that are not. Since I have a Canon 500d(uncoated AA filter) and a Canon 60d(coated AA filter), I decided to try both.

    A video of the instructions Sensor-Film gives you for its usage can be found HERE. A few points I would like to add to this video. First, the little pieces of rip resistant paper included do not work. Having tried the paper several times, it just tears soon as you try to peel the film off. I would recommend using a piece of a fabric ribbon like what is used for decorating gifts, or something similar. Second, the dry time is on the longer end of what is stated. Close to 2 hours, plus 30 minutes to an hour for adding the tab. Finally, the film does not come off as easy as shown in the video. It adheres to the sensor and requires fair amount of force to pull off.

    This is my second time using Sensor-Film. The first time went without much issue, other than learning that the included paper tears rather easily. Ā The following images are from my second and most recent experience with it. The pictures were taken at ~F114 and enhanced to make dust more visible.

    60d Before60d SensorFilm

    60d Sensorfilm and self cleaning

    With the 60d and the fluoride Sensor-Film everything went about how I would expect. The film painted on and peeled off fairly easily. I noticed some smudge like spots in the image that I did not notice on the sensor. Running the cameras sensor cleaning Ā feature two times cleared the issue. I can only guess that they were some small flakes that were weakly adhered or clinging to the sensor due to static. A few spots were not cleaned up. I think that I might have not painted all the way to the top of the sensor to retrieve the hair looking object on the bottom of the frame.

    500d Before

    500d 1st Sensorfilm

    500d 2nd SensorFilm

    500d 3rd SensorFilm

    500d 3rd SensorFilm and self clean

    500d 6th SensorFilm

    500d Methanol

    Things grew more complicated with my 500d this time around. I should point out that the before picture is how the sensor was left since its last cleaning with Sensor-Film. During this cleaning cycle the film would tear near whichever edge it was peeled from. The first application was well within the sensor bounds. By the sixth time think I had gotten a little bit sloppy and might have got a bit close to the edge of the sensor. I omitted taking photos of the 4th and 5th applications because the results were the same as the other attempts. By the sixth time round I got tired of trying to reapply and peel it off in one piece, so I took some Crown denatured alcohol(which is about 75% methanol according to the msds) and a few spun cotton swabs to wiped it down. The alcohol worked well to clean up everything. I should note here that the denatured alcohol did leave a white residue if I put a lot of it on the sensor and let it evaporate. However if the swabs were just a little bit moist, it cleaned up the residue and left no other residue behind. In the future I may try some cheap lint-free swabs and denatured alcohol as an inexpensive cleaning method.

    In the end, my 500d sensor is a little bit less clean than the last time I cleaned it with Sensor-Film. Why I have had this discrepancy in usage I do not know. Meanwhile the sensor on my 60d is quite a bit cleaner. This more closely mirrors my previous experience with using Sensor-Film. For the time being, I think I will have to reserve my judgement on the normal version of Sensor-Film until I have had a chance to try it a third time. The fluoride version seems continue to work well.

    Deflicker images for focus stacking with Magic Lantern and Lightroom

    I have a portable flash that isā€¦unreliable. The net result of this is a change of exposure and color temperature between images when focus stacking with it. These subtle differences can cause brightness banding and color banding in a completed stack. While Zerene Stacker can compensate for changes in exposure, it still leaves shifts in color, and for larger shifts in exposure(I have seen up to 1EV for my sigma610) I find it better to correct the problem in RAW before converting to TIFF.

    Two exposures one after the other, uncorrected.
    Two exposures one after the other, uncorrected.
    The same two exposures with flicker correction.
    The same two exposures with flicker correction.

    The current build of Magic Lantern includes a deflickering module. When enabled this will examine the image and write an .xmp(Lightroom or Adobe Camera Raw) or .ufr(UFRaw) sidecar file which can be read by RAW software to offset the exposure value.

    First enable the post deflicker module and file manager module in Magic Lantern.

    ml_modules

    Next we make sure that image review is turned on(2 seconds should be fine). When the image review screen pops up, Magic Lantern will use this to analyze the image and create the sidecar file.

    Finally we set up the module. Since I will be using Lightroom, I set it to XMP. Deflicker percentile is what part of the image it will use to deflicker. Deflicker target level will be the offset for the values. We will want to take a couple test shots to try and get it as close to 0 as we can.

    deflicker

    In the file manager, you can view the XMP file and check what the exposure value it will set will be. If your image is close to correctly exposed you will want to have the exposure2012 value as close to 0 as you can manage by adjusting the Deflicker target level.

    filemanager_xmpview
    The Exposure2012 value is at 5.7 here. I would want to lower the Deflicker target offset to get it closer to nill.

    At this point you are ready to shoot your sequence.

    Once you are done, import into Lightroom as usual, and it should automatically import and read the XMP sidecar files. Now images have been deflickered from any changed in exposure. It is important now not to modify the exposure slider inside of Lightroom. When copy and pasting settings or syncing settings make sure that "Exposure" is unchecked, since values will be applied absolutely. Now to fix the slight shift in color temperature we set the white balance to auto on all photos by either copy and pasting settings or syncing the settings. When looking at the develop settings for each photos you should now notice difference values for exposure and color temperature across the series of images, and everything should appear uniform in brightness and color.

    The white balance may not be set at what you want and the exposure values might not be exactly where you desire. Since Lightroom can not offset values relative to their current value, we have to do this some other way. Luckily it isnt very hard.

    Method 1: In Lightroom go to the Graduated filters and drag on out outside of the image, so that the whole image is effected by it and there is no gradient on the image. Then you can simply adjust the exposure and color temperature on the graduated filter. Once you are done, copy and paste the filter to all other photos.

    Method 2: We need to install ExifTools. In Lightroom now, select your photos and go to Photos>Save Metadata to File while in the library module. Ā  This writes XMP files to the directory the images are in. Now you can open up terminal or command prompt and paste the following:

    exiftool -Exposure2012+=+0.00 -WhiteBalance="Custom" -ColorTemperature+=+0 -Tint+=+0 -ext xmp /FolderToXMP

    Where "+0.00" is, type the offset amount for your exposure value. If you want to subtract 1.2EV, then it should look like "-Exposure2012+=-1.2". The same goes for "+0" for Color Temperature and Tint. The "WhiteBalance" tag changes the dropbox in Lightroom from "Auto" to "Custom" so that the change to white balance will update as expected. Where "/FolderToXMP" is put the location to where the images are.

    Now in Lightroom go to Photo>Read Metadata from File. Changes will now appear and value will be offset.

    Using exiftool gives you another bonus you can do. You can write out the values to CSV and modify them or examine the values with a spreadsheet. The following command will give you a CSV with exposure, color temperature, and tint values.

    exiftool -csv -Exposure2012 -ColorTemperature -Tint -ext xmp /FolderToXMP > /FolderToWriteFile/list.csv

    For this image for example, I know the standard deviation for exposure is ~0.17EV with a color shift of 43.6K.

    Final image, with out the need for brightness correction in Zerene.
    Final image, without the need for brightness correction in Zerene.

     

     

    Welcome

    Currently, I am still in the process of setting up this site and producing content. In the interim though, I have decided to make it live so I can provide articles when they are ready.

    In the future I will likely update the site's design and expand upon the types of content I write about. Till then expect this site to be fairly underdeveloped.