Page MenuHomePhabricator

Extract heading (=Direction of image) from EXIF/metadata and add it to location template
Closed, ResolvedPublic

Description

Extract heading (=Direction of image) from EXIF/metadata and add it to the location template: https://commons.wikimedia.org/wiki/Template:Location


Version: master
Severity: minor

Details

Reference
bz37925

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:26 AM
bzimport added a project: UploadWizard.
bzimport set Reference to bz37925.
bzimport added a subscriber: Unknown Object (MLST).
Raymond created this task.Jun 25 2012, 9:37 AM

Is there any chance somebody can make this happen? It sounds like a relatively easy thing to do and it would help to make things like GeoCommons (https://commons.wikimedia.org/wiki/Commons:GeoCommons) even more useful.

What's the exact EXIF field? Is its format standardizes? Where would it go in that template? It does sound straightforward to make, but the specifications should be clear.

*standardized

The relevant EXIF field seems to be Exif.GPSInfo.GPSImgDirection – it contains the heading in degrees, which could be directly plugged into the location template.

There is also Exif.GPSInfo.GPSImgDirectionRef which can contain either "T" for true north or "M" for magnetic north.

There are other similar fields, for example for the direction the camera was physically moving to, but that's not what we want (think about shooting sideways out of a moving car).

Note that the location template (https://commons.wikimedia.org/wiki/Template:Location) has two possible types of syntax: One for decimal degrees and one for degrees-minutes-seconds (DMS) kind of data – I'm not sure which one UW uses. Both of them have a parameter for additional attributes (parameter 3 for decimal degrees, parameter 9 for DMS) such as camera heading, region, etc. to be passed to GeoHack. This parameter can potentially hold multiple key-value pairs separated by underscores, but I think the only one that would be used by the UploadWizard would be the heading.

In real life, templates would look like this:
{{Location|34.02427|-116.15830|heading:180}} for decimal degrees
{{Location|34|1|27.37|N|116|9|29.88|W|heading:180}} for DMS

Note that there is a colon between the "heading" and the "180", not a "=".

Hope that helps?

Addendum: The template does not only accept the camera heading in degrees (0-359) but also letter combinations like SE for south-east. More specifically, it uses the abbreviations of the 32 cardinal points (https://en.wikipedia.org/wiki/Points_of_the_compass#32_cardinal_points). If we also want to make it possible to enter a heading by hand, it might be worth keeping that in mind.

MarkTraceur moved this task from Untriaged to Next up on the Multimedia board.Nov 26 2014, 5:35 PM

Change 176029 had a related patch set uploaded (by MarkTraceur):
Add heading field to UploadWizard

https://gerrit.wikimedia.org/r/176029

Patch-For-Review

Gilles moved this task from Next up to Ready for testing on the Multimedia board.Dec 1 2014, 4:34 PM

Change 176029 merged by jenkins-bot:
Add heading field to UploadWizard

https://gerrit.wikimedia.org/r/176029

Gilles moved this task from Ready for testing to Doing on the Multimedia board.Dec 1 2014, 5:18 PM
Gilles moved this task from Doing to Done on the Multimedia board.Dec 4 2014, 8:44 AM
Gilles closed this task as Resolved.Dec 4 2014, 8:47 AM
Gilles claimed this task.
SJu added a subscriber: SJu.Dec 4 2014, 9:16 PM
SJu added a comment.EditedDec 4 2014, 9:27 PM

My new Sony DSC-HX400V camera stores camera direction in Exif.GPSInfo.GPSTrack field instead in Exif.GPSInfo.GPSImgDirection field. Would UploadWizard be able to take this unstandardness of Sony cameras into account?

Gilles reopened this task as Open.Dec 5 2014, 8:06 AM
In T39925#819650, @SJu wrote:

My new Sony DSC-HX400V camera stores camera direction in Exif.GPSInfo.GPSTrack field instead in Exif.GPSInfo.GPSImgDirection field. Would UploadWizard be able to take this unstandardness of Sony cameras into account?

Sure thing, it's easy enough to add that other field. Could you please provide a sample photo that has it? It would make testing easier for us.

Gilles moved this task from Done to Ready for testing on the Multimedia board.Dec 5 2014, 8:07 AM
Gilles moved this task from Ready for testing to Next up on the Multimedia board.
Gilles removed a project: Patch-For-Review.
Gilles set Security to None.
SJu added a comment.Dec 5 2014, 2:37 PM
In T39925#819650, @SJu wrote:

My new Sony DSC-HX400V camera stores camera direction in Exif.GPSInfo.GPSTrack field instead in Exif.GPSInfo.GPSImgDirection field. Would UploadWizard be able to take this unstandardness of Sony cameras into account?

Sure thing, it's easy enough to add that other field. Could you please provide a sample photo that has it? It would make testing easier for us.

https://commons.wikimedia.org/wiki/File:Trojsk%C3%BD_most,_od_Troji_(2014-11-30).jpg - coordinates extracted by DschwenBot - discussed at https://commons.wikimedia.org/wiki/User_talk:Dschwen#Camera_direction_import_failed
https://commons.wikimedia.org/wiki/File:Trojsk%C3%BD_most,_od_Hole%C5%A1ovic_(2014-11-30).JPG - uploaded through UploadWizard

El_Grafo added a comment.EditedDec 5 2014, 3:42 PM
In T39925#819650, @SJu wrote:

My new Sony DSC-HX400V camera stores camera direction in Exif.GPSInfo.GPSTrack field instead in Exif.GPSInfo.GPSImgDirection field. Would UploadWizard be able to take this unstandardness of Sony cameras into account?

Sure thing, it's easy enough to add that other field. Could you please provide a sample photo that has it? It would make testing easier for us.

I'd be very careful about that.

According to exiv2.org, Exif.GPSInfo.GPSTrack is not for the camera heading but for for the direction the GPS sensor was moving. Note that with GPS alone, it's impossible to determine the actual camera heading, you'll need an electronic compass for that (the "GPS" in Exif.GPSInfo.GPSImgDirection is misleading). If your camera doesn't have an electronic compass (and as far as I can see the DSC-HX400V doesn't), direction of movement may be the next best thing, but it may be off 90° if you were shooting sideways out of a moving car or even 180° if you were walking backwards/away from the subject before taking the shot!

Even if you were walking up straight to the subject the heading may be off: If you stand still for a while to take the shot, the GPS unit is constantly re-evaluating its position and because of errors of measurement the recorded position will slightly change over time, which may mean that the heading between the last two recorded points has nothing to do with your actual (non-) movement (this depends on how the device determines the heading, e.g. some may notice that you are not actually moving and hence not record a heading at all).

I think it's better to have no heading at all than one that is likely to be wrong.

PS: found a better source for the meaning of the tags: official CIPA document
PPS: Thanks @Gilles btw for your work on this!

SJu added a comment.Dec 5 2014, 5:05 PM
In T39925#819650, @SJu wrote:

My new Sony DSC-HX400V camera stores camera direction in Exif.GPSInfo.GPSTrack field instead in Exif.GPSInfo.GPSImgDirection field. Would UploadWizard be able to take this unstandardness of Sony cameras into account?

Sure thing, it's easy enough to add that other field. Could you please provide a sample photo that has it? It would make testing easier for us.

I'd be very careful about that.
According to exiv2.org, Exif.GPSInfo.GPSTrack is not for the camera heading but for for the direction the GPS sensor was moving. Note that with GPS alone, it's impossible to determine the actual camera heading, you'll need an electronic compass for that (the "GPS" in Exif.GPSInfo.GPSImgDirection is misleading). If your camera doesn't have an electronic compass (and as far as I can see the DSC-HX400V doesn't), direction of movement may be the next best thing, but it may be off 90° if you were shooting sideways out of a moving car or even 180° if you were walking backwards/away from the subject before taking the shot!
Even if you were walking up straight to the subject the heading may be off: If you stand still for a while to take the shot, the GPS unit is constantly re-evaluating its position and because of errors of measurement the recorded position will slightly change over time, which may mean that the heading between the last two recorded points has nothing to do with your actual (non-) movement (this depends on how the device determines the heading, e.g. some may notice that you are not actually moving and hence not record a heading at all).
I think it's better to have no heading at all than one that is likely to be wrong.
PS: found a better source for the meaning of the tags: official CIPA document
PPS: Thanks @Gilles btw for your work on this!

Regrettably, you are right. The Sony DSC-HX400V camera really have not a compass and the value is not a camera orientation. I take my suggestion back.

Gilles added a comment.Dec 8 2014, 1:13 PM

Thanks for the valuable insight, @El_Grafo

Gilles closed this task as Resolved.Dec 8 2014, 1:14 PM
Gilles moved this task from Next up to Ready for testing on the Multimedia board.
Gilles moved this task from Ready for testing to Doing on the Multimedia board.
Gilles moved this task from Doing to Done on the Multimedia board.