Skip to content

Commit 0346e9a

Browse files
committed
Work in progress on next generation dewarping.
1 parent 70122ce commit 0346e9a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+4501
-1045
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CMakeLists.txt.user
1+
CMakeLists.txt.user*

CMakeLists.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,6 @@ IF(MSVC)
301301
OPTION(ENABLE_CRASH_REPORTER "Enable crash reporter (only for official builds)" OFF)
302302
ENDIF(MSVC)
303303

304-
OPTION(ENABLE_DEWARPING "Enable experimental dewarping support" OFF)
305-
306304
# Prepare config.h
307305
IF(WIN32)
308306
SET(TRANSLATIONS_DIR_REL "translations")
@@ -416,7 +414,7 @@ SET(
416414
AtomicFileOverwriter.cpp AtomicFileOverwriter.h
417415
EstimateBackground.cpp EstimateBackground.h
418416
Despeckle.cpp Despeckle.h
419-
Undistort.cpp Undistort.h
417+
#Undistort.cpp Undistort.h
420418
ThreadPriority.cpp ThreadPriority.h
421419
SystemLoadWidget.cpp SystemLoadWidget.h
422420
FileNameDisambiguator.cpp FileNameDisambiguator.h
@@ -439,11 +437,12 @@ SET(
439437
filter_dc/ThumbnailCollector.h
440438
filter_dc/ContentBoxCollector.h
441439
filter_dc/PageOrientationCollector.h
440+
config.h.in
442441
)
443442
SOURCE_GROUP("Sources" FILES ${sources})
444443
QT4_AUTOMOC(${sources})
445444

446-
SOURCE_GROUP("Version Header" FILES version.h)
445+
SOURCE_GROUP("Special Headers" FILES version.h config.h.in)
447446

448447
SET(win32_resource_file)
449448
IF(WIN32)

FilterData.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Scan Tailor - Interactive post-processing tool for scanned pages.
3-
Copyright (C) 2007-2008 Joseph Artsimovich <joseph_a@mail.ru>
3+
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
44
55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
2020
#define FILTERDATA_H_
2121

2222
#include "imageproc/BinaryThreshold.h"
23+
#include "imageproc/GrayImage.h"
2324
#include "ImageTransformation.h"
2425
#include <QImage>
2526

@@ -37,10 +38,10 @@ class FilterData
3738

3839
QImage const& origImage() const {return m_origImage;}
3940

40-
QImage const& grayImage() const {return m_grayImage;}
41+
imageproc::GrayImage const& grayImage() const {return m_grayImage;}
4142
private:
4243
QImage m_origImage;
43-
QImage m_grayImage;
44+
imageproc::GrayImage m_grayImage;
4445
ImageTransformation m_xform;
4546
imageproc::BinaryThreshold m_bwThreshold;
4647
};

XmlMarshaller.cpp

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Scan Tailor - Interactive post-processing tool for scanned pages.
3-
Copyright (C) 2007-2009 Joseph Artsimovich <joseph_a@mail.ru>
3+
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
44
55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -21,6 +21,8 @@
2121
#include "Margins.h"
2222
#include "Dpi.h"
2323
#include "Utils.h"
24+
#include "imageproc/CubicBSpline.h"
25+
#include <boost/foreach.hpp>
2426
#include <QPointF>
2527
#include <QLineF>
2628
#include <QRect>
@@ -150,3 +152,19 @@ XmlMarshaller::margins(Margins const& margins, QString const& name)
150152
el.setAttribute("bottom", Utils::doubleToString(margins.bottom()));
151153
return el;
152154
}
155+
156+
QDomElement
157+
XmlMarshaller::bspline(imageproc::CubicBSpline const& bspline, QString const& name)
158+
{
159+
if (bspline.controlPoints().empty()) {
160+
return QDomElement();
161+
}
162+
163+
QDomElement el(m_doc.createElement(name));
164+
165+
BOOST_FOREACH(QPointF const& pt, bspline.controlPoints()) {
166+
el.appendChild(pointF(pt, "point"));
167+
}
168+
169+
return el;
170+
}

XmlMarshaller.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Scan Tailor - Interactive post-processing tool for scanned pages.
3-
Copyright (C) 2007-2009 Joseph Artsimovich <joseph_a@mail.ru>
3+
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
44
55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -34,6 +34,11 @@ class QPolygonF;
3434
class QRect;
3535
class QRectF;
3636

37+
namespace imageproc
38+
{
39+
class CubicBSpline;
40+
}
41+
3742
class XmlMarshaller
3843
{
3944
public:
@@ -60,6 +65,8 @@ class XmlMarshaller
6065
QDomElement polygonF(QPolygonF const& poly, QString const& name);
6166

6267
QDomElement margins(Margins const& margins, QString const& name);
68+
69+
QDomElement bspline(imageproc::CubicBSpline const& bspline, QString const& name);
6370
private:
6471
QDomDocument m_doc;
6572
};

XmlUnmarshaller.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Scan Tailor - Interactive post-processing tool for scanned pages.
3-
Copyright (C) 2007-2009 Joseph Artsimovich <joseph_a@mail.ru>
3+
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
44
55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
2020
#include "Dpi.h"
2121
#include "OrthogonalRotation.h"
2222
#include "Margins.h"
23+
#include "imageproc/CubicBSpline.h"
2324
#include <QString>
2425
#include <QSize>
2526
#include <QSizeF>
@@ -140,3 +141,23 @@ XmlUnmarshaller::polygonF(QDomElement const& el)
140141

141142
return poly;
142143
}
144+
145+
imageproc::CubicBSpline
146+
XmlUnmarshaller::bspline(QDomElement const& el)
147+
{
148+
imageproc::CubicBSpline bspline;
149+
150+
QString const point_tag_name("point");
151+
QDomNode node(el.firstChild());
152+
for (; !node.isNull(); node = node.nextSibling()) {
153+
if (!node.isElement()) {
154+
continue;
155+
}
156+
if (node.nodeName() != point_tag_name) {
157+
continue;
158+
}
159+
bspline.appendControlPoint(pointF(node.toElement()));
160+
}
161+
162+
return bspline;
163+
}

XmlUnmarshaller.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Scan Tailor - Interactive post-processing tool for scanned pages.
3-
Copyright (C) 2007-2009 Joseph Artsimovich <joseph_a@mail.ru>
3+
Copyright (C) Joseph Artsimovich <joseph.artsimovich@gmail.com>
44
55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -32,6 +32,11 @@ class QRect;
3232
class QRectF;
3333
class QPolygonF;
3434

35+
namespace imageproc
36+
{
37+
class CubicBSpline;
38+
}
39+
3540
class XmlUnmarshaller
3641
{
3742
public:
@@ -56,6 +61,8 @@ class XmlUnmarshaller
5661
static QRectF rectF(QDomElement const& el);
5762

5863
static QPolygonF polygonF(QDomElement const& el);
64+
65+
static imageproc::CubicBSpline bspline(QDomElement const& el);
5966
};
6067

6168
#endif

config.h.in

-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88

99
#cmakedefine ENABLE_CRASH_REPORTER
1010
#cmakedefine ENABLE_OPENGL
11-
#cmakedefine ENABLE_DEWARPING
1211

1312
#endif

filters/output/ApplyColorsDialog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ ApplyColorsDialog::onSubmit()
5656

5757
// thisPageRB is intentionally not handled.
5858
if (allPagesRB->isChecked()) {
59-
emit acceptedForAllPages();
59+
m_pages.selectAll().swap(pages);
6060
} else if (thisPageAndFollowersRB->isChecked()) {
6161
m_pages.selectPagePlusFollowers(m_curPage).swap(pages);
6262
} else if (selectedPagesRB->isChecked()) {

filters/output/ApplyColorsDialog.h

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ class ApplyColorsDialog : public QDialog, private Ui::OutputApplyColorsDialog
4242
virtual ~ApplyColorsDialog();
4343
signals:
4444
void accepted(std::set<PageId> const& pages);
45-
46-
void acceptedForAllPages();
4745
private slots:
4846
void onSubmit();
4947
private:

filters/output/BlackWhiteOptions.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ namespace output
2525
{
2626

2727
BlackWhiteOptions::BlackWhiteOptions()
28-
: m_thresholdAdjustment(0),
29-
m_dewarp(false)
28+
: m_thresholdAdjustment(0)
3029
{
3130
}
3231

3332
BlackWhiteOptions::BlackWhiteOptions(QDomElement const& el)
34-
: m_thresholdAdjustment(el.attribute("thresholdAdj").toInt()),
35-
m_dewarp(el.attribute("dewarp") == "1")
33+
: m_thresholdAdjustment(el.attribute("thresholdAdj").toInt())
3634
{
3735
}
3836

@@ -41,7 +39,6 @@ BlackWhiteOptions::toXml(QDomDocument& doc, QString const& name) const
4139
{
4240
QDomElement el(doc.createElement(name));
4341
el.setAttribute("thresholdAdj", m_thresholdAdjustment);
44-
el.setAttribute("dewarp", m_dewarp ? "1" : "0");
4542
return el;
4643
}
4744

@@ -52,10 +49,6 @@ BlackWhiteOptions::operator==(BlackWhiteOptions const& other) const
5249
return false;
5350
}
5451

55-
if (m_dewarp != other.m_dewarp) {
56-
return false;
57-
}
58-
5952
return true;
6053
}
6154

filters/output/BlackWhiteOptions.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,12 @@ class BlackWhiteOptions
3838
int thresholdAdjustment() const { return m_thresholdAdjustment; }
3939

4040
void setThresholdAdjustment(int val) { m_thresholdAdjustment = val; }
41-
42-
bool dewarp() const { return m_dewarp; }
43-
44-
void setDewarp(bool enabled) { m_dewarp = enabled; }
45-
41+
4642
bool operator==(BlackWhiteOptions const& other) const;
4743

4844
bool operator!=(BlackWhiteOptions const& other) const;
4945
private:
5046
int m_thresholdAdjustment;
51-
bool m_dewarp;
5247
};
5348

5449
} // namespace output

filters/output/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ SET(
4747
DespeckleVisualization.cpp DespeckleVisualization.h
4848
DespeckleLevel.cpp DespeckleLevel.h
4949
DewarpingView.cpp DewarpingView.h
50+
DewarpingMode.cpp DewarpingMode.h
51+
ChangeDewarpingDialog.cpp ChangeDewarpingDialog.h
52+
DistortionModel.cpp DistortionModel.h
53+
DepthPerception.cpp DepthPerception.h
54+
Curve.cpp Curve.h
5055
)
5156
SOURCE_GROUP("Sources" FILES ${sources})
5257
QT4_AUTOMOC(${sources})

filters/output/CacheDrivenTask.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ CacheDrivenTask::process(
8484
);
8585
OutputImageParams const new_output_image_params(
8686
generator.outputImageSize(), generator.outputContentRect(),
87-
xform, params.outputDpi(), params.colorParams(), params.despeckleLevel()
87+
xform, params.outputDpi(), params.colorParams(),
88+
params.dewarpingMode(), params.distortionModel(),
89+
params.depthPerception(), params.despeckleLevel()
8890
);
8991

9092
if (!stored_output_params->outputImageParams().matches(new_output_image_params)) {
@@ -134,7 +136,7 @@ CacheDrivenTask::process(
134136
)
135137
);
136138
} else {
137-
Dpi const out_dpi(m_ptrSettings->getDpi(page_info.id()));
139+
Dpi const out_dpi(m_ptrSettings->getParams(page_info.id()).outputDpi());
138140

139141
QTransform tmp_xform(xform.transform());
140142
tmp_xform *= Utils::scaleFromToDpi(

0 commit comments

Comments
 (0)