Skip to content

Commit

Permalink
Replace STU dewarp spline initialization method by STEX version
Browse files Browse the repository at this point in the history
* research #2
  • Loading branch information
zvezdochiot authored and noobie-iv committed Jan 3, 2025
1 parent 1a7e763 commit e70cb12
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/filters/deskew/DewarpingView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ DewarpingView::~DewarpingView()
void
DewarpingView::initNewSpline(XSpline& spline, QPointF const& p1, QPointF const& p2)
{
int const num_points = 4;
QLineF const line(p1, p2);
spline.appendControlPoint(line.p1(), 0);
spline.appendControlPoint(line.pointAt(1.0/4.0), 1);
spline.appendControlPoint(line.pointAt(2.0/4.0), 1);
spline.appendControlPoint(line.pointAt(3.0/4.0), 1);
if (num_points > 2)
{
for (int i = 1; i < (num_points - 1); i++)
{
double frac = (double) i / (num_points - 1);
spline.appendControlPoint(line.pointAt(frac), 1);
}
}
spline.appendControlPoint(line.p2(), 0);
}

Expand Down

3 comments on commit e70cb12

@zvezdochiot
Copy link
Member Author

@zvezdochiot zvezdochiot commented on e70cb12 Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noobie-iv , а изменение условия в XSpline? Без него же пустые XSpline что-то возращает, а как результат прямые линии (без промежуточных точек) то сверху, то снизу. Или рано ещё?

// If nearby_junction_t is between prev_t and next_t, make it our mid_t.
if ((nearby_junction_t - prev_t) * (next_t - prev_t) > 0 &&
(nearby_junction_t - next_t) * (prev_t - next_t) > 0) {
mid_t = nearby_junction_t;
flags = JUNCTION_SAMPLE;
}

to:

    if (((next_t < prev_t) ? (prev_t - nearby_junction_t) : (nearby_junction_t - prev_t)) > 1e-5 &&
        ((prev_t < next_t) ? (next_t - nearby_junction_t) : (nearby_junction_t - next_t)) > 1e-5)
    {
        mid_t = nearby_junction_t;
        flags = JUNCTION_SAMPLE;
    }

Правда с комментарием "надо что то сделать".

@noobie-iv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zvezdochiot

Может, вообще откатить, пока не поздно? Я в математику сплайнов вообще не хочу лезть.

@zvezdochiot
Copy link
Member Author

@zvezdochiot zvezdochiot commented on e70cb12 Jan 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@noobie-iv , откатить куда? Ежели рано, то всё норм, просто "галочку" на память оставить. Но откатывать что? Никакого изменения толком данный коммит не несёт (ежели что, можно поставить 5 точек и будет 1 в 1). А править и дополнять 4 точки реально удобнее (по опыту пользования STEX).

PS: Я бы и сам в XSpline не полез, ежели бы не увидел их различие в STD и STEX, Я уже "профессиональный копипастер". У меня какая то деформация после page_layout и 3х ползунков в deskew.

Please sign in to comment.