Enhanced lens identification with Canon cameras, Issue 2228

This commit is contained in:
Ingo
2014-02-07 19:53:19 +01:00
parent a06d005699
commit d1932651e5

View File

@@ -687,7 +687,7 @@ class CALensInterpreter : public IntLensInterpreter< int > {
it_t r; it_t r;
size_t nFound = choices.count( lensID ); size_t nFound = choices.count( lensID );
if( 1== nFound ) { if(1 == nFound) {
r = choices.find ( lensID ); r = choices.find ( lensID );
return r->second; return r->second;
} }
@@ -705,7 +705,8 @@ class CALensInterpreter : public IntLensInterpreter< int > {
maxApertureAtFocal = pow(2.0, apertureTag->toDouble()/64.0); maxApertureAtFocal = pow(2.0, apertureTag->toDouble()/64.0);
if( unitTag ){ if( unitTag ){
double unit = unitTag->toDouble(); double unit = unitTag->toDouble();
if( unit==0. ) unit=1; if( unit==0. )
unit=1;
if( focalLengthTag ) if( focalLengthTag )
focalLength = focalLengthTag->toDouble(); focalLength = focalLengthTag->toDouble();
if( focalLengthMinTag ) if( focalLengthMinTag )
@@ -714,7 +715,6 @@ class CALensInterpreter : public IntLensInterpreter< int > {
focalLengthMax = focalLengthMaxTag->toDouble()/unit; focalLengthMax = focalLengthMaxTag->toDouble()/unit;
} }
if (0 == nFound) {
std::ostringstream s; std::ostringstream s;
s << "Unknown "; s << "Unknown ";
if (focalLengthMin > 0.) if (focalLengthMin > 0.)
@@ -725,11 +725,12 @@ class CALensInterpreter : public IntLensInterpreter< int > {
s << "mm"; s << "mm";
s << " (" << lensID << ")"; s << " (" << lensID << ")";
if (0 == nFound) {
return s.str(); return s.str();
} }
double deltaMin = 1000.; double deltaMin = 1000.;
std::string bestMatch("Unknown"); std::string bestMatch(s.str());
std::ostringstream candidates; std::ostringstream candidates;
for (r = choices.lower_bound(lensID); r != choices.upper_bound(lensID); r++) { for (r = choices.lower_bound(lensID); r != choices.upper_bound(lensID); r++) {
double a1,a2,f1,f2,lensAperture,dif; double a1,a2,f1,f2,lensAperture,dif;
@@ -755,7 +756,7 @@ class CALensInterpreter : public IntLensInterpreter< int > {
lensAperture = exp( log(a1)+(log(a2)-log(a1))/(log(f2)-log(f1))*(log(focalLength)-log(f1)) ); lensAperture = exp( log(a1)+(log(a2)-log(a1))/(log(f2)-log(f1))*(log(focalLength)-log(f1)) );
dif = abs(lensAperture - maxApertureAtFocal); dif = abs(lensAperture - maxApertureAtFocal);
}else } else
dif = 0; dif = 0;
if( dif < deltaMin ){ if( dif < deltaMin ){