Add auto perspective correction to GUI

Add three buttons for correcting pitch, yaw, or both. Horizontal and/or
vertical tilt adjusters are updated with the automatically computed
values.
This commit is contained in:
Lawrence
2020-01-18 14:32:03 -08:00
parent 6ab92eb1f5
commit 72dfa1b242
6 changed files with 207 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
#include "../rtengine/dfmanager.h"
#include "../rtengine/ffmanager.h"
#include "../rtengine/improcfun.h"
#include "../rtengine/perspectivecorrection.h"
#include "../rtengine/procevents.h"
#include "../rtengine/refreshmap.h"
@@ -258,6 +259,7 @@ ToolPanelCoordinator::ToolPanelCoordinator (bool batch) : ipc (nullptr), favorit
flatfield->setFFProvider (this);
lensgeom->setLensGeomListener (this);
rotate->setLensGeomListener (this);
perspective->setLensGeomListener (this);
distortion->setLensGeomListener (this);
crop->setCropPanelListener (this);
icm->setICMPanelListener (this);
@@ -844,6 +846,26 @@ void ToolPanelCoordinator::straightenRequested ()
toolBar->setTool (TMStraighten);
}
void ToolPanelCoordinator::autoPerspRequested (bool corr_pitch, bool corr_yaw, double& rot, double& pitch, double& yaw)
{
if (!(ipc && (corr_pitch || corr_yaw))) {
return;
}
rtengine::ImageSource *src = dynamic_cast<rtengine::ImageSource *>(ipc->getInitialImage());
if (!src) {
return;
}
rtengine::procparams::ProcParams params;
ipc->getParams(&params);
auto res = rtengine::PerspectiveCorrection::autocompute(src, corr_pitch, corr_yaw, &params, src->getMetaData());
rot = res.angle;
pitch = res.pitch;
yaw = res.yaw;
}
double ToolPanelCoordinator::autoDistorRequested ()
{
if (!ipc) {