Enhanced lens identification with Canon cameras, Issue 2228
This commit is contained in:
@@ -683,53 +683,54 @@ class CALensInterpreter : public IntLensInterpreter< int > {
|
|||||||
|
|
||||||
virtual std::string toString (Tag* t)
|
virtual std::string toString (Tag* t)
|
||||||
{
|
{
|
||||||
int lensID = t->toInt();
|
int lensID = t->toInt();
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
Tag *apertureTag = t->getParent()->getRoot()->findTag("MaxAperture");
|
Tag *apertureTag = t->getParent()->getRoot()->findTag("MaxAperture");
|
||||||
Tag *focalLengthTag = t->getParent()->getRoot()->findTag("FocalLength");
|
Tag *focalLengthTag = t->getParent()->getRoot()->findTag("FocalLength");
|
||||||
Tag *focalLengthMaxTag = t->getParent()->getRoot()->findTag("LongFocal");
|
Tag *focalLengthMaxTag = t->getParent()->getRoot()->findTag("LongFocal");
|
||||||
Tag *focalLengthMinTag = t->getParent()->getRoot()->findTag("ShortFocal");
|
Tag *focalLengthMinTag = t->getParent()->getRoot()->findTag("ShortFocal");
|
||||||
Tag *unitTag = t->getParent()->getRoot()->findTag("FocalUnits");
|
Tag *unitTag = t->getParent()->getRoot()->findTag("FocalUnits");
|
||||||
double maxApertureAtFocal = 0.;
|
double maxApertureAtFocal = 0.;
|
||||||
double focalLength = 0.;
|
double focalLength = 0.;
|
||||||
double focalLengthMin = 0.;
|
double focalLengthMin = 0.;
|
||||||
double focalLengthMax = 0.;
|
double focalLengthMax = 0.;
|
||||||
if( apertureTag )
|
if( apertureTag )
|
||||||
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 )
|
||||||
focalLengthMin = focalLengthMinTag->toDouble()/unit;
|
focalLengthMin = focalLengthMinTag->toDouble()/unit;
|
||||||
if( focalLengthMaxTag )
|
if( focalLengthMaxTag )
|
||||||
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.)
|
s << focalLengthMin;
|
||||||
s << focalLengthMin;
|
if (focalLengthMax > 0. && focalLengthMax != focalLengthMin)
|
||||||
if (focalLengthMax > 0. && focalLengthMax != focalLengthMin)
|
s << "-" << focalLengthMax;
|
||||||
s << "-" << focalLengthMax;
|
if (focalLengthMin > 0.)
|
||||||
if (focalLengthMin > 0.)
|
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 ){
|
||||||
|
Reference in New Issue
Block a user