using exif data to straighten images

I take many photos (sports) with a Canon R7. I would like to speed up the process of straightening the images and cropping them to the largest area before doing any further editing. Is there a way to automate this in Darktable - or any other tool for that matter - using the Roll Angle field in the exif data? It occurred to me that one approach might be to write a shell script (I’m using Ubuntu) to check the exif data then edit the xmp files straight after importing the images to Darktable. I can see that the relevant section of the xmp file seems to be the bit about “ashift”, but I can’t interpret the “params” bit of that section which seems to be crucial. I’m open to suggestions of other approaches. Thanks in advance.

How are you getting the roll angle exif data?

What version of Canon firmware are you running on your R7? I too have an R7 and shoot sports, so I understand the issue :smile:.

This is doable using a lua script and correcting the image when it gets loaded into darkroom.

I can get the roll angle via exiftool from the command line. It’s not available in the image information in DT as far as I can tell (but I’m quite new to DT so maybe I’m just missing it). Firmware is 1.6.0. I don’t know anything at all about lua scripts yet so thanks for the tip about that.

Do you know that using its IBIS the R7 has an auto-level feature, so you get perfectly level shots directly (but this disables the higher speed burst modes).

Thanks - yes I did know about that but as you say, I can’t use that at higher burst modes which I need really.

Well I didn’t know that so I learnt something ne about my R7 today. Thanks.

Time to update my firmware :smile:

Probably my most favorite feature right now. Totally removes my signature half-degree-counter-clock-wise rotation in my landscape shots.

2 Likes

Do they explain how this feature works at all?

Thanks for the heads up about lua. I didn’t know anything about that previously, and have done a bit of exploring which was very informative. I have some knowledge of scripting in other programs and languages, so I know something of what is involved in doing this kind of thing. Unfortunately, at this point in time I don’t think I’m in a position to learn enough about lua to write something to handle the automatic rotation. Maybe one day…

I’m about ready to update my firmware. I’ll play with after that’s done and see what I can come up with.

There’s good news and bad news…

First the bad. I’m guessing that the pitch and roll data come from the IBIS, because when I shoot a burst the values are always the same as the first image of the burst.

Now the good… I wrote a script (WIP) that grabs the pitch and roll data and applies the roll automatically to straighten the picture. It works great :smile:

I played with the pitch data trying to see if I could use it. The vertical tilt is on a scale -1 to +1 while the pitch data is in degrees. Maybe I’ll read the code and see if that gives me a clue.

Here’s the script. It adds a preference under lua options to set the automatic cropping.

Drop it into your scripts and enable it.

auto_straighten.zip (2.2 KB)

3 Likes

Bill - wow! Thanks so much for this. I doubt you need me to tell you this, but this works perfectly. This will save me many hours of fiddling with images. Thanks again.

1 Like

The IBIS can rotate the sensor around the lens axis:

So if you couple this with the electronic level which is already in the camera, you just rotate the sensor to align with the electronic level.