Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
11844b5c
Commit
11844b5c
authored
Jul 18, 2022
by
Volker Krause
Browse files
Also detect 1D barcodes by default
parent
4f77b020
Pipeline
#206832
passed with stage
in 8 minutes and 58 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/lib/barcodedecoder.cpp
View file @
11844b5c
...
...
@@ -40,7 +40,8 @@ enum {
static
constexpr
const
auto
SQUARE_MAX_ASPECT
=
1.25
f
;
static
constexpr
const
auto
PDF417_MIN_ASPECT
=
1.5
f
;
static
constexpr
const
auto
PDF417_MAX_ASPECT
=
6.0
f
;
static
constexpr
const
auto
ANY1D_MIN_ASPECT
=
6.0
f
;
static
constexpr
const
auto
ANY1D_MIN_ASPECT
=
4.0
f
;
static
constexpr
const
auto
ANY1D_MAX_ASPECT
=
8.0
f
;
BarcodeDecoder
::
BarcodeDecoder
()
=
default
;
BarcodeDecoder
::~
BarcodeDecoder
()
=
default
;
...
...
@@ -118,7 +119,7 @@ BarcodeDecoder::BarcodeTypes BarcodeDecoder::isPlausibleAspectRatio(int width, i
}
// 1D
if
(
aspectRatio
<
ANY1D_MIN_ASPECT
)
{
if
(
aspectRatio
<
ANY1D_MIN_ASPECT
||
aspectRatio
>
ANY1D_MAX_ASPECT
)
{
hint
&=
~
Any1D
;
}
...
...
src/lib/pdf/pdfbarcodeutil.cpp
View file @
11844b5c
...
...
@@ -11,13 +11,17 @@ using namespace KItinerary;
enum
{
// unit is 1/72 inch, assuming landscape orientation
MinTargetImageHeight
=
28
,
MinTargetImageHeight2D
=
28
,
MinTargetImageHeight1D
=
20
,
MinTargetImageWidth
=
36
,
MaxTargetImageHeight
=
252
,
MaxTargetImageWidth2D
=
252
,
MaxTargetImageWidth1D
=
272
,
// vector path complexity limits
MinPathElementCount2D
=
400
,
MaxPathElementCount2D
=
4000
,
MinPathElementCount1D
=
200
,
MaxPathElementCount1D
=
400
,
};
BarcodeDecoder
::
BarcodeTypes
PdfBarcodeUtil
::
maybeBarcode
(
const
PdfImage
&
img
,
BarcodeDecoder
::
BarcodeTypes
hint
)
...
...
@@ -26,13 +30,16 @@ BarcodeDecoder::BarcodeTypes PdfBarcodeUtil::maybeBarcode(const PdfImage &img, B
const
auto
h
=
img
.
height
();
// image target size checks
if
(
std
::
min
(
w
,
h
)
<
MinTargetImageHeight
||
std
::
max
(
w
,
h
)
<
MinTargetImageWidth
||
std
::
min
(
w
,
h
)
>
MaxTargetImageHeight
)
{
if
(
std
::
max
(
w
,
h
)
<
MinTargetImageWidth
||
std
::
min
(
w
,
h
)
>
MaxTargetImageHeight
)
{
return
BarcodeDecoder
::
None
;
}
if
(
std
::
max
(
w
,
h
)
>
MaxTargetImageWidth2D
)
{
if
(
std
::
max
(
w
,
h
)
>
MaxTargetImageWidth2D
||
std
::
min
(
w
,
h
)
<
MinTargetImageHeight2D
)
{
hint
&=
~
BarcodeDecoder
::
Any2D
;
}
if
(
std
::
max
(
w
,
h
)
>
MaxTargetImageWidth1D
||
std
::
min
(
w
,
h
)
<
MinTargetImageHeight1D
)
{
hint
&=
~
BarcodeDecoder
::
Any1D
;
}
hint
=
BarcodeDecoder
::
isPlausibleSize
(
img
.
sourceWidth
(),
img
.
sourceHeight
(),
hint
);
hint
=
BarcodeDecoder
::
isPlausibleAspectRatio
(
w
,
h
,
hint
);
...
...
@@ -49,5 +56,8 @@ BarcodeDecoder::BarcodeTypes PdfBarcodeUtil::isPlausiblePath(int elementCount, B
if
(
elementCount
<
MinPathElementCount2D
||
elementCount
>
MaxPathElementCount2D
)
{
hint
&=
~
BarcodeDecoder
::
Any2D
;
}
if
(
elementCount
<
MinPathElementCount1D
||
elementCount
>
MaxPathElementCount1D
)
{
hint
&=
~
BarcodeDecoder
::
Any1D
;
}
return
hint
;
}
src/lib/processors/imagedocumentprocessor.cpp
View file @
11844b5c
...
...
@@ -36,7 +36,7 @@ void ImageDocumentProcessor::expandNode(ExtractorDocumentNode &node, const Extra
const
auto
img
=
node
.
content
<
QImage
>
();
BarcodeDecoder
::
BarcodeTypes
barcodeHints
=
BarcodeDecoder
::
Any2D
;
BarcodeDecoder
::
BarcodeTypes
barcodeHints
=
BarcodeDecoder
::
Any2D
|
BarcodeDecoder
::
Any1D
;
// check whether we possibly have a full PDF page raster image here
if
(
engine
->
hints
()
&
ExtractorEngine
::
ExtractFullPageRasterImages
)
{
barcodeHints
|=
BarcodeDecoder
::
IgnoreAspectRatio
;
...
...
src/lib/processors/pdfdocumentprocessor.cpp
View file @
11844b5c
...
...
@@ -91,7 +91,7 @@ void PdfDocumentProcessor::expandNode(ExtractorDocumentNode &node, const Extract
continue
;
}
const
auto
barcodeHints
=
PdfBarcodeUtil
::
maybeBarcode
(
img
,
BarcodeDecoder
::
Any2D
);
const
auto
barcodeHints
=
PdfBarcodeUtil
::
maybeBarcode
(
img
,
BarcodeDecoder
::
Any2D
|
BarcodeDecoder
::
Any1D
);
if
(
barcodeHints
==
BarcodeDecoder
::
None
)
{
continue
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment