From ac39905f11d4f11846ce3aad83c3b42eb6ad1dd6 Mon Sep 17 00:00:00 2001 From: cDc Date: Mon, 24 Sep 2018 12:33:57 +0300 Subject: [PATCH] add maker check for DJI too --- TinyEXIF.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/TinyEXIF.cpp b/TinyEXIF.cpp index 6d6cc31..25a1d7e 100644 --- a/TinyEXIF.cpp +++ b/TinyEXIF.cpp @@ -1006,7 +1006,7 @@ int EXIFInfo::parseFromXMPSegment(const uint8_t* buf, unsigned len) { } } - // Try parsing the XMP content for senseFly info. + // Try parsing the XMP content for supported maker's info. struct ParseXMP { static bool Value(const tinyxml2::XMLElement* document, const char* name, double& value) { if (document->QueryDoubleAttribute(name, &value) == tinyxml2::XML_SUCCESS) @@ -1017,6 +1017,16 @@ int EXIFInfo::parseFromXMPSegment(const uint8_t* buf, unsigned len) { return false; } }; + if (0 == _tcsicmp(Make.c_str(), "DJI")) { + ParseXMP::Value(document, "drone-dji:AbsoluteAltitude", GeoLocation.Altitude); + ParseXMP::Value(document, "drone-dji:RelativeAltitude", GeoLocation.RelativeAltitude); + ParseXMP::Value(document, "drone-dji:GimbalRollDegree", GeoLocation.RollDegree); + ParseXMP::Value(document, "drone-dji:GimbalPitchDegree", GeoLocation.PitchDegree); + ParseXMP::Value(document, "drone-dji:GimbalYawDegree", GeoLocation.YawDegree); + ParseXMP::Value(document, "drone-dji:CalibratedFocalLength", Calibration.FocalLength); + ParseXMP::Value(document, "drone-dji:CalibratedOpticalCenterX", Calibration.OpticalCenterX); + ParseXMP::Value(document, "drone-dji:CalibratedOpticalCenterY", Calibration.OpticalCenterY); + } else if (0 == _tcsicmp(Make.c_str(), "senseFly")) { ParseXMP::Value(document, "Camera:Roll", GeoLocation.RollDegree); if (ParseXMP::Value(document, "Camera:Pitch", GeoLocation.PitchDegree)) { @@ -1028,23 +1038,16 @@ int EXIFInfo::parseFromXMPSegment(const uint8_t* buf, unsigned len) { ParseXMP::Value(document, "Camera:GPSZAccuracy", GeoLocation.AccuracyZ); } else if (0 == _tcsicmp(Make.c_str(), "PARROT")) { - ParseXMP::Value(document, "Camera:Roll", GeoLocation.RollDegree); - if (ParseXMP::Value(document, "Camera:Pitch", GeoLocation.PitchDegree)) { + ParseXMP::Value(document, "Camera:Roll", GeoLocation.RollDegree) || + ParseXMP::Value(document, "drone-parrot:CameraRollDegree", GeoLocation.RollDegree); + if (ParseXMP::Value(document, "Camera:Pitch", GeoLocation.PitchDegree) || + ParseXMP::Value(document, "drone-parrot:CameraPitchDegree", GeoLocation.PitchDegree)) { // convert to DJI format: senseFly uses pitch 0 as NADIR, whereas DJI -90 GeoLocation.PitchDegree = Tools::NormD180(GeoLocation.PitchDegree-90.0); } - ParseXMP::Value(document, "Camera:Yaw", GeoLocation.YawDegree); + ParseXMP::Value(document, "Camera:Yaw", GeoLocation.YawDegree) || + ParseXMP::Value(document, "drone-parrot:CameraYawDegree", GeoLocation.YawDegree); ParseXMP::Value(document, "Camera:AboveGroundAltitude", GeoLocation.RelativeAltitude); - } else { - // Try parsing the XMP content for DJI info. - ParseXMP::Value(document, "drone-dji:AbsoluteAltitude", GeoLocation.Altitude); - ParseXMP::Value(document, "drone-dji:RelativeAltitude", GeoLocation.RelativeAltitude); - ParseXMP::Value(document, "drone-dji:GimbalRollDegree", GeoLocation.RollDegree); - ParseXMP::Value(document, "drone-dji:GimbalPitchDegree", GeoLocation.PitchDegree); - ParseXMP::Value(document, "drone-dji:GimbalYawDegree", GeoLocation.YawDegree); - ParseXMP::Value(document, "drone-dji:CalibratedFocalLength", Calibration.FocalLength); - ParseXMP::Value(document, "drone-dji:CalibratedOpticalCenterX", Calibration.OpticalCenterX); - ParseXMP::Value(document, "drone-dji:CalibratedOpticalCenterY", Calibration.OpticalCenterY); } return PARSE_SUCCESS;