-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.2024.10.04: page split and deskew: complite order
- Loading branch information
1 parent
fc0b38e
commit 5b5c3f3
Showing
34 changed files
with
654 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
Scan Tailor - Interactive post-processing tool for scanned pages. | ||
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <memory> | ||
#include "../Params.h" | ||
#include "OrderByAngleAbsProvider.h" | ||
|
||
namespace deskew | ||
{ | ||
|
||
OrderByAngleAbsProvider::OrderByAngleAbsProvider(IntrusivePtr<Settings> const& settings) | ||
: m_ptrSettings(settings) | ||
{ | ||
} | ||
|
||
bool | ||
OrderByAngleAbsProvider::precedes( | ||
PageId const& lhs_page, bool const lhs_incomplete, | ||
PageId const& rhs_page, bool const rhs_incomplete) const | ||
{ | ||
std::unique_ptr<Params> const lhs_params(m_ptrSettings->getPageParams(lhs_page)); | ||
std::unique_ptr<Params> const rhs_params(m_ptrSettings->getPageParams(rhs_page)); | ||
|
||
bool const lhs_valid = !lhs_incomplete; | ||
bool const rhs_valid = !rhs_incomplete; | ||
|
||
if (lhs_valid != rhs_valid) | ||
{ | ||
// Invalid (unknown) sizes go to the back. | ||
return lhs_valid; | ||
} | ||
|
||
double lhs_angle = 0.0; | ||
if (lhs_params.get()) | ||
{ | ||
switch (lhs_params->distortionType().get()) | ||
{ | ||
case DistortionType::NONE: | ||
lhs_angle = 0.0; | ||
break; | ||
case DistortionType::ROTATION: | ||
lhs_angle = -lhs_params->rotationParams().compensationAngleDeg(); | ||
break; | ||
case DistortionType::PERSPECTIVE: | ||
lhs_angle = lhs_params->perspectiveParams().getAngle(); | ||
break; | ||
case DistortionType::WARP: | ||
lhs_angle = lhs_params->dewarpingParams().getAngle(); | ||
break; | ||
} // switch | ||
} | ||
lhs_angle = (lhs_angle < 0.0) ? -lhs_angle : lhs_angle; | ||
|
||
double rhs_angle = 0.0; | ||
if (rhs_params.get()) | ||
{ | ||
switch (rhs_params->distortionType().get()) | ||
{ | ||
case DistortionType::NONE: | ||
rhs_angle = 0.0; | ||
break; | ||
case DistortionType::ROTATION: | ||
rhs_angle = -rhs_params->rotationParams().compensationAngleDeg(); | ||
break; | ||
case DistortionType::PERSPECTIVE: | ||
rhs_angle = rhs_params->perspectiveParams().getAngle(); | ||
break; | ||
case DistortionType::WARP: | ||
rhs_angle = rhs_params->dewarpingParams().getAngle(); | ||
break; | ||
} // switch | ||
} | ||
rhs_angle = (rhs_angle < 0.0) ? -rhs_angle : rhs_angle; | ||
|
||
if (lhs_angle == rhs_angle) | ||
{ | ||
return (lhs_page < rhs_page); | ||
} | ||
else | ||
{ | ||
return (lhs_angle < rhs_angle); | ||
} | ||
} | ||
|
||
} // namespace deskew |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Scan Tailor - Interactive post-processing tool for scanned pages. | ||
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef DESKEW_ORDER_BY_ANGLE_ABS_PROVIDER_H_ | ||
#define DESKEW_ORDER_BY_ANGLE_ABS_PROVIDER_H_ | ||
|
||
#include "../Settings.h" | ||
#include "IntrusivePtr.h" | ||
#include "PageOrderProvider.h" | ||
|
||
namespace deskew | ||
{ | ||
|
||
class OrderByAngleAbsProvider : public PageOrderProvider | ||
{ | ||
public: | ||
OrderByAngleAbsProvider(IntrusivePtr<Settings> const& settings); | ||
|
||
virtual bool precedes( | ||
PageId const& lhs_page, bool lhs_incomplete, | ||
PageId const& rhs_page, bool rhs_incomplete) const; | ||
private: | ||
IntrusivePtr<Settings> m_ptrSettings; | ||
}; | ||
|
||
} // namespace deskew | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.