pl.beone.promena.transformer:converter-pdfbox-configuration

pl.beone.promena.sdk.maven.parent:promena-transformer-parent

License

License

Categories

Categories

PDFBox Business Logic Libraries Configuration Application Layer Libs config ORM Data PDF
GroupId

GroupId

pl.beone.promena.transformer
ArtifactId

ArtifactId

converter-pdfbox-configuration
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

pl.beone.promena.sdk.maven.parent:promena-transformer-parent
Project URL

Project URL

https://beone.pl
Project Organization

Project Organization

BeOne Sp. z o.o.
Source Code Management

Source Code Management

https://github.com/BeOne-PL/promena-transformer-barcode-detector-zxing-opencv

Download converter-pdfbox-configuration

How to add to project

<!-- https://jarcasting.com/artifacts/pl.beone.promena.transformer/converter-pdfbox-configuration/ -->
<dependency>
    <groupId>pl.beone.promena.transformer</groupId>
    <artifactId>converter-pdfbox-configuration</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/pl.beone.promena.transformer/converter-pdfbox-configuration/
implementation 'pl.beone.promena.transformer:converter-pdfbox-configuration:1.0.0'
// https://jarcasting.com/artifacts/pl.beone.promena.transformer/converter-pdfbox-configuration/
implementation ("pl.beone.promena.transformer:converter-pdfbox-configuration:1.0.0")
'pl.beone.promena.transformer:converter-pdfbox-configuration:jar:1.0.0'
<dependency org="pl.beone.promena.transformer" name="converter-pdfbox-configuration" rev="1.0.0">
  <artifact name="converter-pdfbox-configuration" type="jar" />
</dependency>
@Grapes(
@Grab(group='pl.beone.promena.transformer', module='converter-pdfbox-configuration', version='1.0.0')
)
libraryDependencies += "pl.beone.promena.transformer" % "converter-pdfbox-configuration" % "1.0.0"
[pl.beone.promena.transformer/converter-pdfbox-configuration "1.0.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.3.50
org.jetbrains.kotlin : kotlin-reflect jar 1.3.50
pl.beone.promena.transformer : converter-pdfbox jar 1.0.0
org.springframework.boot : spring-boot-starter jar 2.2.1.RELEASE
joda-time : joda-time jar 2.10.5

test (3)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
io.kotlintest : kotlintest-runner-junit5 jar 3.4.2
org.springframework.boot : spring-boot-starter-test jar 2.2.1.RELEASE

Project Modules

There are no modules declared in this project.

Promena Transformer - barcode detector - ZXing & OpenCV

This transformer provides functionality to detect barcodes in a application/pdf document using ZXing 3.4.0 and OpenCV 4.1.2.

Visit Promena#Transformer to understand the repository structure.

The solution was developed thanks to the following resources:

Algorithm (for one page)

  1. Convert to grayscale image with 300 DPI
  2. Compute the Scharr gradient magnitude representation
  3. Subtract the y-gradient from the x-gradient
  4. Apply the binary threshold using values from linearThresholdValue and linearThresholdMaxValue parameters
  5. Construct and apply the closing kernel using values from linearKernelSizeWidth and linearKernelSizeHeight parameters
  6. Apply erosions and dilations using values from linearErosionsIterations and linearDilationsIterations parameters
  7. Determine bounding boxes
  8. Find the convex hull of each bounding box
  9. If linearAdditionalVerticalTransformation is true, swap linearKernelSizeWidth parameter with linearKernelSizeHeight parameter and repeat steps 2-8
  10. Cut out found contours to separate images
  11. Calculate tilt of each image and rotation angles to rotate the image perpendicularly
  12. After rotation apply additional rotations using value from linearRotationThresholdDegrees parameter
  13. Try to detect a barcode on the image using formats from formats parameter
  14. Repeat steps 2-13 for the set of parameters with matrix prefix
  15. Filter found barcodes using value from regexFilter parameter

Transformation ZxingOpenCvBarcodeDetectorDsl, ZxingOpenCvBarcodeDetectorParametersDsl

The DataDescriptor has to contain at least one descriptor. If more than one descriptor is passed, the transformation will be performed on each of them separately.

Support ZxingOpenCvBarcodeDetectorSupport

Media type ZxingOpenCvBarcodeDetectorSupport.MediaTypeSupport

  • application/pdf; UTF-8 ➡️ application/pdf; UTF-8

Parameters ZxingOpenCvBarcodeDetectorSupport.ParametersSupport

Take a look at Algorithm (for one page) to understand the meaning of given parameter.

  • formats, List<String>, ["Codabar", "UPC-A", "UPC-E", "EAN-8", "EAN-13", "Code 39", "Code 128", "ITF", "RSS-14", "RSS Expanded", "QR Code", "PDF417", "Aztec Code", "Data Matrix", "MaxiCode"] optional
  • regexFilter, String, optional
  • linearRotationThresholdDegrees, Int, <1, 360>, optional
  • linearAdditionalVerticalTransformation, Boolean, optional
  • linearThresholdValue, Double, <1.0, 255.0>, optional
  • linearThresholdMaxVal, Double, <1.0, 255.0>, optional
  • linearKernelSizeWidth, Double, <1.0, 1000.0>, optional
  • linearKernelSizeHeight, Double, <1.0, 1000.0>, optional
  • linearErosionsIterations, Int, <1, 1000>, optional
  • linearDilationsIterations, Int, <1, 1000>, optional
  • matrixRotationThresholdDegrees, Int, <1, 360>, optional
  • matrixAdditionalVerticalTransformation, Boolean, optional
  • matrixThresholdValue, Double, <1.0, 255.0>, optional
  • matrixThresholdMaxVal, Double, <1.0, 255.0>, optional
  • matrixKernelSizeWidth, Double, <1.0, 1000.0>, optional
  • matrixKernelSizeHeight, Double, <1.0, 1000.0>, optional
  • matrixErosionsIterations, Int, <1, 1000>, optional
  • matrixDilationsIterations, Int, <1, 1000>, optional

Metadata

Visit to find out how to build and process barcode metadata.

Dependency

<dependency>
    <groupId>pl.beone.promena.transformer</groupId>
    <artifactId>barcode-detector-zxing-opencv-configuration</artifactId>
    <version>1.0.1</version>
</dependency>

promena-docker-maven-plugin

<dependency>
    <groupId>pl.beone.promena.transformer</groupId>
    <artifactId>barcode-detector-zxing-opencv</artifactId>
    <version>1.0.1</version>
</dependency>

Properties

The default values are adjusted to recognise barcodes on scanned documents.

transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.ZxingOpenCvBarcodeDetectorTransformer.priority=1
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.ZxingOpenCvBarcodeDetectorTransformer.actors=1

# RSS-14, RSS Expanded, UPC-E produces many false-positive detections
# UPC-A, EAN-8, EAN-13 also produces false-positive detections but less than previous ones
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.formats=Codabar,Code 39,Code 128,ITF,QR Code,PDF417,Aztec Code,Data Matrix,MaxiCode
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.regex-filter=

transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-rotation-threshold-degrees=1
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-additional-vertical-transformation=true
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-threshold-value=150.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-threshold-max-val=255.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-kernel-size-width=25.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-kernel-size-height=1.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-erosions-iterations=20
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.linear-dilations-iterations=20

transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-rotation-threshold-degrees=1
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-additional-vertical-transformation=false
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-threshold-value=100.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-threshold-max-val=255.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-kernel-size-width=20.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-kernel-size-height=20.0
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-erosions-iterations=20
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.matrix-dilations-iterations=20
transformer.pl.beone.promena.transformer.barcodedetector.zxingopencv.default.parameters.timeout=

Evaluator

If you want to adjust parameters, run Main from barcode-detector-zxing-opencv-evaluator module (you have to install OpenCV 4.1.2 on your computer).

Screen

pl.beone.promena.transformer

BeOne Sp. z o.o.

Versions

Version
1.0.0