35mm focal length on iPhone SE3 2nd generation over corrercted

Bug #2064625 reported by Alex Romosan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Hugin
Fix Committed
Undecided
Unassigned

Bug Description

This is for an iPhone SE 3rd generation. Looking at the exif data for a zoomed picture I can see:

Lens Specification |3.990000, 3.990000, 1.8, 1.8
Lens Make |Apple
Lens Model |iPhone SE (3rd generation) back camera 3.99mm f/1.8
Digital Zoom Ratio |1.951
Focal Length in 35mm|55

For a normal picture:

Focal Length in 35mm|28
Scene Capture Type |Standard
Lens Specification |3.990000, 3.990000, 1.8, 1.8
Lens Make |Apple
Lens Model |iPhone SE (3rd generation) back camera 3.99mm f/1.8

Turns out the reported focal length for a zoomed picture is already corrected for the digital zoom factor so src/hugin_base/panodata/SrcPanoImage.cpp:542 over corrects by multiplying again with the digital zoom factor ending up with an hFOV too small. I just commented out line 542 and now when I add the zoomed picture I get an hFOV of 34.9 (which is what I would expect) instead of 18.3 (wrong).

--- a/src/hugin_base/panodata/SrcPanoImage.cpp Wed May 01 19:41:11 2024 +0200
+++ b/src/hugin_base/panodata/SrcPanoImage.cpp Thu May 02 15:18:02 2024 +0200
@@ -539,7 +539,7 @@
     const float digitalZoom = Exiv2Helper::getExiv2ValueDouble(exifData, "Exif.Photo.DigitalZoomRatio");
     if (eFocalLength35 > 0 && digitalZoom > 1)
     {
- eFocalLength35 *= digitalZoom;
+ // eFocalLength35 *= digitalZoom;
     };
     float focalLength=0;
     //The various methods to detmine crop factor

Revision history for this message
tmodes (tmodes) wrote :

For images from other phones this line was needed. So I can't simply comment out this line.
Can you provide a sample image for testing? I don't know with which tool you checked the EXIF data.
Best would be an image without digital zoom and a other one with digital zoom.

Changed in hugin:
status: New → Incomplete
Revision history for this message
Alex Romosan (aromosan) wrote :

i'm attaching two, one with and one without zoom.i got the exif data on linux using exif

exif IMG_8093.JPG
EXIF tags in 'IMG_8093.JPG' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag |Value
--------------------+----------------------------------------------------------
Manufacturer |Apple
Model |iPhone SE (3rd generation)
Orientation |Right-top
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Software |17.4.1
Date and Time |2024:05:01 20:28:32
YCbCr Positioning |Centered
Compression |JPEG compression
X-Resolution |72
Y-Resolution |72
Resolution Unit |Inch
Exposure Time |1/40 sec.
F-Number |f/1.8
Exposure Program |Normal program
ISO Speed Ratings |400
Exif Version |Exif Version 2.32
Date and Time (Origi|2024:05:01 20:28:32
Date and Time (Digit|2024:05:01 20:28:32
Offset Time For Date|+02:00
Offset Time For Date|+02:00
Offset Time For Date|+02:00
Components Configura|Y Cb Cr -
Shutter Speed |5.33 EV (1/40 sec.)
Aperture |1.70 EV (f/1.8)
Brightness |0.98 EV (6.75 cd/m^2)
Exposure Bias |0.00 EV
Metering Mode |Pattern
Flash |Flash did not fire, compulsory flash mode
Focal Length |4.0 mm
Subject Area |Within rectangle (width 2216, height 1327) around (x,y) =
Maker Note |1680 bytes undefined data
Sub-second Time (Ori|467
Sub-second Time (Dig|467
FlashPixVersion |FlashPix Version 1.0
Color Space |Uncalibrated
Pixel X Dimension |4032
Pixel Y Dimension |3024
Sensing Method |One-chip color area sensor
Scene Type |Directly photographed
Exposure Mode |Auto exposure
White Balance |Auto white balance
Digital Zoom Ratio |1.951
Focal Length in 35mm|55
Scene Capture Type |Standard
Lens Specification |3.990000, 3.990000, 1.8, 1.8
Lens Make |Apple
Lens Model |iPhone SE (3rd generation) back camera 3.99mm f/1.8
Composite Image |2
North or South Latit|N
Latitude |48, 12, 43.95
East or West Longitu|E
Longitude |16, 22, 53.99
Altitude Reference |Sea level
Altitude |158.9586
GPS Time (Atomic Clo|18:28:32.00
Speed Unit |K
Speed of GPS Receive|0.033372
GPS Image Direction |T
GPS Image Direction |113.7853
Reference for Bearin|T
Bearing of Destinati|113.7853
GPS Date |2024:05:01
GPS Horizontal Posit|4.79103
--------------------+----------------------------------------------------------
EXIF data contains a thumbnail (6137 bytes).

Revision history for this message
tmodes (tmodes) wrote :

Okay, thanks for the test file. I found the report with the digital zoom ratio: https://bugs.launchpad.net/hugin/+bug/2000019
Here the digital zoom ratio is required for a correct fov.

The problem is that Apple does not follow the EXIF standard.
The EXIF standard says under FocalLengthIn35mmFilm:
- Digital zoom ratio is not taken into account.
But Apple takes the digital zoom ratio into account and write also the digital zoom ratio.

So not sure how to work around this violation of the standard. Best would be if Apple would follow the standard, but I have no hope that this will happen.

Revision history for this message
Alex Romosan (aromosan) wrote :

I guess if the manufacturer is Apple then don't correct (at least if the model is iPhone SE (3rd generation)). I'm trying to get data from non Apple phones to understand how the 35mm focal length equivalent is reported.

Revision history for this message
Alex Romosan (aromosan) wrote :

I just noticed there are two fields "Focal Length" and "Focal Length in 35mm" Looking at the values for the respective pictures:

non zoomed:

Focal Length |4.0 mm
Focal Length in 35mm|28
Lens Specification |3.990000, 3.990000, 1.8, 1.8

zoomed:

Focal Length |4.0 mm
Digital Zoom Ratio |1.951
Focal Length in 35mm|55
Lens Specification |3.990000, 3.990000, 1.8, 1.8

so the Focal Length stays the same but the Focal Length in 35mm changes (already corrected by the Digital Zoom factor). Is it safe to assume the Focal Length in 35mm already incorporates the digital zoom factor correction? I'll try to get data from a non Apple phone and let you know.

Revision history for this message
tmodes (tmodes) wrote :

> Is it safe to assume the Focal Length in 35mm already incorporates the digital zoom factor correction?

No, as already written the EXIF standard says clearly: Digital zoom ratio is not taken into account.

Just your examples and the files in the mentioned other bug report (Samsung phone):
exiftool -make -model -focallength* -digitalzoom* -e -ext jpg .
======== ./IMG_7964.JPG (non zoomed)
Make : Apple
Camera Model Name : iPhone SE (3rd generation)
Focal Length : 4.0 mm
Focal Length In 35mm Format : 28 mm

======== ./IMG_8093.JPG (zoomed)
Make : Apple
Camera Model Name : iPhone SE (3rd generation)
Focal Length : 4.0 mm
Focal Length In 35mm Format : 55 mm
Digital Zoom Ratio : 1.950967742

======== ./PXL_20221219_230755050.jpg (non zoomed)
Make : samsung
Camera Model Name : SM-A528B (a52sxq)
Focal Length : 5.2 mm
Focal Length In 35mm Format : 39 mm
Digital Zoom Ratio : 0

======== ./PXL_20221219_230800590.jpg (zoomed)
Make : samsung
Camera Model Name : SM-A528B (a52sxq)
Focal Length : 5.2 mm
Focal Length In 35mm Format : 39 mm
Digital Zoom Ratio : 2.55

So the Samsung test images matches the EXIF standard, but the Apple iPhone images don't follow the standard. And I don't know which models are affected and which one not. This would mean to maintain a list of phones which don't follow the standard (and this may change with each software update).

Revision history for this message
Alex Romosan (aromosan) wrote (last edit ):

so it turns out google's pixel 6a follows the standard but the 7 doesn't (correction: the different focal length is probably because of the optical zoom so Pixel 7 follows the standard as well)
non zoomed:

Manufacturer |Google
Model |Pixel 7
Focal Length |6.8 mm
Digital Zoom Ratio | 0
Focal Length in 35mm|24

zoomed:

Manufacturer |Google
Model |Pixel 7
Focal Length |6.8 mm
Digital Zoom Ratio |4.00
Focal Length in 35mm|48

for Pixel 6a non zoomed:

Manufacturer |Google
Model |Pixel 6a
Focal Length |4.4 mm
Digital Zoom Ratio | 0
Focal Length in 35mm|27

zoomed:

Manufacturer |Google
Model |Pixel 6a
Focal Length |4.4 mm
Digital Zoom Ratio |7.00
Focal Length in 35mm|27

so there you go...

Revision history for this message
Alex Romosan (aromosan) wrote :

for an iPhone 8

zoomed:

Make : Apple
Camera Model Name : iPhone 8
Focal Length : 4.0 mm
Focal Length In 35mm Format : 141 mm
Digital Zoom Ratio : 5.006622517

non zoomed:

Make : Apple
Camera Model Name : iPhone 8
Focal Length : 4.0 mm
Focal Length In 35mm Format : 28 mm

for iPhone6

zoomed:

Make : Apple
Camera Model Name : iPhone 6
Focal Length : 4.2 mm
Focal Length In 35mm Format : 145 mm
Digital Zoom Ratio : 4.995918367

non zoomed

Make : Apple
Camera Model Name : iPhone 6
Focal Length : 4.2 mm
Focal Length In 35mm Format : 29 mm

iphoneSE 3rd generation:

zoomed:

Make : Apple
Camera Model Name : iPhone SE (3rd generation)
Focal Length : 4.0 mm
Focal Length In 35mm Format : 55 mm
Digital Zoom Ratio : 1.950967742

non zoomed:

Make : Apple
Camera Model Name : iPhone SE (3rd generation)
Focal Length : 4.0 mm
Focal Length In 35mm Format : 28 mm

I'm getting data for two more iPhone models tomorrow and all add to this.

Revision history for this message
Alex Romosan (aromosan) wrote :

Two more data points

======== IMG_9839.jpg (unzoomed)
Make : Apple
Camera Model Name : iPhone 11 Pro Max
Focal Length : 4.2 mm
Focal Length In 35mm Format : 26 mm
======== IMG_9840.jpg (zoomed)
Make : Apple
Camera Model Name : iPhone 11 Pro Max
Focal Length : 6.0 mm
Focal Length In 35mm Format : 95 mm
Digital Zoom Ratio : 1.841656516
======== image0.jpg (zoomed)
Make : Apple
Camera Model Name : iPhone 14 Pro Max
Focal Length : 9.0 mm
Focal Length In 35mm Format : 404 mm
Digital Zoom Ratio : 5.23183391
======== image1.jpg (unzoomed)
Make : Apple
Camera Model Name : iPhone 14 Pro Max
Focal Length : 6.9 mm
Focal Length In 35mm Format : 24 mm

so it looks like Apple reports the 35mm focal length equivalent with the digital zoom already included.

i looked at the EXIF standard:

4.6.6.7.38. DigitalZoomRatio
This tag indicates the digital zoom ratio when the image was shot. If the numerator of the recorded value is
0, this indicates that digital zoom was not used.
     Tag = 41988 (A404.H)
     Type = RATIONAL
     Count = 1
     Default = None
4.6.6.7.39. FocalLengthIn35mmFilm
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.
     Tag = 41989 (A405.H)
     Type = SHORT
     Count = 1
     Default = None

but it doesn't say anything about the digital zoom factor. it is true that in Annex E. [Informative] Guidelines for Implementing Tag Information it says:

E.2.10 FocalLengthln35mmFilm
Tag Information
This tag indicates the equivalent focal length assuming a 35mm film camera.
[Exif/DCF writer]
    ・Digital zoom ratio is not taken into account.
[Exif/DCF reader]
    ・An Exif/DCF reader can use this value along with subject distance to estimate the magnification.

but that's just a guideline not the standard.

Basically, Apple's 35mm focal length equivalent incorporates the digital zoom factor while Google's doesn't. Which one is correct is a matter of interpretation.

So I would suggest a check for manufacturer when applying the digital zoom correction to the 35mm focal length equivalent and skip it if Apple.

Revision history for this message
tmodes (tmodes) wrote :

Sorry, but you are only repeating the same sentence I cited already twice. No need to repeat it again.

All other manufactures (Goggle, Samsung, all camera makers) are following the guidelines in the EXIF standard. Only Apple has to do its own way. So we have to add special code to handle this special case. Sorry, but IHMO this is not a "matter of interpretation".

The default branch contains now this special code.

Changed in hugin:
status: Incomplete → Fix Committed
Revision history for this message
Alex Romosan (aromosan) wrote :

Thank you.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.