further tweaks to the lensfun automatching logic
This commit is contained in:
parent
b2232f3843
commit
cbae5e0718
@ -30,9 +30,10 @@ extern const Settings *settings;
|
|||||||
// LFModifier
|
// LFModifier
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
LFModifier::LFModifier(lfModifier *m, bool swap_xy):
|
LFModifier::LFModifier(lfModifier *m, bool swap_xy, int flags):
|
||||||
data_(m),
|
data_(m),
|
||||||
swap_xy_(swap_xy)
|
swap_xy_(swap_xy),
|
||||||
|
flags_(flags)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,6 +87,31 @@ void LFModifier::processVignetteLine3Channels(int width, int y, float *line) con
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Glib::ustring LFModifier::getDisplayString() const
|
||||||
|
{
|
||||||
|
if (!data_) {
|
||||||
|
return "NONE";
|
||||||
|
} else {
|
||||||
|
Glib::ustring ret;
|
||||||
|
Glib::ustring sep = "";
|
||||||
|
if (flags_ & LF_MODIFY_DISTORTION) {
|
||||||
|
ret += "distortion";
|
||||||
|
sep = ", ";
|
||||||
|
}
|
||||||
|
if (flags_ & LF_MODIFY_VIGNETTING) {
|
||||||
|
ret += sep;
|
||||||
|
ret += "vignetting";
|
||||||
|
sep = ", ";
|
||||||
|
}
|
||||||
|
if (flags_ & LF_MODIFY_SCALE) {
|
||||||
|
ret += sep;
|
||||||
|
ret += "autoscaling";
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// LFCamera
|
// LFCamera
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -158,7 +184,7 @@ bool LFLens::ok() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Glib::ustring LFLens::getDisplayString() const
|
Glib::ustring LFLens::getLens() const
|
||||||
{
|
{
|
||||||
if (data_) {
|
if (data_) {
|
||||||
return Glib::ustring::compose("%1 %2", data_->Maker, data_->Model);
|
return Glib::ustring::compose("%1 %2", data_->Maker, data_->Model);
|
||||||
@ -251,12 +277,11 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c
|
|||||||
LFLens ret;
|
LFLens ret;
|
||||||
if (data_) {
|
if (data_) {
|
||||||
const char *lname = name.c_str();
|
const char *lname = name.c_str();
|
||||||
const lfCamera *cam = nullptr;
|
bool stdlens = camera.ok() && (name.empty() || name.find("Unknown ") == 0);
|
||||||
if (name.empty() || name.find("Unknown ") == 0) {
|
if (stdlens) {
|
||||||
lname = "Standard";
|
lname = "Standard";
|
||||||
cam = camera.data_;
|
|
||||||
}
|
}
|
||||||
auto found = data_->FindLenses(cam, nullptr, lname, LF_SEARCH_LOOSE);
|
auto found = data_->FindLenses(camera.data_, nullptr, lname, LF_SEARCH_LOOSE);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
// try to split the maker from the model of the lens
|
// try to split the maker from the model of the lens
|
||||||
Glib::ustring make, model;
|
Glib::ustring make, model;
|
||||||
@ -264,12 +289,14 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c
|
|||||||
if (i != Glib::ustring::npos) {
|
if (i != Glib::ustring::npos) {
|
||||||
make = name.substr(0, i);
|
make = name.substr(0, i);
|
||||||
model = name.substr(i+1);
|
model = name.substr(i+1);
|
||||||
found = data_->FindLenses(cam, make.c_str(), model.c_str(), LF_SEARCH_LOOSE);
|
found = data_->FindLenses(camera.data_, make.c_str(), model.c_str(), LF_SEARCH_LOOSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
ret.data_ = found[0];
|
ret.data_ = found[0];
|
||||||
lf_free(found);
|
lf_free(found);
|
||||||
|
} else if (camera.ok() && !stdlens) {
|
||||||
|
ret = findLens(LFCamera(), name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -281,11 +308,11 @@ LFModifier *LFDatabase::getModifier(const LFCamera &camera, const LFLens &lens,
|
|||||||
int width, int height, bool swap_xy) const
|
int width, int height, bool swap_xy) const
|
||||||
{
|
{
|
||||||
LFModifier *ret = nullptr;
|
LFModifier *ret = nullptr;
|
||||||
if (data_) {
|
if (data_ && focalLen > 0) {
|
||||||
if (camera.ok() && lens.ok()) {
|
if (camera.ok() && lens.ok()) {
|
||||||
lfModifier *mod = lfModifier::Create(lens.data_, camera.getCropFactor(), width, height);
|
lfModifier *mod = lfModifier::Create(lens.data_, camera.getCropFactor(), width, height);
|
||||||
mod->Initialize(lens.data_, LF_PF_F32, focalLen, aperture, focusDist > 0 ? focusDist : 1000, 0.0, LF_RECTILINEAR, LF_MODIFY_VIGNETTING | LF_MODIFY_DISTORTION, false);
|
int flags = mod->Initialize(lens.data_, LF_PF_F32, focalLen, aperture, focusDist > 0 ? focusDist : 1000, 0.0, LF_RECTILINEAR, LF_MODIFY_VIGNETTING | LF_MODIFY_DISTORTION | LF_MODIFY_SCALE, false);
|
||||||
ret = new LFModifier(mod, swap_xy);
|
ret = new LFModifier(mod, swap_xy, flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -323,7 +350,8 @@ LFModifier *LFDatabase::findModifier(const LensProfParams &lensProf, const Image
|
|||||||
std::cout << "LENSFUN:\n"
|
std::cout << "LENSFUN:\n"
|
||||||
<< " camera: " << c.getDisplayString() << "\n"
|
<< " camera: " << c.getDisplayString() << "\n"
|
||||||
<< " lens: " << l.getDisplayString() << "\n"
|
<< " lens: " << l.getDisplayString() << "\n"
|
||||||
<< " correction? " << (ret ? "yes" : "no") << std::endl;
|
<< " correction: "
|
||||||
|
<< (ret ? ret->getDisplayString() : "NONE") << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -39,15 +39,18 @@ public:
|
|||||||
void correctCA(double &x, double &y, int channel) const {}
|
void correctCA(double &x, double &y, int channel) const {}
|
||||||
void processVignetteLine(int width, int y, float *line) const;
|
void processVignetteLine(int width, int y, float *line) const;
|
||||||
void processVignetteLine3Channels(int width, int y, float *line) const;
|
void processVignetteLine3Channels(int width, int y, float *line) const;
|
||||||
|
|
||||||
|
Glib::ustring getDisplayString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit LFModifier(lfModifier *m, bool rotateXY);
|
explicit LFModifier(lfModifier *m, bool swap_xy, int flags);
|
||||||
LFModifier(const LFModifier &);
|
LFModifier(const LFModifier &);
|
||||||
LFModifier &operator=(const LFModifier &);
|
LFModifier &operator=(const LFModifier &);
|
||||||
|
|
||||||
friend class LFDatabase;
|
friend class LFDatabase;
|
||||||
lfModifier *data_;
|
lfModifier *data_;
|
||||||
bool swap_xy_;
|
bool swap_xy_;
|
||||||
|
int flags_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LFCamera {
|
class LFCamera {
|
||||||
@ -70,8 +73,8 @@ class LFLens {
|
|||||||
public:
|
public:
|
||||||
LFLens();
|
LFLens();
|
||||||
bool ok() const;
|
bool ok() const;
|
||||||
|
Glib::ustring getLens() const;
|
||||||
Glib::ustring getDisplayString() const;
|
Glib::ustring getDisplayString() const { return getLens(); }
|
||||||
private:
|
private:
|
||||||
friend class LFDatabase;
|
friend class LFDatabase;
|
||||||
const lfLens *data_;
|
const lfLens *data_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user