Add rotation to camera-based perspective tool

This rotation is different from the Rotate tool and the post-correction
adjustment rotation because it is applied between camera shift and
camera angle. It is equivalent to correcting the camera's roll and is
the same as the rotation calculated by automatic perspective correction.
This commit is contained in:
Lawrence
2020-01-18 17:13:24 -08:00
parent 025d11bb22
commit 7395b26db4
10 changed files with 61 additions and 21 deletions

View File

@@ -340,6 +340,7 @@ void ParamsEdited::set(bool v)
perspective.camera_crop_factor = v;
perspective.camera_focal_length = v;
perspective.camera_pitch = v;
perspective.camera_roll = v;
perspective.camera_shift_horiz = v;
perspective.camera_shift_vert = v;
perspective.camera_yaw = v;
@@ -936,6 +937,7 @@ void ParamsEdited::initFrom(const std::vector<rtengine::procparams::ProcParams>&
perspective.camera_crop_factor = perspective.camera_crop_factor && p.perspective.camera_crop_factor == other.perspective.camera_crop_factor;
perspective.camera_focal_length = perspective.camera_focal_length && p.perspective.camera_focal_length == other.perspective.camera_focal_length;
perspective.camera_pitch = perspective.camera_pitch && p.perspective.camera_pitch == other.perspective.camera_pitch;
perspective.camera_roll = perspective.camera_roll && p.perspective.camera_roll == other.perspective.camera_roll;
perspective.camera_shift_horiz = perspective.camera_shift_horiz && p.perspective.camera_shift_horiz == other.perspective.camera_shift_horiz;
perspective.camera_shift_vert = perspective.camera_shift_vert && p.perspective.camera_shift_vert == other.perspective.camera_shift_vert;
perspective.projection_pitch = perspective.projection_pitch && p.perspective.projection_pitch == other.perspective.projection_pitch;
@@ -2359,6 +2361,10 @@ void ParamsEdited::combine(rtengine::procparams::ProcParams& toEdit, const rteng
toEdit.perspective.camera_pitch = dontforceSet && options.baBehav[ADDSET_PERSP_CAM_ANGLE] ? toEdit.perspective.camera_pitch + mods.perspective.camera_pitch : mods.perspective.camera_pitch;
}
if (perspective.camera_roll) {
toEdit.perspective.camera_roll = dontforceSet && options.baBehav[ADDSET_PERSP_CAM_ANGLE] ? toEdit.perspective.camera_roll + mods.perspective.camera_roll : mods.perspective.camera_roll;
}
if (perspective.camera_shift_horiz) {
toEdit.perspective.camera_shift_horiz = dontforceSet && options.baBehav[ADDSET_PERSP_CAM_SHIFT] ? toEdit.perspective.camera_shift_horiz + mods.perspective.camera_shift_horiz : mods.perspective.camera_shift_horiz;
}

View File

@@ -400,6 +400,7 @@ struct PerspectiveParamsEdited {
bool camera_crop_factor;
bool camera_focal_length;
bool camera_pitch;
bool camera_roll;
bool camera_shift_horiz;
bool camera_shift_vert;
bool camera_yaw;

View File

@@ -87,6 +87,9 @@ PerspCorrection::PerspCorrection () : FoldableToolPanel(this, "perspective", M("
camera_shift_vert = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_CAMERA_SHIFT_VERTICAL"), -100, 100, 0.01, 0));
camera_shift_vert->setAdjusterListener (this);
camera_roll = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_CAMERA_ROLL"), -45, 45, 0.01, 0));
camera_roll->setAdjusterListener (this);
camera_pitch = Gtk::manage (new Adjuster (M("TP_PERSPECTIVE_CAMERA_PITCH"),
-85, 85, 0.1, 0, ipers_cam_pitch_left, ipers_cam_pitch_right));
camera_pitch->setAdjusterListener (this);
@@ -152,6 +155,7 @@ PerspCorrection::PerspCorrection () : FoldableToolPanel(this, "perspective", M("
camera_vbox->pack_start (*camera_crop_factor);
camera_vbox->pack_start (*camera_shift_horiz);
camera_vbox->pack_start (*camera_shift_vert);
camera_vbox->pack_start (*camera_roll);
camera_vbox->pack_start (*camera_pitch);
camera_vbox->pack_start (*camera_yaw);
camera_vbox->pack_start (*auto_hbox);
@@ -195,6 +199,7 @@ void PerspCorrection::read (const ProcParams* pp, const ParamsEdited* pedited)
camera_crop_factor->setEditedState (pedited->perspective.camera_crop_factor ? Edited : UnEdited);
camera_focal_length->setEditedState (pedited->perspective.camera_focal_length ? Edited : UnEdited);
camera_pitch->setEditedState (pedited->perspective.camera_pitch ? Edited : UnEdited);
camera_roll->setEditedState (pedited->perspective.camera_roll ? Edited : UnEdited);
camera_shift_horiz->setEditedState (pedited->perspective.camera_shift_horiz ? Edited : UnEdited);
camera_shift_vert->setEditedState (pedited->perspective.camera_shift_vert ? Edited : UnEdited);
camera_yaw->setEditedState (pedited->perspective.camera_yaw ? Edited : UnEdited);
@@ -211,6 +216,7 @@ void PerspCorrection::read (const ProcParams* pp, const ParamsEdited* pedited)
camera_crop_factor->setValue (pp->perspective.camera_crop_factor);
camera_focal_length->setValue (pp->perspective.camera_focal_length);
camera_pitch->setValue (pp->perspective.camera_pitch);
camera_roll->setValue (pp->perspective.camera_roll);
camera_shift_horiz->setValue (pp->perspective.camera_shift_horiz);
camera_shift_vert->setValue (pp->perspective.camera_shift_vert);
camera_yaw->setValue (pp->perspective.camera_yaw);
@@ -240,6 +246,7 @@ void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited)
pp->perspective.camera_crop_factor= camera_crop_factor->getValue ();
pp->perspective.camera_focal_length = camera_focal_length->getValue ();
pp->perspective.camera_pitch = camera_pitch->getValue ();
pp->perspective.camera_roll = camera_roll->getValue ();
pp->perspective.camera_shift_horiz = camera_shift_horiz->getValue ();
pp->perspective.camera_shift_vert = camera_shift_vert->getValue ();
pp->perspective.camera_yaw = camera_yaw->getValue ();
@@ -263,6 +270,7 @@ void PerspCorrection::write (ProcParams* pp, ParamsEdited* pedited)
pedited->perspective.camera_crop_factor= camera_crop_factor->getEditedState ();
pedited->perspective.camera_focal_length = camera_focal_length->getEditedState ();
pedited->perspective.camera_pitch = camera_pitch->getEditedState();
pedited->perspective.camera_roll = camera_roll->getEditedState();
pedited->perspective.camera_shift_horiz = camera_shift_horiz->getEditedState();
pedited->perspective.camera_shift_vert = camera_shift_vert->getEditedState();
pedited->perspective.camera_yaw = camera_yaw->getEditedState();
@@ -283,6 +291,7 @@ void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdit
camera_crop_factor->setDefault (defParams->perspective.camera_crop_factor);
camera_focal_length->setDefault (defParams->perspective.camera_focal_length);
camera_pitch->setDefault (defParams->perspective.camera_pitch);
camera_roll->setDefault (defParams->perspective.camera_roll);
camera_shift_horiz->setDefault (defParams->perspective.camera_shift_horiz);
camera_shift_vert->setDefault (defParams->perspective.camera_shift_vert);
camera_yaw->setDefault (defParams->perspective.camera_yaw);
@@ -299,6 +308,7 @@ void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdit
camera_crop_factor->setDefaultEditedState (pedited->perspective.camera_crop_factor ? Edited : UnEdited);
camera_focal_length->setDefaultEditedState (pedited->perspective.camera_focal_length ? Edited : UnEdited);
camera_pitch->setDefaultEditedState (pedited->perspective.camera_pitch ? Edited : UnEdited);
camera_roll->setDefaultEditedState (pedited->perspective.camera_roll ? Edited : UnEdited);
camera_shift_horiz->setDefaultEditedState (pedited->perspective.camera_shift_horiz ? Edited : UnEdited);
camera_shift_vert->setDefaultEditedState (pedited->perspective.camera_shift_vert ? Edited : UnEdited);
camera_yaw->setDefaultEditedState (pedited->perspective.camera_yaw ? Edited : UnEdited);
@@ -314,6 +324,7 @@ void PerspCorrection::setDefaults (const ProcParams* defParams, const ParamsEdit
camera_crop_factor->setDefaultEditedState (Irrelevant);
camera_focal_length->setDefaultEditedState (Irrelevant);
camera_pitch->setDefaultEditedState (Irrelevant);
camera_roll->setDefaultEditedState (Irrelevant);
camera_shift_horiz->setDefaultEditedState (Irrelevant);
camera_shift_vert->setDefaultEditedState (Irrelevant);
camera_yaw->setDefaultEditedState (Irrelevant);
@@ -350,9 +361,11 @@ void PerspCorrection::adjusterChanged(Adjuster* a, double newval)
camera_shift_horiz->getValue(),
M("TP_PERSPECTIVE_CAMERA_SHIFT_VERTICAL"),
camera_shift_vert->getValue()));
} else if (a == camera_pitch || a == camera_yaw) {
} else if (a == camera_pitch || a == camera_roll|| a == camera_yaw) {
listener->panelChanged (EvPerspCamAngle,
Glib::ustring::compose("%1=%2\n%3=%4",
Glib::ustring::compose("%1=%2\n%3=%4\n%5=%6",
M("TP_PERSPECTIVE_CAMERA_ROLL"),
camera_roll->getValue(),
M("TP_PERSPECTIVE_CAMERA_YAW"),
camera_yaw->getValue(),
M("TP_PERSPECTIVE_CAMERA_PITCH"),
@@ -401,6 +414,7 @@ void PerspCorrection::autoCorrectionPressed(Gtk::Button* b)
disableListener();
camera_pitch->setValue(pitch);
camera_roll->setValue(rot);
camera_yaw->setValue(yaw);
enableListener();
@@ -435,6 +449,7 @@ void PerspCorrection::setAdjusterBehavior (bool badd, bool camera_focal_length_a
camera_crop_factor->setAddMode(camera_focal_length_add);
camera_focal_length->setAddMode(camera_focal_length_add);
camera_pitch->setAddMode(camera_angle_add);
camera_roll->setAddMode(camera_angle_add);
camera_shift_horiz->setAddMode(camera_shift_add);
camera_shift_vert->setAddMode(camera_shift_add);
camera_yaw->setAddMode(camera_angle_add);
@@ -454,6 +469,7 @@ void PerspCorrection::trimValues (rtengine::procparams::ProcParams* pp)
camera_crop_factor->trimValue(pp->perspective.camera_crop_factor);
camera_focal_length->trimValue(pp->perspective.camera_focal_length);
camera_pitch->trimValue(pp->perspective.camera_pitch);
camera_roll->trimValue(pp->perspective.camera_roll);
camera_shift_horiz->trimValue(pp->perspective.camera_shift_horiz);
camera_shift_vert->trimValue(pp->perspective.camera_shift_vert);
camera_yaw->trimValue(pp->perspective.camera_yaw);
@@ -474,6 +490,7 @@ void PerspCorrection::setBatchMode (bool batchMode)
camera_crop_factor->showEditedCB ();
camera_focal_length->showEditedCB ();
camera_pitch->showEditedCB ();
camera_roll->showEditedCB ();
camera_shift_horiz->showEditedCB ();
camera_shift_vert->showEditedCB ();
camera_yaw->showEditedCB ();

View File

@@ -42,6 +42,7 @@ protected:
Adjuster* camera_crop_factor;
Adjuster* camera_focal_length;
Adjuster* camera_pitch;
Adjuster* camera_roll;
Adjuster* camera_shift_horiz;
Adjuster* camera_shift_vert;
Adjuster* camera_yaw;