Skip to content

Include version number of QR Code and DataMatrix in Result #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/DecoderResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class DecoderResult
Content _content;
std::string _ecLevel;
int _lineCount = 0;
int _versionNumber = 0;
StructuredAppendInfo _structuredAppend;
bool _isMirrored = false;
bool _readerInit = false;
Expand Down Expand Up @@ -71,6 +72,7 @@ class DecoderResult

ZX_PROPERTY(std::string, ecLevel, setEcLevel)
ZX_PROPERTY(int, lineCount, setLineCount)
ZX_PROPERTY(int, versionNumber, setVersionNumber)
ZX_PROPERTY(StructuredAppendInfo, structuredAppend, setStructuredAppend)
ZX_PROPERTY(Error, error, setError)
ZX_PROPERTY(bool, isMirrored, setIsMirrored)
Expand Down
4 changes: 3 additions & 1 deletion core/src/Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Result::Result(const std::string& text, int y, int xStart, int xStop, BarcodeFor
_position(Line(y, xStart, xStop)),
_format(format),
_lineCount(0),
_versionNumber(0),
_readerInit(readerInit)
{}

Expand All @@ -34,6 +35,7 @@ Result::Result(DecoderResult&& decodeResult, Position&& position, BarcodeFormat
_sai(decodeResult.structuredAppend()),
_format(format),
_lineCount(decodeResult.lineCount()),
_versionNumber(decodeResult.versionNumber()),
_isMirrored(decodeResult.isMirrored()),
_readerInit(decodeResult.readerInit())
{
Expand Down Expand Up @@ -116,7 +118,7 @@ Result& Result::setDecodeHints(DecodeHints hints)

bool Result::operator==(const Result& o) const
{
// two symbols may be considered the same if at least one of them has an error
// two symbols may not be considered the same if at least one of them has an error
if (!(format() == o.format() && (bytes() == o.bytes() || error() || o.error())))
return false;

Expand Down
8 changes: 7 additions & 1 deletion core/src/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,15 @@ class Result
bool readerInit() const { return _readerInit; }

/**
* @brief How many lines have been detected with this code (applies only to linear symbologies)
* @brief lineCount How many lines have been detected with this code (applies only to linear symbologies)
*/
int lineCount() const { return _lineCount; }

/**
* @brief versionNumber QR Code or DataMatrix version number.
*/
int versionNumber() const { return _versionNumber; }

// only for internal use
void incrementLineCount() { ++_lineCount; }
void setIsInverted(bool v) { _isInverted = v; }
Expand All @@ -166,6 +171,7 @@ class Result
StructuredAppendInfo _sai;
BarcodeFormat _format = BarcodeFormat::None;
int _lineCount = 0;
int _versionNumber = 0;
bool _isMirrored = false;
bool _isInverted = false;
bool _readerInit = false;
Expand Down
3 changes: 2 additions & 1 deletion core/src/datamatrix/DMDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ static DecoderResult DoDecode(const BitMatrix& bits)
}

// Decode the contents of that stream of bytes
return DecodedBitStreamParser::Decode(std::move(resultBytes), version->isDMRE());
return DecodedBitStreamParser::Decode(std::move(resultBytes), version->isDMRE())
.setVersionNumber(version->versionNumber);
}

static BitMatrix FlippedL(const BitMatrix& bits)
Expand Down
1 change: 1 addition & 0 deletions core/src/qrcode/QRDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ DecoderResult DecodeBitStream(ByteArray&& bytes, const Version& version, ErrorCo
return DecoderResult(std::move(result))
.setError(std::move(error))
.setEcLevel(ToString(ecLevel))
.setVersionNumber(version.versionNumber())
.setStructuredAppend(structuredAppend);
}

Expand Down
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