From 2df26028b8c696f4c41496810317ce816cedf839 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Sat, 21 May 2022 15:11:00 -0700 Subject: [PATCH] Fix auto perspective correction not working Use default focal length and/or crop factor if undefined. Closes #6487. --- rtgui/toolpanelcoord.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 2c506710f..9099f5620 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -1022,6 +1022,16 @@ void ToolPanelCoordinator::autoPerspRequested (bool corr_pitch, bool corr_yaw, d rtengine::procparams::ProcParams params; ipc->getParams(¶ms); + // If focal length or crop factor are undetermined, use the defaults. + if (params.perspective.camera_focal_length <= 0) { + params.perspective.camera_focal_length = + PerspectiveParams::DEFAULT_CAMERA_FOCAL_LENGTH; + } + if (params.perspective.camera_crop_factor <= 0) { + params.perspective.camera_crop_factor = + PerspectiveParams::DEFAULT_CAMERA_CROP_FACTOR; + } + auto res = rtengine::PerspectiveCorrection::autocompute(src, corr_pitch, corr_yaw, ¶ms, src->getMetaData(), lines); rot = res.angle; pitch = res.pitch;