Commit 107ff773 authored by Julius Künzel's avatar Julius Künzel
Browse files

Import keyframes dialog: add two new modes offset and inverted position

Fixes #438

The two new modes are useful to paste the analysis date from the
opencv.tracker (aka Motion Tracker) effect to a transform effect and use
them to stabilize the footage.

Inverted Position is the same than Position but with negativ values x >
-x and y > -y

Offset position is the difference beetween the reference point's position
(first keyframe) and the current keyframe's position
parent e2ada40b
Pipeline #68308 passed with stage
in 8 minutes and 30 seconds
......@@ -303,6 +303,8 @@ void KeyframeImport::updateDataDisplay()
double hDist = m_maximas.at(3).y() - m_maximas.at(3).x();
m_sourceCombo->addItem(i18n("Geometry"), ImportRoles::FullGeometry);
m_sourceCombo->addItem(i18n("Position"), ImportRoles::Position);
m_sourceCombo->addItem(i18n("Inverted Position"), ImportRoles::InvertedPosition);
m_sourceCombo->addItem(i18n("Offset Position"), ImportRoles::OffsetPosition);
m_sourceCombo->addItem(i18n("X"), ImportRoles::XOnly);
m_sourceCombo->addItem(i18n("Y"), ImportRoles::YOnly);
if (wDist > 0) {
......@@ -332,8 +334,8 @@ void KeyframeImport::updateDataDisplay()
void KeyframeImport::updateRange()
{
int pos = m_sourceCombo->currentData().toInt();
m_alignSourceCombo->setEnabled(pos == ImportRoles::Position);
m_alignTargetCombo->setEnabled(pos == ImportRoles::Position);
m_alignSourceCombo->setEnabled(pos == ImportRoles::Position || pos == ImportRoles::InvertedPosition);
m_alignTargetCombo->setEnabled(pos == ImportRoles::Position || pos == ImportRoles::InvertedPosition);
QString rangeText;
if (m_limitRange->isChecked()) {
switch (pos) {
......@@ -759,6 +761,7 @@ void KeyframeImport::importSelectedData()
int frame = 0;
KeyframeImport::ImportRoles convertMode = static_cast<KeyframeImport::ImportRoles> (m_sourceCombo->currentData().toInt());
mlt_keyframe_type type;
mlt_rect firstRect = animData->anim_get_rect("key", anim->key_get_frame(0));
for (int i = 0; i < anim->key_count(); i++) {
int error = anim->key_get(i, frame, type);
if (error) {
......@@ -782,6 +785,8 @@ void KeyframeImport::importSelectedData()
}
break;
case ImportRoles::Position:
case ImportRoles::InvertedPosition:
case ImportRoles::OffsetPosition:
case ImportRoles::YOnly:
if (size < 2) {
continue;
......@@ -794,7 +799,7 @@ void KeyframeImport::importSelectedData()
break;
}
mlt_rect rect = animData->anim_get_rect("key", frame);
if (convertMode == ImportRoles::Position) {
if (convertMode == ImportRoles::Position || convertMode == ImportRoles::InvertedPosition) {
switch (sourceAlign) {
case 1:
// Align center
......@@ -835,6 +840,14 @@ void KeyframeImport::importSelectedData()
kfrData[0] = locale.toString(int(rect.x));
kfrData[1] = locale.toString(int(rect.y));
break;
case ImportRoles::InvertedPosition:
kfrData[0] = locale.toString(int(-rect.x));
kfrData[1] = locale.toString(int(-rect.y));
break;
case ImportRoles::OffsetPosition:
kfrData[0] = locale.toString(int(firstRect.x - rect.x));
kfrData[1] = locale.toString(int(firstRect.y - rect.y));
break;
case ImportRoles::SimpleValue:
case ImportRoles::XOnly:
kfrData[0] = locale.toString(int(rect.x));
......
......@@ -81,6 +81,8 @@ protected:
SimpleValue,
FullGeometry,
Position,
InvertedPosition,
OffsetPosition,
XOnly,
YOnly,
WidthOnly,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment