Skip to content

Commit 445217e

Browse files
committed
ReadBarcode: fix issue with interacting tryInvert and tryDenoise options
1 parent 0f115a8 commit 445217e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

core/src/BinaryBitmap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void BinaryBitmap::invert()
6363
auto matrix = const_cast<BitMatrix*>(_cache->matrix.get());
6464
matrix->flipAll();
6565
}
66-
_inverted = true;
66+
_inverted = !_inverted;
6767
}
6868

6969
template <typename F>

core/src/ReadBarcode.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,12 @@ Barcodes ReadBarcodes(const ImageView& _iv, const ReaderOptions& opts)
175175
for (auto&& iv : pyramid.layers) {
176176
auto bitmap = CreateBitmap(opts.binarizer(), iv);
177177
for (int close = 0; close <= (closedReader ? 1 : 0); ++close) {
178-
if (close)
178+
if (close) {
179+
// if we already inverted the image in the first round, we need to undo that first
180+
if (bitmap->inverted())
181+
bitmap->invert();
179182
bitmap->close();
183+
}
180184

181185
// TODO: check if closing after invert would be beneficial
182186
for (int invert = 0; invert <= static_cast<int>(opts.tryInvert() && !close); ++invert) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy