add PARROT camera support to XMP
This commit is contained in:
50
TinyEXIF.cpp
50
TinyEXIF.cpp
@@ -998,33 +998,53 @@ int EXIFInfo::parseFromXMPSegment(const uint8_t* buf, unsigned len) {
|
||||
if (szProjectionType != NULL) {
|
||||
if (0 == _tcsicmp(szProjectionType, "perspective"))
|
||||
ProjectionType = 1;
|
||||
else if (0 == _tcsicmp(szProjectionType, "equirectangular") ||
|
||||
0 == _tcsicmp(szProjectionType, "spherical"))
|
||||
else
|
||||
if (0 == _tcsicmp(szProjectionType, "equirectangular") ||
|
||||
0 == _tcsicmp(szProjectionType, "spherical"))
|
||||
ProjectionType = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try parsing the XMP content for senseFly info.
|
||||
struct ParseXMP {
|
||||
static bool Value(const tinyxml2::XMLElement* document, const char* name, double& value) {
|
||||
if (document->QueryDoubleAttribute(name, &value) == tinyxml2::XML_SUCCESS)
|
||||
return true;
|
||||
const tinyxml2::XMLElement* const element(document->FirstChildElement(name));
|
||||
if (element != NULL && element->QueryDoubleText(&value) == tinyxml2::XML_SUCCESS)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if (0 == _tcsicmp(Make.c_str(), "senseFly")) {
|
||||
document->QueryDoubleAttribute("Camera:Roll", &GeoLocation.RollDegree);
|
||||
if (document->QueryDoubleAttribute("Camera:Pitch", &GeoLocation.PitchDegree) == tinyxml2::XML_SUCCESS) {
|
||||
ParseXMP::Value(document, "Camera:Roll", GeoLocation.RollDegree);
|
||||
if (ParseXMP::Value(document, "Camera:Pitch", GeoLocation.PitchDegree)) {
|
||||
// convert to DJI format: senseFly uses pitch 0 as NADIR, whereas DJI -90
|
||||
GeoLocation.PitchDegree = Tools::NormD180(GeoLocation.PitchDegree-90.0);
|
||||
}
|
||||
document->QueryDoubleAttribute("Camera:Yaw", &GeoLocation.YawDegree);
|
||||
document->QueryDoubleAttribute("Camera:GPSXYAccuracy", &GeoLocation.AccuracyXY);
|
||||
document->QueryDoubleAttribute("Camera:GPSZAccuracy", &GeoLocation.AccuracyZ);
|
||||
ParseXMP::Value(document, "Camera:Yaw", GeoLocation.YawDegree);
|
||||
ParseXMP::Value(document, "Camera:GPSXYAccuracy", GeoLocation.AccuracyXY);
|
||||
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)) {
|
||||
// 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:AboveGroundAltitude", GeoLocation.RelativeAltitude);
|
||||
} else {
|
||||
// Try parsing the XMP content for DJI info.
|
||||
document->QueryDoubleAttribute("drone-dji:AbsoluteAltitude", &GeoLocation.Altitude);
|
||||
document->QueryDoubleAttribute("drone-dji:RelativeAltitude", &GeoLocation.RelativeAltitude);
|
||||
document->QueryDoubleAttribute("drone-dji:GimbalRollDegree", &GeoLocation.RollDegree);
|
||||
document->QueryDoubleAttribute("drone-dji:GimbalPitchDegree", &GeoLocation.PitchDegree);
|
||||
document->QueryDoubleAttribute("drone-dji:GimbalYawDegree", &GeoLocation.YawDegree);
|
||||
document->QueryDoubleAttribute("drone-dji:CalibratedFocalLength", &Calibration.FocalLength);
|
||||
document->QueryDoubleAttribute("drone-dji:CalibratedOpticalCenterX", &Calibration.OpticalCenterX);
|
||||
document->QueryDoubleAttribute("drone-dji:CalibratedOpticalCenterY", &Calibration.OpticalCenterY);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user