Tilt Calculator module (tiltcalc.mo)

Started by ewinemiller, September 11, 2016, 07:17:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ewinemiller

Hi folks,

Posted here for feedback and suggestions; a module to calculate the appropriate tilt for tilt-shift lenses. Modeled after an android app I did a while back. Much quicker just to bring it up on the camera.

It puts a menu on the Debug tab.

README.rst


Tilt Calculator
===============

Tilt-shift lenses give amazing control of the depth of field by rotating the focus plane, but without knowing how much tilt to dial in, focusing can be frustrating and time consuming.
Tilt Calculator finds the tilt given your focal length and distance to the hinge point. No more trial and error focusing with your tilt-shift. Focus where you want it.

:Author: Eric Winemiller
:License: GPL
:Website: http://digitalcornersquid.com
:Summary: Tilt Calculator


tiltcalc.c


#include <module.h>
#include <dryos.h>
#include <menu.h>
#include <config.h>
#include <math.h>

static uint32_t focal_lengths[] = { 17, 24, 45, 90 };
#define FOCAL_LENGTH_TEXT "17mm", "24mm", "45mm", "90mm"

static float units[] = {10, 25.4, 304.8};
#define UNITS_TEXT "cm", "inch", "feet"

static CONFIG_INT("tilt.calculator.focallength", focal_length_sel, 1);
static CONFIG_INT("tilt.calculator.unit", unit_sel, 1);
static CONFIG_INT("tilt.calculator.distance", distance_sel, 60);

static MENU_UPDATE_FUNC(degrees_update)
{
double height = distance_sel * units[unit_sel];
int degrees = roundf(1800.0f / M_PI * asinf(focal_lengths[focal_length_sel]/height));
     
MENU_SET_VALUE("%d.%d degrees", degrees/10, degrees%10);
}

static struct menu_entry tilt_calc_menu[] =
{
    {
        .name = "Tilt Calculator",
        .select = menu_open_submenu,
        .submenu_width = 710,
        .children =  (struct menu_entry[])
         {
            {
                .name = "Focal Length",
                .priv = &focal_length_sel,
                .min = 0,
                .max = COUNT(focal_lengths)-1,
                .choices = CHOICES(FOCAL_LENGTH_TEXT),
                .help = "Select the lens focal length.",
            },
            {
                .name = "Unit",
                .priv = &unit_sel,
                .min = 0,
                .max = COUNT(units)-1,
                .choices = CHOICES(UNITS_TEXT),
                .help = "Select the unit for distance to hinge point.",
            },
            {
                .name = "Distance",
                .priv = &distance_sel,
                .min = 1,
                .max = 500,
                .help = "Select the distance to hinge point.",
            },
            {
                .name = "Tilt degrees",
                .update = degrees_update,
                .icon_type = IT_ALWAYS_ON,
                .help  = "[READ-ONLY] Set your tilt to this value.",
            },
            MENU_EOL,
        }
    }
};

static unsigned int tilt_calc_init()
{
    menu_add("Debug", tilt_calc_menu, COUNT(tilt_calc_menu));
return 0;
}

static unsigned int tilt_calc_deinit()
{
menu_remove("Debug", tilt_calc_menu, COUNT(tilt_calc_menu));
return 0;
}

MODULE_INFO_START()
    MODULE_INIT(tilt_calc_init)
    MODULE_DEINIT(tilt_calc_deinit)
MODULE_INFO_END()

MODULE_CONFIGS_START()
    MODULE_CONFIG(focal_length_sel)
    MODULE_CONFIG(unit_sel)
    MODULE_CONFIG(distance_sel)
MODULE_CONFIGS_END()


Regards

ewinemiller

Hi folks,

I've posted the compiled version at

https://www.dropbox.com/s/ume80p0ym8a0y1g/tiltcalc.mo?dl=0

and the source is now available at

https://bitbucket.org/ewinemiller/magic-lantern/src/tiltcalc/modules/tiltcalc/

It's only been tested on a 5D mark III.

Are there any tilt-shift enthusiasts watching?

Right now it lets you pick from the four canon lenses, but there are a handful of off brands at different focal lengths (e.g. 35, 80). Any input on just trying to find all those for a short list vs. just letting you pick anything from any focal length 8-200? ML's menu scrolling works really nice so a big list like that is not as bad as it sounds. I'm leaning towards the later.

Thanks,

jrumans

I just purchased the Canon 24mm TS-E II, will definitely check this out, thanks!
Sometimes you have to go out on a limb to get the fruit.

garry23

@ewinemiller

Great to see you experimenting. Like you I have a 5DIII and I have a 24 TS-E II.

I've posted about my experiences with this lens on my blog, eg http://photography.grayheron.net/2014/03/some-early-thoughts-on-tilt-shift.html

I did experiment with a Lua script to handle the simple DoF math, but in the end decided it wasn't worth the trouble, and now use the a simple approach of starting with a calc in my head (9/2J).

The reason being that the 35mm Tilt Shift at 24mm doesn't give you any refined access to tilting; and no feedback, like a dof on a non-tilt lens. The focusing process with the TS-E requires much iteration, eg using LV, that I found a tilt calculation beyond the 9/2J level not worth it.

The real value of ML with a TS-E is to use A-ETTR for exposure setting.

I offer the above as my experiences.

Cheers

Garry

DeafEyeJedi

Nice work @ewinemiller and thanks for sharing a compiled version for 5D3. Definitely will give this a test run as I can borrow a 24mm TS-E II from where I work.
5D3.113 | 5D3.123 | EOSM.203 | 7D.203 | 70D.112 | 100D.101 | EOSM2.* | 50D.109

ewinemiller

Hi all,

I updated this so that it starts with the canon focal lengths, but you can add and remove focal lengths now up to 10. The links in the second post are updated with the appropriate code and compiled module. It's been tested on 5D3 1.13.

Regards

Seanc

Very slick. Thanks!
I'm learning for the first time with an inexpensive Ukrainian 80mm T/S and this is helping me get started. The ability to customize the lens list is perfect. I'm using it just above the subject (pinball playfield) and this helped me zero in on the tilt amount to use.

ewinemiller

Until the where we land for source control question is settled, the code is squirreled away at https://github.com/ewinemiller/TiltCalculatorForMagicLantern