-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No vignette correction available for NIKON D5600 + AF-S DX Nikkor 35mm f/1.8G but it appears in lensfundb #6989
Comments
Confirmed. There is some suspicious usage, or rather non-usage, of the camera specifications when searching for a matching lens profile. |
Thanks for looking into it |
I did some testing with the code and managed to fix the problem. I need to clean the patch up and also understand why the camera details weren't used to look up the lens. It looks intentional, but the rationale is not clear. Patchdiff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc
index fc5bb0017..5bf154592 100644
--- a/rtengine/rtlensfun.cc
+++ b/rtengine/rtlensfun.cc
@@ -460,20 +460,38 @@ LFCamera LFDatabase::findCamera(const Glib::ustring &make, const Glib::ustring &
}
-LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) const
+LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name, bool autoMatch) const
{
LFLens ret;
if (data_ && !name.empty()) {
MyMutex::MyLock lock(lfDBMutex);
- if (!camera.data_) {
+ if (!autoMatch) {
// Only the lens name provided. Try to find exact match by name.
LFLens candidate;
+ LFLens bestCandidate;
+ const auto isCStringIn = [](const char *str, const char *const *list) {
+ for (auto element = list[0]; element[0]; element++) {
+ if (!strcmp(str, element)) {
+ return true;
+ }
+ }
+ return false;
+ };
for (auto lens_list = data_->GetLenses(); lens_list[0]; lens_list++) {
candidate.data_ = lens_list[0];
- if (name == candidate.getLens()) {
- return candidate;
+ if ((!bestCandidate.data_ ||
+ (bestCandidate.data_->CropFactor > camera.data_->CropFactor
+ ? bestCandidate.data_->CropFactor > candidate.data_->CropFactor
+ : candidate.data_->CropFactor <= camera.data_->CropFactor &&
+ bestCandidate.data_->CropFactor < candidate.data_->CropFactor)) &&
+ name == candidate.getLens() &&
+ isCStringIn(camera.data_->Mount, candidate.data_->Mounts)) {
+ bestCandidate.data_ = candidate.data_;
}
}
+ if (bestCandidate.data_) {
+ return bestCandidate;
+ }
}
auto found = data_->FindLenses(camera.data_, nullptr, name.c_str());
for (size_t pos = 0; !found && pos < name.size(); ) {
@@ -562,12 +580,7 @@ std::unique_ptr<LFModifier> LFDatabase::findModifier(
}
const LFCamera c = findCamera(make, model, lensProf.lfAutoMatch());
- const LFLens l = findLens(
- lensProf.lfAutoMatch()
- ? c
- : LFCamera(),
- lens
- );
+ const LFLens l = findLens(c, lens, lensProf.lfAutoMatch());
bool swap_xy = false;
if (rawRotationDeg >= 0) {
diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h
index bcce77f34..1d941246f 100644
--- a/rtengine/rtlensfun.h
+++ b/rtengine/rtlensfun.h
@@ -121,7 +121,7 @@ public:
std::vector<LFCamera> getCameras() const;
std::vector<LFLens> getLenses() const;
LFCamera findCamera(const Glib::ustring &make, const Glib::ustring &model, bool autoMatch) const;
- LFLens findLens(const LFCamera &camera, const Glib::ustring &name) const;
+ LFLens findLens(const LFCamera &camera, const Glib::ustring &name, bool autoMatch) const;
std::unique_ptr<LFModifier> findModifier(
const procparams::LensProfParams &lensProf,
diff --git a/rtgui/lensprofile.cc b/rtgui/lensprofile.cc
index 0e17b3f40..5f42a1cde 100644
--- a/rtgui/lensprofile.cc
+++ b/rtgui/lensprofile.cc
@@ -251,7 +251,7 @@ void LensProfilePanel::read(const rtengine::procparams::ProcParams* pp, const Pa
if (pp->lensProf.lfAutoMatch()) {
if (metadata) {
- const LFLens l = db->findLens(c, metadata->getLens());
+ const LFLens l = db->findLens(c, metadata->getLens(), true);
setLensfunLens(l.getLens());
}
} else if (pp->lensProf.lfManual()) {
@@ -522,7 +522,7 @@ void LensProfilePanel::onCorrModeChanged(const Gtk::RadioButton* rbChanged)
} else if (metadata) {
const LFDatabase* const db = LFDatabase::getInstance();
const LFCamera c = db->findCamera(metadata->getMake(), metadata->getModel(), true);
- const LFLens l = db->findLens(c, metadata->getLens());
+ const LFLens l = db->findLens(c, metadata->getLens(), true);
setLensfunCamera(c.getMake(), c.getModel());
setLensfunLens(l.getLens());
}
@@ -808,7 +808,7 @@ void LensProfilePanel::updateLensfunWarning()
return;
}
- const LFLens l = db->findLens(LFCamera(), (*itl)[lf->lensfunModelLens.lens]);
+ const LFLens l = db->findLens(c, (*itl)[lf->lensfunModelLens.lens], false);
const float lenscrop = l.getCropFactor();
const float camcrop = c.getCropFactor(); |
hi, I don't have that much experience with rawtherapee development, should I apply this to head or can I apply this over v5.10? is there any kind of nightly build available? regards |
The patch is intended to be a progress report and solicit feedback from other developers who are interested. If you want to try it, I created the patch on top of the dev branch. However, it might also work on v5.10. There's no automated build available until I create a pull request. |
Vignetting correction checkbox is greyed/disabled out for this camera/lens combination although I see it available in my lensfun db:
NIKON D5600 + AF-S DX Nikkor 35mm f/1.8G
I believe somehow rawtherapee or lensfun is getting confused and picking up the second record, the one taken with a FX camera that lacks vignetting data.
about/version:
To reproduce, open attached NEF file, in neutral profile, go to Transform -> Lens/Geometry -> Profiled lens correction -> Automatically selected (Vignetting is disabled).
Attached files available under Public Domain.
files at (could not upload it here, maybe by filesize?): http://oss.verlet.org/pub/20240313-rtbugnovignette35mm.tgz
The text was updated successfully, but these errors were encountered: