I recently wrote a Python script that reads EXIF data for camera, lens, and focus position and adds a scale bar to the photos: https://gist.github.com/welliam/f1df4594670b4b2165d0661a78b33a24
Here's an example of the result: https://www.inaturalist.org/photos/309888307
It's written with prime lenses in mind, though other lenses could be adapted to work for it. I didn't attempt a general formula, with my limited understanding of optics. Additionally, most people online say focus distance is not reported accurately from EXIF data at all, so a general formula wouldn't probably work. Even with perfect EXIF data, I'm not sure a general solution is actually possible; real life lenses are complicated.
Instead I manually recorded pixels/mm at various focus distances with the camera, and interpolate between them linearly. (Therefore, it doesn't matter if the EXIF focus distance is actually accurate, just that it's internally consistent.) It's a crude solution but it does seem to work; with test photos of rulers at random focus distances it seems to be reasonably accurate.
Right now it only works with known combinations of lenses and cameras (really just the one I use most often now, my OM-5 with the M.Zuiko 60mm macro lens). It feels like a safe assumption to just go off sensor size for the camera, rather than rely on an individual model, but without more cameras and lenses to try out I'm not confident about any assumptions.
I don't think a Python script is the best way to do this part. I want a sort of webpage that people can quickly add scale bars onto. The automatic derivation from EXIF data part will be hard to get support for without people contributing their own measurements (cameras are pretty expensive!); most likely I'll add an input field for manually specifying pixels/mm at various focus distances, and give people instructions on how to figure that out on their own.
Comentários
Adicionar um Comentário