Camera database for FOV: Fallback to 35mm equiv., local database?

Started by lbo, September 30, 2018, 06:23:45 PM

Previous topic - Next topic

lbo

the FOV display is very useful (I shoot aerial photos)!

Will IMatch use my camera's EXIF data contains 35mm equivalent focal length if there is no entry in the database?

After all, I would welcome a possibility to maintain also a local crop factor database.

Oliver

Mario

The sensor size is needed to calculate the FOV (in addition to the col length, which is pulled from EXIF/XMO).

The sensor size is not recorded in EXIF, hence all the camera database mumbo-jumbo was required. I could have done without, but this was the most comfortable solution for my users.
You don't need a local camera database. The Map panel caches the data once retrieved.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lbo

Quote from: Mario on September 30, 2018, 06:31:29 PM
The sensor size is needed to calculate the FOV (in addition to the col length, which is pulled from EXIF/XMO).

The Sony RX100 .arw contains the Exif information "Focal Length In 35mm Format", this seems to be sufficient information.

Quote
You don't need a local camera database. The Map panel caches the data once retrieved.

Maybe a misunderstanding:

I would prefer a local file where I can place crop factors of cameras I use.

This way I can get the correct FOV immediately without your help.

Of course I also help creating a photools maintained camera list, but I think the user should be able to do it also alone.

Oliver

Mario

The focal length is used when calculating the FOV. But the sensor size / diameter is the critical part, to calculate the field of view. Sensor size is not accessible via EXIF metadata.

QuoteI would prefer a local file where I can place crop factors of cameras I use.

I prefer to create and maintain the data in one central place.
If you don't like this, feel free to clone the Map App and implement your own custom solution.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lbo

Quote from: Mario on October 01, 2018, 10:23:56 AM
If you don't like this, feel free to clone the Map App and implement your own custom solution.

come on. If I wrote something that annoyed you, let me know. But assume that I don't want to criticize but provide valuable suggestions even if I'm not yet a paying IMatch user.

In any case, take a look at Exif tag ID 0xa405 named "Focal Length In 35mm Format" or "FocalLengthIn35mmFilm"

JEITA CP-3451 writes: "This tag indicates the equivalent focal length assuming a 35mm film camera, in mm. A value of 0 means the focal length is unknown. Note that this tag differs from the FocalLength tag."

Not every camera writes this tag, e.g. my Canon DSLR do not. But the Sony RX100, Samsung Galaxy and Huawei Smartphones do write this tag.

Oliver

Mario

As I said above already, the focal length alone is not sufficient to calculate the field of view of your camera.
The sensor size relative to the standard 35mm format is also needed. Focal length comes from EXIF, sensor size is not available in EXIF.

Read this for more info: https://shuttermuse.com/calculate-field-of-view-camera-lens/

It just makes sense to collect and maintain this information in a central place, for easy updates and rollouts.
The Map App in IMatch is fully documented open source and you can modify in any way you see fit.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lbo

Quote from: Mario on October 02, 2018, 09:12:53 AM
As I said above already, the focal length alone is not sufficient to calculate the field of view of your camera.

that's correct, but 0xa405 "FocalLengthIn35mmFilm" is sufficient.

And thanks to your hint about the sources I found that IMatch even favours FocalLengthIn35mmFilm over 0x920a "FocalLength", see this snippet from maputility.js:


        let flen = focalLength35mm;
        if (flen == undefined) {
            flen = focalLength * cropFactor;
        }


This means, if FocalLengthIn35mmFilm is present in Exif data, IMatch doesn't use FocalLength * crop factor at all.

That's what I wanted to know in my original posting.

Oliver

Mario

Quotethat's correct, but 0xa405 "FocalLengthIn35mmFilm" is sufficient.

How do you calculate the field of view with just the focal length?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lbo

Quote from: Mario on October 02, 2018, 06:04:59 PM
Quotethat's correct, but 0xa405 "FocalLengthIn35mmFilm" is sufficient.

How do you calculate the field of view with just the focal length?

replace "focal length" by "35 mm equivalent focal length" to ask the correct question.

See https://en.wikipedia.org/wiki/35_mm_equivalent_focal_length

BTW: I'm not sure whether I understand the question correctly, since your code already uses FocalLengthIn35mmFilm, IMatch calculates finally:

(2 * Math.atan(36 / (2 * (parseFloat(file.focallength35mm))))) * 180.0 / Math.PI;

since olmap.js and gmap.js pass the result from "parseFloat(m.file.focallength35mm)" as third parameter to MapUtility.getFOV(), and MapUtility.getFOV() assigns this value to flen.

Oliver

P.S.: Sorry if I'm slow on the uptake. I didn't expect this discussion to get that long.

Mario

This formula requires the dimensions of the sensor in your camera, which is not in the EXIF.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lbo

Quote from: Mario on October 02, 2018, 06:59:22 PM
This formula requires the dimensions of the sensor in your camera, which is not in the EXIF.

this formula uses the width of a full format sensor, and this is not an individual but a known value (36mm).

After all, I didn't anything else but condensing your code. Here the original snippets:

maputility.js

    self.getFOV = function(cropFactor,focalLength,focalLength35mm = undefined) {

        let flen = focalLength35mm;
        if (flen == undefined) {
            flen = focalLength * cropFactor;
        }
       
        // Standard full-frame sensor => this sensor
        // 35mm camera has a sensor width of 36mm.
        // See: https://shuttermuse.com/calculate-field-of-view-camera-lens/
        return (2 * Math.atan(36 / (2 * flen))) * 180.0 / Math.PI;
    }


olmap.js:

                    if (file.focalLength || file.focallength35mm) {
                        let flen35 = undefined;
                        if (parseFloat(file.focallength35mm) > 0) {
                            flen35 = parseFloat(file.focallength35mm);
                        }
                        let fov = MapUtility.getFOV(cropFactor,file.focalLength,flen35);


gmap.js:

                    if (m.file.focalLength || m.file.focallength35mm) {
                        let flen35 = undefined;
                        if (parseFloat(m.file.focallength35mm) > 0) {
                            flen35 = parseFloat(m.file.focallength35mm);
                        }
                        let fov = MapUtility.getFOV(cropFactor,m.file.focalLength,flen35);


In addition, I attach a photo with hacked focal length values:
FocalLength=100mm on a Sony RX100 with crop factor 2,7 or so is very narrow,
FocalLengthIn35mmFilm=10mm is very wide.

If you look at the FOV display in IMatch, you will see that IMatch uses the wide angle FocalLengthIn35mmFilm value. The real FocalLength (100mm) is not used.

Oliver

lbo

For completeness, and an untampered (but size reduced) example of a RX100 image showing the relation between the two fields as set by the camera:

0x920a "Focal Length" is 25.7 mm
0xa405 "FocalLengthIn35mmFilm" is 70 mm (See https://en.wikipedia.org/wiki/35_mm_equivalent_focal_length)

As expected, 70 / 25.7 = 2.72 which is of course the crop factor of the sensor.

Oliver

Mario

Great.
Now you can purchase IMatch, make your own Map Panel version which uses your code and calculations and you no longer need the camera database (at least for this usage).
I will keep the camera database, because it works universally, even for files without 35mm equiv. data, old camera models etc. The camera database also stores other data which I plan to use in future apps and IMatch versions.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

jch2103

An observation: Not all cameras/manufacturers use useful tags like 0xa405 "FocalLengthIn35mmFilm". Consequently to cover all (or nearly all) cases, Mario had to set up the "camera database mumbo-jumbo".

John

lbo

Quote from: Mario on October 02, 2018, 08:05:38 PM
Now you can purchase IMatch, make your own Map Panel version which uses your code and calculations and you no longer need the camera database

I cited your code, plain copy/paste from IMatch distribution. No code changed/proposed by me.

I am not (and was never) against a camera database maintained by photools. I appreciate it.

lbo

Quote from: jch2103 on October 02, 2018, 08:49:46 PM
An observation: Not all cameras/manufacturers use useful tags like 0xa405 "FocalLengthIn35mmFilm"

Of course. That's why I wrote "Fallback" in the subject (I even provided examples for Cameras not providing it).

My main question was, whether IMatch uses FocalLengthIn35mmFilm if the crop factor is not known. I did not get an answer to this question.

By looking at the js code, I found that IMatch does not even "fall back" to FocalLengthIn35mmFilm, but prefer FocalLengthIn35mmFilm over FocalLength. This seems to be a good decision as far as I can estimate.

Oliver