pl.beone.promena.transformer:barcode-detector-zxing-opencv

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

License

License

Categories

Categories

OpenCV Business Logic Libraries Computer Vision ZXing Data Data Formats Image Processing ORM
GroupId

GroupId

pl.beone.promena.transformer
ArtifactId

ArtifactId

barcode-detector-zxing-opencv
Last Version

Last Version

1.0.1
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 barcode-detector-zxing-opencv

How to add to project

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

Dependencies

compile (9)

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.base : promena-transformer-util jar 1.0.0
pl.beone.promena.transformer : barcode-detector-zxing-opencv-application-model jar 1.0.1
io.github.microutils : kotlin-logging jar 1.7.6
org.bytedeco : javacv-platform jar 1.5.2
com.google.zxing : core jar 3.4.0
com.google.zxing : javase jar 3.4.0
org.apache.pdfbox : pdfbox jar 2.0.16

test (5)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.3
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
io.kotlintest : kotlintest-runner-junit5 jar 3.4.2
io.mockk : mockk jar 1.9.3
pl.beone.lib : docker-extension-junit5 jar 1.0.0

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.1
1.0.0