New CHDK script for KAP - UAV for fast shutter speeds
  • A new KAP script for CHDK has been published by waterwingz on the CHDK site:

    http://chdk.wikia.com/wiki/KAP_&_UAV_Exposure_Control_Script

    The main purpose of the script is to manage all of the exposure settings so that a fast target shutter speed is maintained, thereby maximizing picture sharpness. The variables are managed independently for each picture, which provides flexibility for variable lighting conditions not available from a simple Tv mode setting. The script also provides the usual intervalometer parameters, as well as parameters for exposure compensation, zoom, fixed focus at infinity, and USB run/pause control. The hope is that you can set all these parameters in advance, and just start the script running when you launch rather than having to change camera settings manually.

    The script works for cameras with any combination of adjustable iris and/or ND filter. It will run under CHDK versions 1.2 and 1.3, but in either case build 3149 or later is required.

    This project grew out of previous discussions on CHDK's Custom Auto ISO function, which works in a manner similar to the new script, except that it does not manage the aperture setting.

    I've been working with waterwingz for a couple weeks on this script, and I think it's pretty good, but any input on needed changes or fixes would be appreciated, either here or in the CHDK forum.

    I hope the script will be useful.
  • In case you missed it, you may be interested in the following comments that I have posted previously :-

    Michael Layefsky and others have long used the following SDM methods that give correctly exposed images at 8x normal shutter speed :-

    http://arch.ced.berkeley.edu/kap/discuss/index.php?p=/discussion/4705/sharpness-revisited-for-chdk-users#Item_14

    The second method allows you to set maximum ISO.
    This has been used on stratospheric balloon flights.
    It does what you want the CHDK script to do.

    My own tests suggest that with these small sensor cameras and with a subject essentially at infinity (which optically can be less than two metres at wide-angle !) stopping-down the aperture is undesirable.

    It reduces sharpness and forces a lower shutter speed.

    Bear in mind that f4 on these cameras is typically equivalent to f22 on a 35mm camera as far as depth-of-field (that you do not need) is concerned.

    The SDM strategy is to force the ND filter out and set aperture to maximum.
  • Thanks so much, David, for your encouragement and support.
  • Thanks wayback! I'll test this script as soon as possible! Unfortunately I have no idea when that is, the weather seems quite sucky this week and sunlight very limited. I hope for next weekend. But the script looks nice, good work.
  • It may be useful to provide hard evidence as to why I say shutter speed and iso alone can deal with all practical shooting conditions.

    Consider the following settings from a user in Las Vegas in very bright conditions :-

    Bv96 = 900 (brightness)
    Sv96 = 465 (100 ISO real)
    Tv96 = 1148 (1/4000 sec)
    Av96 = 363 (f3.7 real)

    In other words, aperture fully open in very bright light.
    Most shooting conditions will be in dimmer light where shutter speed needs to be reduced and/or ISO increased.

    There is no reason to change the aperture (that is, make it physically smaller).

    For cameras with an ND filter that is obviously ALWAYS forced out.
  • In my experience with my A590is, mid-range apertures seem to be a bit sharper than either wide open or completely stopped down. So I would prefer to shoot at something like f/3.5 or f/4.0 since that produces better pictures for me. But that's a preference, and for KAP in particular I would be willing to go wide open if it means I don't have to slow down the shutter speed, which is the most important determinant of getting sharp pictures. The script manages those decisions automatically based on the user's parameter settings and the algorithms described in detail in the wiki linked to above.

    The new script has the advantage of letting me set value preferences and ranges for all exposure components - shutter speed, ISO, and aperture or ND filter. Someone who believes the aperture setting has no effect on sharpness can set his aperture preference to wide open and shoot on that basis, and he may still benefit from other features found in the script. Or if he doesn't want to use the script, he can lock his aperture to wide open and just use the Custom Auto ISO function found in the CHDK menu, which works much as the script does, but without any aperture control.

    So the script offers the user a good bit of flexibility to set the exposure preferences the way *he* wants to, without locking them in stone, and it provides within the script a few settings that normally require manual camera settings, such as going into manual focus, then setting focus to infinity, or zooming to a particular point. In fact, if you use auto-run, everything would be automatic - you would only have to hit the power button to turn on the camera.

    By the way, I should mention that for my A590is, and presumably the A570is, the Focus setting "MF2" in the parameters is the one that works to go to manual focus at infinity. Or if you want to use autofocus, just set that preference to "Off".
  • OK, updated CHDK version and installed the script. Looks good. Now just waiting for airtime. :D
  • I hope you get some good wind, Henrik. Let me know how the script works for you.
  • Alrighty, I had a test drive today! :)

    The wind was scary, but I had set my mind to test this, so I did.

    It was bumpy ride, so I decided to target 1/1000.

    Relevant settings that I used:

    Av Mode: Iris
    Target Tv: 1/1000
    Tv Max: 1/2000
    Lowest Av: 2.8
    Target Av: 4.0
    Highest Av: 8.0
    ISO Min: 80
    ISO Max1: 100
    ISO Max2: 200

    I deliberately kept the ISOs low.

    I'm very happy with the results. Even though the light was already so low, that every pic was with f/2.8, I think the readings are consistent. And the exposure is as good as it gets with this camera (A640). Clouds over exposed mostly, but that's a metering issue, I think I have to set exposure compensation down a bit, and that'll do the trick. There was couple pics with 1/1000 and ISO 120, so quite close already to switch to f/3.5 or so, but not enough light. Exposure range in the captured pics was from 1/320 to 1/1000.

    All in all, I'm very happy with this. It's clear, easy and it works. Thanks Wayback! :)

    All saved pics from the trip:

    http://harkonen.smugmug.com/Kites/Rikalanm%C3%A4ki-25102013


    image

    -Henrik
  • I'm glad it worked for you. The pictures look sharp, which was the primary goal.

  • Anxious to try it also with my A810, which has only ND filter, no iris. :)
  • Thank you for a very nice script!
    I used it today with a powershot 230HS to shoot theese images: http://rotand.dk/pics/sat131026/
    I only changed the frequency and used the ND filter setting. The images were much better than last attempt.
  • Does the script allow the focus to be set by hyperfocal distance (based on f /stop and zoom focal-length)?

    Photos taken with an A590 using the hyperfocal distance are sharper than using infinity.
  • The current script does not have a hyperfocal focus option but it would be easy to add to the next release if you think that would be valuable?

    Edit : I should probably also point out that the ability of CHDK to successfully set a manual focus varies somewhat with camera model. The script allows you to select from all the methods discovered so far (trial & error) to see which one might work for your camera. If one of the methods works then hyperfocal distance selection is possible.
  • bisenberger, do you use CHDK to set the focus to the hyperfocal distance? I've never played with that on my A590, but testing the various focus distances you can get manually on the camera, I haven't found that the next step closer from infinity, which I think is 20 ft, is any better than infinity for sharpness.

    If you're not using any zoom, and the aperture is f2.6, what is the hyperfocal distance?


  • Hi waterwingz,
    I just upgraded my CHDK in my PS A590is to Ver 1.2.0-3192 an loaded the script, but when I start the script I get the following error: bad argument #1 to ´set_prop´ (number expected, got nil) and the script gets terminated.

    What I'm missing?
    Any help is really appreciated.
    Regards
    Ramiro
  • Ramiro

    when you did the upgrade to CHDK did you update the CHDK folder? There should be a LUALIB subfolder with a file called 'propcase.lua' and a subfolder in that called GEN with various propset files (propset1.lua etc). The set_prop command needs to access that stuff.
  • Just managed to upgrade CHDK to 1.2 on one of my A2300's and loaded the KAP UAV script. Seems to work except the MF4 setting causes CHDK to stall.
  • Getting manual focus to work properly with CHDK is a bit "hit or miss". The method needed varies a lot from camera to camera unfortunately so the script includes all the methods most commonly used. Not all will work - you have to do a little "trial & error" to see what works for your camera.
  • As Dave said, if you're updating to a new major version of CHDK, such as 1.1 or earlier to 1.2, or 1.2 to 1.3, you want to download from the "Complete" column on the downloads page, not the "Small" column. Delete all the old CHDK stuff on the card, in both the root directory and the CHDK folder, then replace it with the Complete stuff, plus of course the new KAP script, which goes in the Scripts subfolder.
  • Thank you very much Dave and wayback!!
    I just did what you said and the script worked without any problem!
    Regards
    Ramiro
  • waterwingz, yes hyperfocal distance would be a valuable option.

    wayback, yes I use CHDK to set the hyperfocal distance. On the version of CHDK I've been using if your A590 is in manual focus mode (with ALT on) pressing the down button sets MF distance to hyperfocal distance. The resulting image is sharper than when it's set to infinity. The A590 is still and excellent KAP camera.
  • The following is from the CHDK April 2009 user guide.

    More keys and shortcuts:
    In manual focus mode - (with ALT)
    Up – Set MF to infinity
    Down – to set MF distance to hyperfocal distance (based on f/stop and zoom focal-length).
    Left – Decrease Value Factor,
    Right – Increase Value Factor.
  • I've now tried this lua script on both my A640 and G7 and I am very impressed. I've yet to test it on my IR converted A640.

    The addition of hyperfocal distance to the script would for me be the icing on the cake. When taking full fish eye images and using the zoom to fill the view finder, it would hopefully ensure better definition in the images especially towards the edges of the image. I know the quality of the optics figures here too but it would help.

    To understand the problem this site has an online Depth of Field Calculator which not only gives numbers but graphics to complement your entered data. Using my data you can see by the graphics how setting the focal length/hyperfocal distance can affect the image outcome.

    Data: Canon A640, Focal Length 5.8mm (29.2x0.2=5.84 [0.2=fish eye value]), f-stop f/4
    approx vertical height 150 feet.

    image

    The site also has an extensive list of Circles of Confusion for most cameras as well as a calculator.

    Peter

    Further explanation in my case using fish-eye. The problem is I need to over-ride the camera doing its own thing while range-finding. The circumference of the lens impedes on the camera's sensors, giving erroneous readings. The manual setting is such a fiddle and therefore errors when setting up. The ability to dial it in once and for all is attractive.
  • Thanks for the links toadstone, very handy!

    Like wayback, I found the sweet spot on my A590 IS to be around f/4.0.
  • A590 IS:
    If the focus lock is set to off in the script, and you use CHDK to set the focus to hyperfocal distance before running the script the photos will be taken at the hyperfocal distance. You will want to make sure Iris is not enabled for AV Mode in the script, as different apertures will affect the hyperfocal distance.

    Really cool script!
  • Toadstone,
    I have been playing around sometime with hyperfocal distance with my A590is and my experience is that if you set the focus in the hyperfocal distance, although it is technically true that you get the maximum depth of field possible, the sharpness in "infinite" would be almost not acceptable.
    And usually focusing in the hyperfocal distance it is not needed while doing KAP since you don't have a lot of objects too close to the kite even, if you are taking pictures of other kites.
    Plase take a look to the table below.

    Canon A590is

    https://www.dropbox.com/s/2u7dqkcbpsqqwux/DOF_A590is.jpg

    I hope this helps.
    Regards
    Ramiro

    PS: For some reason I can't include the picture of the table :-(
  • Here's a comparison between infinite and hyperfocal focus with safety MF both off and on. Safety MF makes a big difference on hypefocal.
    f/4.0 - 1/800 - ISO 80
    image
  • As I see it, the infinite picture is sharper at the far end than the hyperfocal picture, which is what I would expect.

    You can't really tell anything from the safety MF pics because safety MF is actually autofocus, and since you have both near and far objects in the frame, you don't really know what it's focusing on each time.

    If the hyperfocal distance is, say, 10 feet, then focus is perfect only at 10 feet. Nearer or farther away, the subjects may still appear to be in focus, but really they are just not enough out of focus to be recognized as such. But still, focus is always best at the nominal subject distance, and deteriorates as you move away from that distance. That's why I think infinity is almost always the better choice for KAP.

    Waterwingz can do as he likes, but I just don't think building in a hyperfocal setting into the script would be useful for the great majority of KAPpers. Might be more useful for UAV though.
  • The above is not a valid test.

    "the subjects may still appear to be in focus, but really they are just not enough out of focus to be recognized as such."

    Which means they ARE in focus under those viewing conditions.
    The point is, the magnified views in the images above represent a different set of viewing conditions.
    For the magnified images viewed at the same distance, the 'circle-of-confusion' would be smaller and the hyperfocal distance would be different than that used.
    It would move closer to infinity.

    I agree there is no point having a hyperfocal option.
    If you are using a wide-angle setting with a UAV then it is not needed there either.
    Anything beyond one metre is at infinity anyway.

    As for aperture, that should not be variable but fixed at your determined optimum value.
    In the case of my S95 that is fully open.

    Just change shutter speed and ISO, that is all that is needed.

    Keep it simple ............
  • The photos were all taken from the same location on a tripod at f/4.0 - 1/800 - ISO 80. The only difference between the images were the focus set at hyperfocal and infinite and the Safety MF setting. The posted image is a screen capture from Adobe Bridge Review Mode. The Loupe tool is a feature of Review Mode that lets you compare areas of different images at 100% magnification (1:1). For more information on Adobe Bridge Review Mode and the Loupe tool see this link.
    http://help.adobe.com/en_US/creativesuite/cs/using/WS7049512F-0ED0-4f33-B6D9-D7B89F8F0909a.html

    I agree that it looks like hyperfocal distance is of little value for KAP.

    I've notice with my cameras that the sweet spot is around the middle of Aperture range. I prefer to use the AV setting for KAP with lower ISO to avoid noise in shadow areas.
  • I think that you will find that most cameras have a f stop sweet spot. For example my DSLR Canon EOS 450d with kit lens is f8. Max. 5.6 - Min. f36. However in the context of KAP and the smaller cameras we use, we are limited to the available stops and the balance between higher shutter speeds, and ISO etc. so this script is a real God send for setting everything up before hand, without forgetting something in the field.
  • Waterwingz has released version 1.2 of this script. The link to the file is shown on the wiki entry:

    http://chdk.wikia.com/wiki/KAP_&_UAV_Exposure_Control_Script

    This version cleans up some minor issues with focusing at infinity and USB control, and adds 1/640 second as a target Tv option. However, the exposure calculation logic has not changed.

    He has also clarified and simplified some of the wiki text.

    In my testing, I've found it very helpful to have in the script all of the settings I previously had to do manually, such as going into manual focus and setting subject distance to infinity, while at the same time dealing with the Picavet and the kite. Now I can set the script parameters and camera settings in advance, turn on autorun, and the script will begin executing just by hitting the power button.

    I also think we have the logic right for exposure control - maintaining a fast shutter speed, but providing flexibility in case that's needed to get the shot. The wiki describes the specific logic used for exposure.

    I really appreciate the time and effort Waterwingz devoted to writing this script and the wiki entry. I was able to help with testing, but almost all the code, and certainly all of the expertise, was his. I hope the script will be useful.
  • Thanks again, @wayback and @waterwingz for this! I'll update to 1.2 asap. 1/640 sounds good addition to the Tv target range. Too bad the active KAPing season is already way behind... :(
  • Perfect! thanks Waterwingz.
  • Just a quick note to let everyone know the script was updated to version 1.3 today. The change is to correctly handle the ND filter on cameras that do not have a user adjustable aperture. The download link is here : http://chdk.wikia.com/wiki/KAP_&_UAV_Exposure_Control_Script

    On a related note, the CHDK wiki has nice page showing all the camera variations by model that affect what CHDK can do : http://chdk.wikia.com/wiki/CameraFeatureTable
  • Sweet, perfect timing! I just picked up an A3400 from a holiday deal and was just getting started experimenting with the previous version. I'll switch to this new one and start learning. Thanks for the updated script!
  • Hello Waterwingz and thanks again for your efforts in helping the community.

    Questions : is there a way to force a minimum speed ? I can only see a target and max speed but no minimum
  • philgib : currently the script will hold the target Tv (shutter speed) until the aperture has been opened all the way, the ND filter is out, and the ISO setting has been raised to ISOMAX2. Only at that point will it start to decrease the shutter speed - to maintain the correct exposure. I'm guessing that your request to set a low limit to the shutter speed is because you can adjust somewhat for the resulting underexposed image with post processing, but you can't fix any blur resulting from the shutter speed being too low? That makes sense.

    I've had a couple of other requests for additional script features. I'll roll this one in too and post back here when the next update is complete.

    WWZ
  • Script updated to v1.4 per user requests.

    http://chdk.wikia.com/wiki/KAP_&_UAV_Exposure_Control_Script

    Changes include :
    1) Addition of a minimum Tv setting to limt the slowest shutter speed that the script can use. In low lighting situations, this can lead to underexposed images that may need to be fixed in post processing but that's probably better than having correctly exposed blurred images.
    2) Addition of an option to power the camera completely off when the specified number of shots has been taken.
    3) Clean up to the text console to block less of the LCD image area.
  • @waterwingz Thanks, keeps getting better and better! :)
  • Excellent! Thanks waterwingz.
  • Updated today to v1.5.

    KAP_UAV_Exposure_Control_Script

    This version uses a new CHDK command that completely turns off the LCD display rather than the old command that just temporarily turned off the backlight. It requires a recent CHDK release - either the stable 1.2.0 version or the development 1.3.0 version.

    Edit : older version of this script (v1.4) archived here : kap_uav.lua v1.4
  • FINALLY I got the change to try out this script in action. Used the old 1.3 version, but it worked just fine! Perfect!

    Too bad I set the target speed only to 1/1000, and the wind was blowing 10m/s. Also A810 is really noisy at ISO 200 and up, next time I'll just set the hard limit to 100 or max 200. Also the ND filter seems to introduce some smoothness to the picture. :(

    @nasion: Hope you got that sunny weather already in Michigan, like I was enjoying today! :) Though -10 C @ 10m/s isn't that tempting combination. Young drivers had fun on the ice with cars...

    Click on the pic for couple more pics:

    image
  • @heharkon, today was our first sunny day up here in Michigan's Keweenaw Peninsula with wind in weeks! It was very chilly though, with wind chills hitting -30°F (-34°C) at my first KAP spot. I took off work to take advantage of the sun/wind combo to fly at a couple spots. I kept my A3400 shelved for today, didn't want to risk it crashing into the snow.

    Eagle Harbor Lighthouse
  • Very nice! :) One nice thing about kiting, is that you most of the time face away from the wind, not against it, so your face doesn't freeze that much. :)
  • The CHDK kap_uav.lua script has now been updated to version 2.2.

    Principal changes include interleaved video recording options, more robust and simpler focus at infinity options, automatic camera ND filter / aperture detection, and much much more. Script documentation and download links are here : http://chdk.wikia.com/wiki/KAP_UAV_Exposure_Control_Script

    To make things simple, all script configurations have good defaults. You can simply download, install, and run the script and expect good results with no additional modifications. Not complicated at all.

    But if you need to tweak things to your preferences (and who doesn't?) then the capability is there.

    Comments, request for features, and (heavens forbid) bug reports are welcome here, or on the CHDK forum : http://chdk.setepontos.com/index.php?topic=10822
  • Thanks for the new version, waterwings. I think the video interleave is particularly nifty. If nothing else, it will show how much the camera is moving around up there.
  • An updated version of this script (v3.0) is now available.

    The script now includes several USB control modes in addition to its standard advanced exposure control and intervalometer functions.

    New USB modes include :
    1) USB control off (ignored)
    2) USB control enables / disables intervalometer shooting
    3) USB triggers a single shot each time the USB power is pulsed
    4) USB controls more advanced camera functions ( shoot, zoom, lens in/out ) via a PWM device like the Gentles gentWIRE-USB2

    Other updates include some minor cosmetic tweaks and logging of a bit more information about the initial camera state (for debugging user issues).

    As always, up-to-date documentation and download links are available here : CHDK KAP_UAV Exposure Control Script Wikia Page
  • Updated to v3.1. I found a way to "help" some of the rare camera models that don't like to focus at infinity after setting zoom position.

    Same download links as before.
  • Sounds great @waterwingz !

    I'm still using 2.4 it seems, but maybe it's time to upgrade.

    Btw, would it be easy to implement some sort of cycling zoom position setting? I.e. have at least two zoom positions, which would be cycled through the shots? Of course, zooming constantly in and out would drain the battery fast, but would be interesting feature. Now when I think of it, I guess the "normal" interval script had such a feature?

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion