fixing compilation issues

This commit is contained in:
Nikolaos Ftylitakis 2021-08-07 13:28:11 +03:00
parent 5cb7431435
commit 263a8b61be
19 changed files with 213 additions and 214 deletions

View File

@ -170,10 +170,10 @@ QSharedPointer<DecoderResult> Decoder::decode(QSharedPointer<zxing::aztec::Aztec
QSharedPointer<String> result = getEncodedData(aCorrectedBits);
// std::printf("constructing array\n");
QSharedPointer<std::vector<zxing::byte>> arrayOut(aCorrectedBits->getSize());
for (size_t i = 0; i < aCorrectedBits->count(); i++)
QSharedPointer<std::vector<zxing::byte>> arrayOut(new std::vector<zxing::byte>(aCorrectedBits->getSize()));
for (size_t i = 0; i < aCorrectedBits->getSize(); i++)
{
arrayOut[i] = (zxing::byte)aCorrectedBits->get(i);
(*arrayOut)[i] = (zxing::byte)aCorrectedBits->get(i);
}
// std::printf("returning\n");
@ -352,7 +352,7 @@ QSharedPointer<BitArray> Decoder::correctBits(QSharedPointer<zxing::BitArray> ra
numECCodewords = NB_DATABLOCK[ddata_->getNBLayers()] - numDataCodewords;
}
QSharedPointer<std::vector<int>> dataWords(numCodewords_);
QSharedPointer<std::vector<int>> dataWords(new std::vector<int>(numCodewords_));
for (int i = 0; i < numCodewords_; i++)
{
@ -361,7 +361,7 @@ QSharedPointer<BitArray> Decoder::correctBits(QSharedPointer<zxing::BitArray> ra
{
if (rawbits->get(codewordSize_ * i + codewordSize_ - j + offset))
{
dataWords[i] += flag;
(*dataWords)[i] += flag;
}
flag <<= 1;
}
@ -402,7 +402,7 @@ QSharedPointer<BitArray> Decoder::correctBits(QSharedPointer<zxing::BitArray> ra
for (int j = 0; j < codewordSize_; j++)
{
bool color = (dataWords[i] & flag) == flag;
bool color = ((*dataWords)[i] & flag) == flag;
if (seriesCount == codewordSize_ - 1)
{

View File

@ -59,10 +59,10 @@ QSharedPointer<AztecDetectorResult> Detector::detect() {
QSharedPointer<BitMatrix> bits =
sampleGrid(image_,
corners[shift_%4],
corners[(shift_+3)%4],
corners[(shift_+2)%4],
corners[(shift_+1)%4]);
(*corners)[shift_%4],
(*corners)[(shift_+3)%4],
(*corners)[(shift_+2)%4],
(*corners)[(shift_+1)%4]);
// std::printf("------------\ndetected: compact:%s, nbDataBlocks:%d, nbLayers:%d\n------------\n",compact_?"YES":"NO", nbDataBlocks_, nbLayers_);
@ -168,11 +168,10 @@ Detector::getMatrixCornerPoints(std::vector<QSharedPointer<Point> > bullEyeCorne
throw ReaderException("matrix extends over image bounds");
}
std::vector< QSharedPointer<ResultPoint> >* array = new std::vector< QSharedPointer<ResultPoint> >();
vector< QSharedPointer<ResultPoint> >& returnValue (array->values());
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetax), float(targetay))));
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetbx), float(targetby))));
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetcx), float(targetcy))));
returnValue.push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetdx), float(targetdy))));
array->push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetax), float(targetay))));
array->push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetbx), float(targetby))));
array->push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetcx), float(targetcy))));
array->push_back(QSharedPointer<ResultPoint>(new ResultPoint(float(targetdx), float(targetdy))));
return QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >(array);
}
@ -197,7 +196,7 @@ void Detector::correctParameterData(QSharedPointer<zxing::BitArray> parameterDat
int flag = 1;
for (int j = 1; j <= codewordSize; j++) {
if (parameterData->get(codewordSize*i + codewordSize - j)) {
parameterWords[i] += flag;
(*parameterWords)[i] += flag;
}
flag <<= 1;
}
@ -217,7 +216,7 @@ void Detector::correctParameterData(QSharedPointer<zxing::BitArray> parameterDat
for (int i = 0; i < numDataCodewords; i++) {
int flag = 1;
for (int j = 1; j <= codewordSize; j++) {
if ((parameterWords[i] & flag) == flag) {
if (((*parameterWords)[i] & flag) == flag) {
parameterData->set(i*codewordSize+codewordSize-j);
}
flag <<= 1;
@ -449,10 +448,10 @@ bool Detector::isWhiteOrBlackRectangle(QSharedPointer<zxing::aztec::Point> p1,
QSharedPointer<zxing::aztec::Point> p4) {
int corr = 3;
p1 = new Point(p1->getX() - corr, p1->getY() + corr);
p2 = new Point(p2->getX() - corr, p2->getY() - corr);
p3 = new Point(p3->getX() + corr, p3->getY() - corr);
p4 = new Point(p4->getX() + corr, p4->getY() + corr);
p1.reset(new Point(p1->getX() - corr, p1->getY() + corr));
p2.reset(new Point(p2->getX() - corr, p2->getY() - corr));
p3.reset(new Point(p3->getX() + corr, p3->getY() - corr));
p4.reset(new Point(p4->getX() + corr, p4->getY() + corr));
int cInit = getColor(p4, p1);

View File

@ -39,7 +39,7 @@ BitMatrixParser::BitMatrixParser(QSharedPointer<BitMatrix> bitMatrix) : bitMatri
parsedVersion_ = readVersion(bitMatrix);
bitMatrix_ = extractDataRegion(bitMatrix);
readBitMatrix_ = new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight());
readBitMatrix_.reset(new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight()));
}
QSharedPointer<Version> BitMatrixParser::readVersion(QSharedPointer<BitMatrix> bitMatrix) {
@ -58,7 +58,7 @@ QSharedPointer<Version> BitMatrixParser::readVersion(QSharedPointer<BitMatrix> b
}
QSharedPointer<std::vector<zxing::byte>> BitMatrixParser::readCodewords() {
QSharedPointer<std::vector<zxing::byte>> result(parsedVersion_->getTotalCodewords());
QSharedPointer<std::vector<zxing::byte>> result(new std::vector<zxing::byte>(parsedVersion_->getTotalCodewords()));
int resultOffset = 0;
int row = 4;
int column = 0;
@ -75,22 +75,22 @@ QSharedPointer<std::vector<zxing::byte>> BitMatrixParser::readCodewords() {
do {
// Check the four corner cases
if ((row == numRows) && (column == 0) && !corner1Read) {
result[resultOffset++] = (zxing::byte) readCorner1(numRows, numColumns);
(*result)[resultOffset++] = (zxing::byte) readCorner1(numRows, numColumns);
row -= 2;
column +=2;
corner1Read = true;
} else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
result[resultOffset++] = (zxing::byte) readCorner2(numRows, numColumns);
(*result)[resultOffset++] = (zxing::byte) readCorner2(numRows, numColumns);
row -= 2;
column +=2;
corner2Read = true;
} else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
result[resultOffset++] = (zxing::byte) readCorner3(numRows, numColumns);
(*result)[resultOffset++] = (zxing::byte) readCorner3(numRows, numColumns);
row -= 2;
column +=2;
corner3Read = true;
} else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
result[resultOffset++] = (zxing::byte) readCorner4(numRows, numColumns);
(*result)[resultOffset++] = (zxing::byte) readCorner4(numRows, numColumns);
row -= 2;
column +=2;
corner4Read = true;
@ -98,7 +98,7 @@ QSharedPointer<std::vector<zxing::byte>> BitMatrixParser::readCodewords() {
// Sweep upward diagonally to the right
do {
if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) {
result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns);
(*result)[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns);
}
row -= 2;
column +=2;
@ -109,7 +109,7 @@ QSharedPointer<std::vector<zxing::byte>> BitMatrixParser::readCodewords() {
// Sweep downward diagonally to the left
do {
if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) {
result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns);
(*result)[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns);
}
row += 2;
column -=2;

View File

@ -58,7 +58,7 @@ std::vector<QSharedPointer<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<
for (int i = 0; i < ecBlock->getCount(); i++) {
int numDataCodewords = ecBlock->getDataCodewords();
int numBlockCodewords = ecBlocks->getECCodewords() + numDataCodewords;
QSharedPointer<std::vector<zxing::byte>> buffer(numBlockCodewords);
QSharedPointer<std::vector<zxing::byte>> buffer(new std::vector<zxing::byte>(numBlockCodewords));
QSharedPointer<DataBlock> blockRef(new DataBlock(numDataCodewords, buffer));
result[numResultBlocks++] = blockRef;
}
@ -86,19 +86,19 @@ std::vector<QSharedPointer<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<
int rawCodewordsOffset = 0;
for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (int j = 0; j < numResultBlocks; j++) {
result[j]->codewords_[i] = rawCodewords[rawCodewordsOffset++];
(*result[j]->codewords_)[i] = (*rawCodewords)[rawCodewordsOffset++];
}
}
// Fill out the last data block in the longer ones
for (int j = longerBlocksStartAt; j < numResultBlocks; j++) {
result[j]->codewords_[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
(*result[j]->codewords_)[shorterBlocksNumDataCodewords] = (*rawCodewords)[rawCodewordsOffset++];
}
// Now add in error correction blocks
int max = result[0]->codewords_->size();
for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
for (int j = 0; j < numResultBlocks; j++) {
int iOffset = j < longerBlocksStartAt ? i : i + 1;
result[j]->codewords_[iOffset] = rawCodewords[rawCodewordsOffset++];
(*result[j]->codewords_)[iOffset] = (*rawCodewords)[rawCodewordsOffset++];
}
}

View File

@ -44,9 +44,9 @@ Decoder::Decoder() : rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) {}
void Decoder::correctErrors(QSharedPointer<std::vector<zxing::byte>> codewordBytes, int numDataCodewords) {
int numCodewords = codewordBytes->size();
QSharedPointer<std::vector<int>> codewordInts(numCodewords);
QSharedPointer<std::vector<int>> codewordInts(new std::vector<int>(numCodewords));
for (int i = 0; i < numCodewords; i++) {
codewordInts[i] = codewordBytes[i] & 0xff;
(*codewordInts)[i] = (*codewordBytes)[i] & 0xff;
}
int numECCodewords = numCodewords - numDataCodewords;
try {
@ -58,7 +58,7 @@ void Decoder::correctErrors(QSharedPointer<std::vector<zxing::byte>> codewordByt
// Copy back into array of bytes -- only need to worry about the bytes that were data
// We don't care about errors in the error-correction codewords
for (int i = 0; i < numDataCodewords; i++) {
codewordBytes[i] = (zxing::byte)codewordInts[i];
(*codewordBytes)[i] = (zxing::byte)(*codewordInts)[i];
}
}
@ -79,7 +79,7 @@ QSharedPointer<DecoderResult> Decoder::decode(QSharedPointer<BitMatrix> bits) {
for (int i = 0; i < dataBlocksCount; i++) {
totalBytes += dataBlocks[i]->getNumDataCodewords();
}
QSharedPointer<std::vector<zxing::byte>> resultBytes(totalBytes);
QSharedPointer<std::vector<zxing::byte>> resultBytes(new std::vector<zxing::byte>(totalBytes));
// Error-correct and copy data blocks together into a stream of bytes
for (int j = 0; j < dataBlocksCount; j++) {
@ -89,7 +89,7 @@ QSharedPointer<DecoderResult> Decoder::decode(QSharedPointer<BitMatrix> bits) {
correctErrors(codewordBytes, numDataCodewords);
for (int i = 0; i < numDataCodewords; i++) {
// De-interlace data blocks.
resultBytes[i * dataBlocksCount + j] = codewordBytes[i];
(*resultBytes)[i * dataBlocksCount + j] = (*codewordBytes)[i];
}
}
// Decode the contents of that stream of bytes

View File

@ -61,8 +61,8 @@ class DecodedBitStreamParser {
static const char PUNCT_CHARS[];
static const char MIXED_CHARS[];
static QSharedPointer<std::vector<BigInteger> EXP900;
static QSharedPointer<std::vector<BigInteger> initEXP900();
static QSharedPointer<std::vector<BigInteger>> EXP900;
static QSharedPointer<std::vector<BigInteger>> initEXP900();
static int textCompaction(QSharedPointer<std::vector<int>> codewords, int codeIndex, QSharedPointer<String> result);
static void decodeTextCompaction(QSharedPointer<std::vector<int>> textCompactionData,

View File

@ -72,7 +72,7 @@ QSharedPointer<std::vector<int>> BitMatrixParser::readCodewords()
//int width = bitMatrix_->getWidth();
int height = bitMatrix_->getHeight();
erasures_ = new std::vector<int>(MAX_CW_CAPACITY);
erasures_.reset(new std::vector<int>(MAX_CW_CAPACITY));
QSharedPointer<std::vector<int>> codewords (new std::vector<int>(MAX_CW_CAPACITY));
int next = 0;
@ -129,14 +129,14 @@ int BitMatrixParser::processRow(int rowNumber, QSharedPointer<std::vector<int>>
if (eraseCount_ >= (int)erasures_->size()) {
throw FormatException("BitMatrixParser::processRow(PDF417): eraseCount too big!");
}
erasures_[eraseCount_] = next;
(*erasures_)[eraseCount_] = next;
next++;
eraseCount_++;
} else {
if (next >= codewords->size()) {
throw FormatException("BitMatrixParser::processRow(PDF417): codewords index out of bound.");
}
codewords[next++] = cw;
(*codewords)[next++] = cw;
}
} else {
// Left row indicator column
@ -154,10 +154,10 @@ int BitMatrixParser::processRow(int rowNumber, QSharedPointer<std::vector<int>>
// Right row indicator column is in codeword[next]
// Overwrite the last codeword i.e. Right Row Indicator
--next;
aRightColumnTriple_[rowNumber % 3] = codewords[next]; /* added 2012-06-22 hfn */
aRightColumnTriple_[rowNumber % 3] = (*codewords)[next]; /* added 2012-06-22 hfn */
if (rowNumber % 3 == 2) {
if (ecLevel_ < 0) {
rightColumnECData_ = codewords[next];
rightColumnECData_ = (*codewords)[next];
if (rightColumnECData_ == leftColumnECData_ && (int)leftColumnECData_ > 0) { /* leftColumnECData_ != 0 */
ecLevel_ = ((rightColumnECData_ % 30) - rows_ % 3) / 3;
}
@ -167,7 +167,7 @@ int BitMatrixParser::processRow(int rowNumber, QSharedPointer<std::vector<int>>
throw FormatException("BitMatrixParser::processRow(PDF417): outer columns corrupted!");
}
}
codewords[next] = 0;
(*codewords)[next] = 0;
}
return next;
}
@ -187,9 +187,9 @@ QSharedPointer<std::vector<int>> BitMatrixParser::trimArray(QSharedPointer<std::
throw IllegalArgumentException("BitMatrixParser::trimArray: negative size!");
}
// 2012-10-12 hfn don't throw "NoErrorException" when size == 0
QSharedPointer<std::vector<int>> a = new std::vector<int>(size);
QSharedPointer<std::vector<int>> a(new std::vector<int>(size));
for (int i = 0; i < size; i++) {
a[i] = array[i];
(*a)[i] = (*array)[i];
}
return a;
}

View File

@ -61,18 +61,18 @@ const char DecodedBitStreamParser::MIXED_CHARS[] = {
'\r', '\t', ',', ':', '#', '-', '.', '$', '/', '+', '%', '*',
'=', '^'};
QSharedPointer<std::vector<BigInteger> DecodedBitStreamParser::initEXP900() {
QSharedPointer<std::vector<BigInteger> EXP900 (16);
EXP900[0] = BigInteger(1);
QSharedPointer<std::vector<BigInteger>> DecodedBitStreamParser::initEXP900() {
QSharedPointer<std::vector<BigInteger>> EXP900 (new std::vector<BigInteger>(16));
(*EXP900)[0] = BigInteger(1);
BigInteger nineHundred (900);
EXP900[1] = nineHundred;
(*EXP900)[1] = nineHundred;
for (int i = 2; i < EXP900->size(); i++) {
EXP900[i] = EXP900[i - 1] * nineHundred;
(*EXP900)[i] = (*EXP900)[i - 1] * nineHundred;
}
return EXP900;
}
QSharedPointer<std::vector<BigInteger> DecodedBitStreamParser::EXP900 = initEXP900();
QSharedPointer<std::vector<BigInteger>> DecodedBitStreamParser::EXP900 = initEXP900();
DecodedBitStreamParser::DecodedBitStreamParser(){}
@ -84,8 +84,8 @@ QSharedPointer<DecoderResult> DecodedBitStreamParser::decode(QSharedPointer<std:
QSharedPointer<String> result (new String(100));
// Get compaction mode
int codeIndex = 1;
int code = codewords[codeIndex++];
while (codeIndex < codewords[0]) {
int code = (*codewords)[codeIndex++];
while (codeIndex < (*codewords)[0]) {
switch (code) {
case TEXT_COMPACTION_MODE_LATCH:
codeIndex = textCompaction(codewords, codeIndex, result);
@ -111,7 +111,7 @@ QSharedPointer<DecoderResult> DecodedBitStreamParser::decode(QSharedPointer<std:
break;
}
if (codeIndex < codewords->size()) {
code = codewords[codeIndex++];
code = (*codewords)[codeIndex++];
} else {
throw FormatException();
}
@ -133,22 +133,22 @@ int DecodedBitStreamParser::textCompaction(QSharedPointer<std::vector<int>> code
int codeIndex,
QSharedPointer<String> result) {
// 2 character per codeword
QSharedPointer<std::vector<int>> textCompactionData (codewords[0] << 1);
QSharedPointer<std::vector<int>> textCompactionData (new std::vector<int>((*codewords)[0] << 1));
// Used to hold the byte compaction value if there is a mode shift
QSharedPointer<std::vector<int>> byteCompactionData (codewords[0] << 1);
QSharedPointer<std::vector<int>> byteCompactionData (new std::vector<int>((*codewords)[0] << 1));
int index = 0;
bool end = false;
while ((codeIndex < codewords[0]) && !end) {
int code = codewords[codeIndex++];
while ((codeIndex < (*codewords)[0]) && !end) {
int code = (*codewords)[codeIndex++];
if (code < TEXT_COMPACTION_MODE_LATCH) {
textCompactionData[index] = code / 30;
textCompactionData[index + 1] = code % 30;
(*textCompactionData)[index] = code / 30;
(*textCompactionData)[index + 1] = code % 30;
index += 2;
} else {
switch (code) {
case TEXT_COMPACTION_MODE_LATCH:
textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH;
(*textCompactionData)[index++] = TEXT_COMPACTION_MODE_LATCH;
break;
case BYTE_COMPACTION_MODE_LATCH:
codeIndex--;
@ -165,9 +165,9 @@ int DecodedBitStreamParser::textCompaction(QSharedPointer<std::vector<int>> code
// after which the mode shall revert to the prevailing sub-mode
// of the Text Compaction mode. Codeword 913 is only available
// in Text Compaction mode; its use is described in 5.4.2.4.
textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE;
code = codewords[codeIndex++];
byteCompactionData[index] = code; //Integer.toHexString(code);
(*textCompactionData)[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE;
code = (*codewords)[codeIndex++];
(*byteCompactionData)[index] = code; //Integer.toHexString(code);
index++;
break;
case BYTE_COMPACTION_MODE_LATCH_6:
@ -210,7 +210,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointer<std::vector<int
Mode priorToShiftMode = ALPHA;
int i = 0;
while (i < length) {
int subModeCh = textCompactionData[i];
int subModeCh = (*textCompactionData)[i];
char ch = 0;
switch (subMode) {
case ALPHA:
@ -230,7 +230,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointer<std::vector<int
priorToShiftMode = subMode;
subMode = PUNCT_SHIFT;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((zxing::byte) byteCompactionData[i]);
result->append((zxing::byte) (*byteCompactionData)[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointer<std::vector<int
priorToShiftMode = subMode;
subMode = PUNCT_SHIFT;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((zxing::byte) byteCompactionData[i]);
result->append((zxing::byte) (*byteCompactionData)[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -280,7 +280,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointer<std::vector<int
priorToShiftMode = subMode;
subMode = PUNCT_SHIFT;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((zxing::byte) byteCompactionData[i]);
result->append((zxing::byte) (*byteCompactionData)[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -295,7 +295,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointer<std::vector<int
if (subModeCh == PAL) {
subMode = ALPHA;
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
result->append((zxing::byte) byteCompactionData[i]);
result->append((zxing::byte) (*byteCompactionData)[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -332,7 +332,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointer<std::vector<int
} else if (subModeCh == MODE_SHIFT_TO_BYTE_COMPACTION_MODE) {
// PS before Shift-to-Byte is used as a padding character,
// see 5.4.2.4 of the specification
result->append((zxing::byte) byteCompactionData[i]);
result->append((zxing::byte) (*byteCompactionData)[i]);
} else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) {
subMode = ALPHA;
}
@ -366,15 +366,15 @@ int DecodedBitStreamParser::byteCompaction(int mode,
// is not a multiple of 6
int count = 0;
int64_t value = 0;
QSharedPointer<std::vector<zxing::byte>> decodedData = new std::vector<zxing::byte>(6);
QSharedPointer<std::vector<int>> byteCompactedCodewords = new std::vector<int>(6);
QSharedPointer<std::vector<zxing::byte>> decodedData(new std::vector<zxing::byte>(6));
QSharedPointer<std::vector<int>> byteCompactedCodewords(new std::vector<int>(6));
bool end = false;
int nextCode = codewords[codeIndex++];
while ((codeIndex < codewords[0]) && !end) {
byteCompactedCodewords[count++] = nextCode;
int nextCode = (*codewords)[codeIndex++];
while ((codeIndex < (*codewords)[0]) && !end) {
(*byteCompactedCodewords)[count++] = nextCode;
// Base 900
value = 900 * value + nextCode;
nextCode = codewords[codeIndex++];
nextCode = (*codewords)[codeIndex++];
// perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH
if (nextCode == TEXT_COMPACTION_MODE_LATCH ||
nextCode == BYTE_COMPACTION_MODE_LATCH ||
@ -394,25 +394,25 @@ int DecodedBitStreamParser::byteCompaction(int mode,
// Convert to Base 256
for (int j = 0; j < 6; ++j)
{
decodedData[5 - j] = (zxing::byte) (value%256);
(*decodedData)[5 - j] = (zxing::byte) (value%256);
value >>= 8;
}
result->append(string((char*)&(decodedData->values()[0]), decodedData->values().size()));
result->append(string((char*)&((*decodedData)[0]), decodedData->size()));
count = 0;
}
}
}
// if the end of all codewords is reached the last codeword needs to be added
if (codeIndex == codewords[0] && nextCode < TEXT_COMPACTION_MODE_LATCH)
byteCompactedCodewords[count++] = nextCode;
if (codeIndex == (*codewords)[0] && nextCode < TEXT_COMPACTION_MODE_LATCH)
(*byteCompactedCodewords)[count++] = nextCode;
// If Byte Compaction mode is invoked with codeword 901,
// the last group of codewords is interpreted directly
// as one byte per codeword, without compaction.
for (int i = 0; i < count; i++)
{
result->append((zxing::byte)byteCompactedCodewords[i]);
result->append((zxing::byte)(*byteCompactedCodewords)[i]);
}
} else if (mode == BYTE_COMPACTION_MODE_LATCH_6) {
@ -421,8 +421,8 @@ int DecodedBitStreamParser::byteCompaction(int mode,
int count = 0;
int64_t value = 0;
bool end = false;
while (codeIndex < codewords[0] && !end) {
int code = codewords[codeIndex++];
while (codeIndex < (*codewords)[0] && !end) {
int code = (*codewords)[codeIndex++];
if (code < TEXT_COMPACTION_MODE_LATCH) {
count++;
// Base 900
@ -442,12 +442,12 @@ int DecodedBitStreamParser::byteCompaction(int mode,
if ((count % 5 == 0) && (count > 0)) {
// Decode every 5 codewords
// Convert to Base 256
QSharedPointer<std::vector<zxing::byte>> decodedData = new std::vector<zxing::byte>(6);
QSharedPointer<std::vector<zxing::byte>> decodedData(new std::vector<zxing::byte>(6));
for (int j = 0; j < 6; ++j) {
decodedData[5 - j] = (zxing::byte) (value & 0xFF);
(*decodedData)[5 - j] = (zxing::byte) (value & 0xFF);
value >>= 8;
}
result->append(string((char*)&decodedData[0],6));
result->append(string((char*)&(*decodedData)[0],6));
// 2012-11-27 hfn after recent java code/fix by srowen
count = 0;
}
@ -470,15 +470,15 @@ int DecodedBitStreamParser::numericCompaction(QSharedPointer<std::vector<int>> c
int count = 0;
bool end = false;
QSharedPointer<std::vector<int>> numericCodewords = new std::vector<int>(MAX_NUMERIC_CODEWORDS);
QSharedPointer<std::vector<int>> numericCodewords(new std::vector<int>(MAX_NUMERIC_CODEWORDS));
while (codeIndex < codewords[0] && !end) {
int code = codewords[codeIndex++];
if (codeIndex == codewords[0]) {
while (codeIndex < (*codewords)[0] && !end) {
int code = (*codewords)[codeIndex++];
if (codeIndex == (*codewords)[0]) {
end = true;
}
if (code < TEXT_COMPACTION_MODE_LATCH) {
numericCodewords[count] = code;
(*numericCodewords)[count] = code;
count++;
} else {
if (code == TEXT_COMPACTION_MODE_LATCH ||
@ -553,7 +553,7 @@ QSharedPointer<String> DecodedBitStreamParser::decodeBase900toBase10(QSharedPoin
{
BigInteger result = BigInteger(0);
for (int i = 0; i < count; i++) {
result = result + (EXP900[count - i - 1] * BigInteger(codewords[i]));
result = result + ((*EXP900)[count - i - 1] * BigInteger((*codewords)[i]));
}
string resultString = bigIntegerToString(result);
if (resultString[0] != '1') {

View File

@ -53,7 +53,7 @@ void ErrorCorrection::decode(QSharedPointer<std::vector<int>> received,
bool error = false;
for (int i = numECCodewords; i > 0; i--) {
int eval = poly->evaluateAt(field_.exp(i));
S[numECCodewords - i] = eval;
(*S)[numECCodewords - i] = eval;
if (eval != 0) {
error = true;
}
@ -63,11 +63,11 @@ void ErrorCorrection::decode(QSharedPointer<std::vector<int>> received,
QSharedPointer<ModulusPoly> knownErrors = field_.getOne();
for (int i=0;i<erasures->size();i++) {
int b = field_.exp(received->size() - 1 - erasures[i]);
int b = field_.exp(received->size() - 1 - (*erasures)[i]);
// Add (1 - bx) term:
QSharedPointer<std::vector<int>> one_minus_b_x(new std::vector<int>(2));
one_minus_b_x[1]=field_.subtract(0,b);
one_minus_b_x[0]=1;
(*one_minus_b_x)[1]=field_.subtract(0,b);
(*one_minus_b_x)[0]=1;
QSharedPointer<ModulusPoly> term (new ModulusPoly(field_,one_minus_b_x));
knownErrors = knownErrors->multiply(term);
}
@ -86,11 +86,11 @@ void ErrorCorrection::decode(QSharedPointer<std::vector<int>> received,
QSharedPointer<std::vector<int>> errorMagnitudes = findErrorMagnitudes(omega, sigma, errorLocations);
for (int i = 0; i < errorLocations->size(); i++) {
int position = received->size() - 1 - field_.log(errorLocations[i]);
int position = received->size() - 1 - field_.log((*errorLocations)[i]);
if (position < 0) {
throw ReedSolomonException("Bad error location!");
}
received[position] = field_.subtract(received[position], errorMagnitudes[i]);
(*received)[position] = field_.subtract((*received)[position], (*errorMagnitudes)[i]);
#if (defined (DEBUG) && defined _WIN32)
{
WCHAR szmsg[256];
@ -164,7 +164,7 @@ QSharedPointer<std::vector<int>> ErrorCorrection::findErrorLocations(QSharedPoin
int e = 0;
for (int i = 1; i < field_.getSize() && e < numErrors; i++) {
if (errorLocator->evaluateAt(i) == 0) {
result[e] = field_.inverse(i);
(*result)[e] = field_.inverse(i);
e++;
}
}
@ -195,7 +195,7 @@ QSharedPointer<std::vector<int>> ErrorCorrection::findErrorMagnitudes(QSharedPoi
int errorLocatorDegree = errorLocator->getDegree();
QSharedPointer<std::vector<int>> formalDerivativeCoefficients (new std::vector<int>(errorLocatorDegree));
for (i = 1; i <= errorLocatorDegree; i++) {
formalDerivativeCoefficients[errorLocatorDegree - i] =
(*formalDerivativeCoefficients)[errorLocatorDegree - i] =
field_.multiply(i, errorLocator->getCoefficient(i));
}
QSharedPointer<ModulusPoly> formalDerivative (new ModulusPoly(field_, formalDerivativeCoefficients));
@ -204,10 +204,10 @@ QSharedPointer<std::vector<int>> ErrorCorrection::findErrorMagnitudes(QSharedPoi
int s = errorLocations->size();
QSharedPointer<std::vector<int>> result ( new std::vector<int>(s));
for (i = 0; i < s; i++) {
int xiInverse = field_.inverse(errorLocations[i]);
int xiInverse = field_.inverse((*errorLocations)[i]);
int numerator = field_.subtract(0, errorEvaluator->evaluateAt(xiInverse));
int denominator = field_.inverse(formalDerivative->evaluateAt(xiInverse));
result[i] = field_.multiply(numerator, denominator);
(*result)[i] = field_.multiply(numerator, denominator);
}
return result;
}

View File

@ -40,21 +40,22 @@ ModulusGF ModulusGF::PDF417_GF(929,3);
ModulusGF::ModulusGF(int modulus, int generator)
: modulus_(modulus) {
expTable_ = new std::vector<int>(modulus_);
logTable_ = new std::vector<int>(modulus_);
expTable_.reset(new std::vector<int>(modulus_));
logTable_.reset(new std::vector<int>(modulus_));
int x = 1,i;
for (i = 0; i < modulus_; i++) {
expTable_[i] = x;
(*expTable_)[i] = x;
x = (x * generator) % modulus_;
}
for (i = 0; i < modulus_-1; i++) {
logTable_[expTable_[i]] = i;
(*logTable_)[(*expTable_)[i]] = i;
}
// logTable[0] == 0 but this should never be used
QSharedPointer<std::vector<int>>aZero(new std::vector<int>(1)),aOne(new std::vector<int>(1));
aZero[0]=0;aOne[0]=1;
zero_ = new ModulusPoly(*this, aZero);
one_ = new ModulusPoly(*this, aOne);
(*aZero)[0]=0;
(*aOne)[0]=1;
zero_.reset(new ModulusPoly(*this, aZero));
one_.reset(new ModulusPoly(*this, aOne));
}
QSharedPointer<ModulusPoly> ModulusGF::getZero() {
@ -75,7 +76,7 @@ QSharedPointer<ModulusPoly> ModulusGF::buildMonomial(int degree, int coefficient
}
int nCoefficients = degree + 1;
QSharedPointer<std::vector<int>> coefficients (new std::vector<int>(nCoefficients));
coefficients[0] = coefficient;
(*coefficients)[0] = coefficient;
QSharedPointer<ModulusPoly> result(new ModulusPoly(*this,coefficients));
return result;
}
@ -91,28 +92,28 @@ int ModulusGF::subtract(int a, int b) {
}
int ModulusGF::exp(int a) {
return expTable_[a];
return (*expTable_)[a];
}
int ModulusGF::log(int a) {
if (a == 0) {
throw IllegalArgumentException("log of zero!");
}
return logTable_[a];
return (*logTable_)[a];
}
int ModulusGF::inverse(int a) {
if (a == 0) {
throw IllegalArgumentException("inverse of zero!");;
}
return expTable_[modulus_ - logTable_[a] - 1];
return (*expTable_)[modulus_ - (*logTable_)[a] - 1];
}
int ModulusGF::multiply(int a, int b) {
if (a == 0 || b == 0) {
return 0;
}
return expTable_[(logTable_[a] + logTable_[b]) % (modulus_ - 1)];
return (*expTable_)[((*logTable_)[a] + (*logTable_)[b]) % (modulus_ - 1)];
}
int ModulusGF::getSize() {

View File

@ -37,11 +37,11 @@ ModulusPoly::ModulusPoly(ModulusGF &field, QSharedPointer<std::vector<int>> coef
throw IllegalArgumentException("no coefficients!");
}
int coefficientsLength = coefficients->size();
if (coefficientsLength > 1 && coefficients[0] == 0)
if (coefficientsLength > 1 && (*coefficients)[0] == 0)
{
// Leading term must be non-zero for anything except the constant polynomial "0"
int firstNonZero = 1;
while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0)
while (firstNonZero < coefficientsLength && (*coefficients)[firstNonZero] == 0)
{
firstNonZero++;
}
@ -58,7 +58,7 @@ ModulusPoly::ModulusPoly(ModulusGF &field, QSharedPointer<std::vector<int>> coef
coefficients_.reset(new std::vector<int>(coefficientsLength));
for (int i = 0; i < coefficientsLength; i++)
{
coefficients_[i] = c[i + firstNonZero];
(*coefficients_)[i] = (*c)[i + firstNonZero];
}
/*
coefficientsLength -= firstNonZero;
@ -93,7 +93,7 @@ int ModulusPoly::getDegree()
*/
bool ModulusPoly::isZero()
{
return coefficients_[0] == 0;
return (*coefficients_)[0] == 0;
}
/**
@ -101,7 +101,7 @@ bool ModulusPoly::isZero()
*/
int ModulusPoly::getCoefficient(int degree)
{
return coefficients_[coefficients_->size() - 1 - degree];
return (*coefficients_)[coefficients_->size() - 1 - degree];
}
/**
@ -122,14 +122,14 @@ int ModulusPoly::evaluateAt(int a)
int result = 0;
for (i = 0; i < size; i++)
{
result = field_.add(result, coefficients_[i]);
result = field_.add(result, (*coefficients_)[i]);
}
return result;
}
int result = coefficients_[0];
int result = (*coefficients_)[0];
for (i = 1; i < size; i++)
{
result = field_.add(field_.multiply(a, result), coefficients_[i]);
result = field_.add(field_.multiply(a, result), (*coefficients_)[i]);
}
return result;
}
@ -162,12 +162,12 @@ QSharedPointer<ModulusPoly> ModulusPoly::add(QSharedPointer<ModulusPoly> other)
// Copy high-order terms only found in higher-degree polynomial's coefficients
for (int i = 0; i < lengthDiff; i++)
{
sumDiff[i] = largerCoefficients[i];
(*sumDiff)[i] = (*largerCoefficients)[i];
}
for (int i = lengthDiff; i < largerCoefficients->size(); i++)
{
sumDiff[i] = field_.add(smallerCoefficients[i - lengthDiff], largerCoefficients[i]);
(*sumDiff)[i] = field_.add((*smallerCoefficients)[i - lengthDiff], (*largerCoefficients)[i]);
}
return QSharedPointer<ModulusPoly>(new ModulusPoly(field_, sumDiff));
@ -204,10 +204,10 @@ QSharedPointer<ModulusPoly> ModulusPoly::multiply(QSharedPointer<ModulusPoly> ot
QSharedPointer<std::vector<int>> product(new std::vector<int>(aLength + bLength - 1));
for (i = 0; i < aLength; i++)
{
int aCoeff = aCoefficients[i];
int aCoeff = (*aCoefficients)[i];
for (j = 0; j < bLength; j++)
{
product[i + j] = field_.add(product[i + j], field_.multiply(aCoeff, bCoefficients[j]));
(*product)[i + j] = field_.add((*product)[i + j], field_.multiply(aCoeff, (*bCoefficients)[j]));
}
}
return QSharedPointer<ModulusPoly>(new ModulusPoly(field_, product));
@ -219,7 +219,7 @@ QSharedPointer<ModulusPoly> ModulusPoly::negative()
QSharedPointer<std::vector<int>> negativeCoefficients(new std::vector<int>(size));
for (int i = 0; i < size; i++)
{
negativeCoefficients[i] = field_.subtract(0, coefficients_[i]);
(*negativeCoefficients)[i] = field_.subtract(0, (*coefficients_)[i]);
}
return QSharedPointer<ModulusPoly>(new ModulusPoly(field_, negativeCoefficients));
}
@ -238,7 +238,7 @@ QSharedPointer<ModulusPoly> ModulusPoly::multiply(int scalar)
QSharedPointer<std::vector<int>> product(new std::vector<int>(size));
for (int i = 0; i < size; i++)
{
product[i] = field_.multiply(coefficients_[i], scalar);
(*product)[i] = field_.multiply((*coefficients_)[i], scalar);
}
return QSharedPointer<ModulusPoly>(new ModulusPoly(field_, product));
}
@ -257,7 +257,7 @@ QSharedPointer<ModulusPoly> ModulusPoly::multiplyByMonomial(int degree, int coef
QSharedPointer<std::vector<int>> product(new std::vector<int>(size + degree));
for (int i = 0; i < size; i++)
{
product[i] = field_.multiply(coefficients_[i], coefficient);
(*product)[i] = field_.multiply((*coefficients_)[i], coefficient);
}
return QSharedPointer<ModulusPoly>(new ModulusPoly(field_, product));
}

View File

@ -106,24 +106,24 @@ QSharedPointer<DetectorResult> Detector::detect(DecodeHints const& hints) {
throw NotFoundException("Bad module width.");
}
int dimension = computeDimension(vertices[12], vertices[14],
vertices[13], vertices[15], moduleWidth);
int dimension = computeDimension((*vertices)[12], (*vertices)[14],
(*vertices)[13], (*vertices)[15], moduleWidth);
if (dimension < 1) {
throw NotFoundException("Bad dimension.");
}
int yDimension = max(computeYDimension(vertices[12], vertices[14],
vertices[13], vertices[15], moduleWidth), dimension);
int yDimension = max(computeYDimension((*vertices)[12], (*vertices)[14],
(*vertices)[13], (*vertices)[15], moduleWidth), dimension);
// Deskew and sample lines from image.
QSharedPointer<BitMatrix> linesMatrix = sampleLines(vertices, dimension, yDimension);
QSharedPointer<BitMatrix> linesGrid(LinesSampler(linesMatrix, dimension).sample());
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > points(4);
points[0] = vertices[5];
points[1] = vertices[4];
points[2] = vertices[6];
points[3] = vertices[7];
QSharedPointer<std::vector<QSharedPointer<ResultPoint>>> points(new std::vector<QSharedPointer<ResultPoint>>(4));
(*points)[0] = (*vertices)[5];
(*points)[1] = (*vertices)[4];
(*points)[2] = (*vertices)[6];
(*points)[3] = (*vertices)[7];
return QSharedPointer<DetectorResult>(new DetectorResult(linesGrid, points));
}
@ -148,7 +148,7 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
const int height = matrix->getHeight();
const int width = matrix->getWidth();
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > result(16);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>>> result(new std::vector<QSharedPointer<ResultPoint>>(16));
bool found = false;
QSharedPointer<std::vector<int>> counters(new std::vector<int>(START_PATTERN_LENGTH));
@ -158,8 +158,8 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
QSharedPointer<std::vector<int>> loc = findGuardPattern(matrix, 0, i, width, false, START_PATTERN,
START_PATTERN_LENGTH, counters);
if (loc) {
result[0] = new ResultPoint((float)loc[0], (float)i);
result[4] = new ResultPoint((float)loc[1], (float)i);
(*result)[0].reset(new ResultPoint((float)(*loc)[0], (float)i));
(*result)[4].reset(new ResultPoint((float)(*loc)[1], (float)i));
found = true;
break;
}
@ -171,15 +171,15 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
QSharedPointer<std::vector<int>> loc = findGuardPattern(matrix, 0, i, width, false, START_PATTERN,
START_PATTERN_LENGTH, counters);
if (loc) {
result[1] = new ResultPoint((float)loc[0], (float)i);
result[5] = new ResultPoint((float)loc[1], (float)i);
(*result)[1].reset(new ResultPoint((float)(*loc)[0], (float)i));
(*result)[5].reset(new ResultPoint((float)(*loc)[1], (float)i));
found = true;
break;
}
}
}
counters = new std::vector<int>(STOP_PATTERN_LENGTH);
counters.reset(new std::vector<int>(STOP_PATTERN_LENGTH));
// Top right
if (found) { // Found the Bottom Left vertex
@ -188,8 +188,8 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
QSharedPointer<std::vector<int>> loc = findGuardPattern(matrix, 0, i, width, false, STOP_PATTERN,
STOP_PATTERN_LENGTH, counters);
if (loc) {
result[2] = new ResultPoint((float)loc[1], (float)i);
result[6] = new ResultPoint((float)loc[0], (float)i);
(*result)[2].reset(new ResultPoint((float)(*loc)[1], (float)i));
(*result)[6].reset(new ResultPoint((float)(*loc)[0], (float)i));
found = true;
break;
}
@ -202,8 +202,8 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
QSharedPointer<std::vector<int>> loc = findGuardPattern(matrix, 0, i, width, false, STOP_PATTERN,
STOP_PATTERN_LENGTH, counters);
if (loc) {
result[3] = new ResultPoint((float)loc[1], (float)i);
result[7] = new ResultPoint((float)loc[0], (float)i);
(*result)[3].reset(new ResultPoint((float)(*loc)[1], (float)i));
(*result)[7].reset(new ResultPoint((float)(*loc)[0], (float)i));
found = true;
break;
}
@ -218,10 +218,10 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
const int width = matrix->getWidth();
const int halfWidth = width >> 1;
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > result(16);
QSharedPointer<std::vector<QSharedPointer<ResultPoint>>> result(new std::vector<QSharedPointer<ResultPoint>>(16));
bool found = false;
QSharedPointer<std::vector<int>> counters = new std::vector<int>(START_PATTERN_REVERSE_LENGTH);
QSharedPointer<std::vector<int>> counters(new std::vector<int>(START_PATTERN_REVERSE_LENGTH));
// Top Left
for (int i = height - 1; i > 0; i -= rowStep) {
@ -229,8 +229,8 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE,
START_PATTERN_REVERSE_LENGTH, counters);
if (loc) {
result[0] = new ResultPoint((float)loc[1], (float)i);
result[4] = new ResultPoint((float)loc[0], (float)i);
(*result)[0].reset(new ResultPoint((float)(*loc)[1], (float)i));
(*result)[4].reset(new ResultPoint((float)(*loc)[0], (float)i));
found = true;
break;
}
@ -243,15 +243,15 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE,
START_PATTERN_REVERSE_LENGTH, counters);
if (loc) {
result[1] = new ResultPoint((float)loc[1], (float)i);
result[5] = new ResultPoint((float)loc[0], (float)i);
(*result)[1].reset(new ResultPoint((float)(*loc)[1], (float)i));
(*result)[5].reset(new ResultPoint((float)(*loc)[0], (float)i));
found = true;
break;
}
}
}
counters = new std::vector<int>(STOP_PATTERN_REVERSE_LENGTH);
counters.reset(new std::vector<int>(STOP_PATTERN_REVERSE_LENGTH));
// Top Right
if (found) { // Found the Bottom Left vertex
@ -260,8 +260,8 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
QSharedPointer<std::vector<int>> loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE,
STOP_PATTERN_REVERSE_LENGTH, counters);
if (loc) {
result[2] = new ResultPoint((float)loc[0], (float)i);
result[6] = new ResultPoint((float)loc[1], (float)i);
(*result)[2].reset(new ResultPoint((float)(*loc)[0], (float)i));
(*result)[6].reset(new ResultPoint((float)(*loc)[1], (float)i));
found = true;
break;
}
@ -274,8 +274,8 @@ QSharedPointer<std::vector<QSharedPointer<ResultPoint>> > Detector::findVertices
QSharedPointer<std::vector<int>> loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE,
STOP_PATTERN_REVERSE_LENGTH, counters);
if (loc) {
result[3] = new ResultPoint((float)loc[0], (float)i);
result[7] = new ResultPoint((float)loc[1], (float)i);
(*result)[3].reset(new ResultPoint((float)(*loc)[0], (float)i));
(*result)[7].reset(new ResultPoint((float)(*loc)[1], (float)i));
found = true;
break;
}
@ -303,7 +303,7 @@ QSharedPointer<std::vector<int>> Detector::findGuardPattern(QSharedPointer<BitMa
const int pattern[],
int patternSize,
QSharedPointer<std::vector<int>>& counters) {
counters->values().assign(counters->size(), 0);
counters->assign(counters->size(), 0);
int patternLength = patternSize;
bool isWhite = whiteFirst;
@ -312,26 +312,26 @@ QSharedPointer<std::vector<int>> Detector::findGuardPattern(QSharedPointer<BitMa
for (int x = column; x < column + width; x++) {
bool pixel = matrix->get(x, row);
if (pixel ^ isWhite) {
counters[counterPosition]++;
(*counters)[counterPosition]++;
} else {
if (counterPosition == patternLength - 1) {
if (patternMatchVariance(counters, pattern,
MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
QSharedPointer<std::vector<int>> result = new std::vector<int>(2);
result[0] = patternStart;
result[1] = x;
QSharedPointer<std::vector<int>> result(new std::vector<int>(2));
(*result)[0] = patternStart;
(*result)[1] = x;
return result;
}
patternStart += counters[0] + counters[1];
patternStart += (*counters)[0] + (*counters)[1];
for(int i = 0; i < patternLength - 2; ++i)
counters[i] = counters[ i + 2];
counters[patternLength - 2] = 0;
counters[patternLength - 1] = 0;
(*counters)[i] = (*counters)[ i + 2];
(*counters)[patternLength - 2] = 0;
(*counters)[patternLength - 1] = 0;
counterPosition--;
} else {
counterPosition++;
}
counters[counterPosition] = 1;
(*counters)[counterPosition] = 1;
isWhite = !isWhite;
}
}
@ -361,7 +361,7 @@ int Detector::patternMatchVariance(QSharedPointer<std::vector<int>>& counters,
int total = 0;
int patternLength = 0;
for (int i = 0; i < numCounters; i++) {
total += counters[i];
total += (*counters)[i];
patternLength += pattern[i];
}
if (total < patternLength) {
@ -377,7 +377,7 @@ int Detector::patternMatchVariance(QSharedPointer<std::vector<int>>& counters,
int totalVariance = 0;
for (int x = 0; x < numCounters; x++) {
int counter = counters[x] << 8;
int counter = (*counters)[x] << 8;
int scaledPattern = pattern[x] * unitBarWidth;
int variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter;
if (variance > maxIndividualVariance) {
@ -409,8 +409,8 @@ void Detector::correctVertices(QSharedPointer<BitMatrix> matrix,
QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >& vertices,
bool upsideDown)
{
bool isLowLeft = abs(vertices[4]->getY() - vertices[5]->getY()) < 20.0;
bool isLowRight = abs(vertices[6]->getY() - vertices[7]->getY()) < 20.0;
bool isLowLeft = abs((*vertices)[4]->getY() - (*vertices)[5]->getY()) < 20.0;
bool isLowRight = abs((*vertices)[6]->getY() - (*vertices)[7]->getY()) < 20.0;
if (isLowLeft || isLowRight) {
throw NotFoundException("Cannot find enough PDF417 guard patterns!");
} else {
@ -449,8 +449,8 @@ void Detector::findWideBarTopBottom(QSharedPointer<BitMatrix> matrix,
int lenPattern,
int rowStep)
{
QSharedPointer<ResultPoint> verticeStart(vertices[offsetVertice]);
QSharedPointer<ResultPoint> verticeEnd(vertices[offsetVertice + 4]);
QSharedPointer<ResultPoint> verticeStart((*vertices)[offsetVertice]);
QSharedPointer<ResultPoint> verticeEnd((*vertices)[offsetVertice + 4]);
// Start horizontally at the middle of the bar.
int endWideBar = startWideBar + lenWideBar;
@ -496,7 +496,7 @@ void Detector::findWideBarTopBottom(QSharedPointer<BitMatrix> matrix,
}
}
vertices[offsetVertice + 8] = new ResultPoint((float)x, (float)y);
(*vertices)[offsetVertice + 8].reset(new ResultPoint((float)x, (float)y));
}
/**
@ -518,10 +518,10 @@ void Detector::findCrossingPoint(QSharedPointer<std::vector<QSharedPointer<Resul
int idxLineB1, int idxLineB2,
QSharedPointer<BitMatrix>& matrix)
{
Point p1(vertices[idxLineA1]->getX(), vertices[idxLineA1]->getY());
Point p2(vertices[idxLineA2]->getX(), vertices[idxLineA2]->getY());
Point p3(vertices[idxLineB1]->getX(), vertices[idxLineB1]->getY());
Point p4(vertices[idxLineB2]->getX(), vertices[idxLineB2]->getY());
Point p1((*vertices)[idxLineA1]->getX(), (*vertices)[idxLineA1]->getY());
Point p2((*vertices)[idxLineA2]->getX(), (*vertices)[idxLineA2]->getY());
Point p3((*vertices)[idxLineB1]->getX(), (*vertices)[idxLineB1]->getY());
Point p4((*vertices)[idxLineB2]->getX(), (*vertices)[idxLineB2]->getY());
Point result(intersection(Line(p1, p2), Line(p3, p4)));
if (result.x == numeric_limits<float>::infinity() ||
@ -535,7 +535,7 @@ void Detector::findCrossingPoint(QSharedPointer<std::vector<QSharedPointer<Resul
throw NotFoundException("PDF:Detector: crossing points out of region!");
}
vertices[idxResult] = QSharedPointer<ResultPoint>(new ResultPoint(result.x, result.y));
(*vertices)[idxResult] = QSharedPointer<ResultPoint>(new ResultPoint(result.x, result.y));
}
/**
@ -576,11 +576,11 @@ Point Detector::intersection(Line a, Line b) {
* @return the module size.
*/
float Detector::computeModuleWidth(QSharedPointer<std::vector<QSharedPointer<ResultPoint>> >& vertices) {
float pixels1 = ResultPoint::distance(vertices[0], vertices[4]);
float pixels2 = ResultPoint::distance(vertices[1], vertices[5]);
float pixels1 = ResultPoint::distance((*vertices)[0], (*vertices)[4]);
float pixels2 = ResultPoint::distance((*vertices)[1], (*vertices)[5]);
float moduleWidth1 = (pixels1 + pixels2) / (17 * 2.0f);
float pixels3 = ResultPoint::distance(vertices[6], vertices[2]);
float pixels4 = ResultPoint::distance(vertices[7], vertices[3]);
float pixels3 = ResultPoint::distance((*vertices)[6], (*vertices)[2]);
float pixels4 = ResultPoint::distance((*vertices)[7], (*vertices)[3]);
float moduleWidth2 = (pixels3 + pixels4) / (18 * 2.0f);
return (moduleWidth1 + moduleWidth2) / 2.0f;
}
@ -651,10 +651,10 @@ QSharedPointer<BitMatrix> Detector::sampleLines(QSharedPointer<std::vector<QShar
(float)sampleDimensionX, 0.0f,
0.0f, (float)sampleDimensionY,
(float)sampleDimensionX, (float)sampleDimensionY,
vertices[12]->getX(), vertices[12]->getY(),
vertices[14]->getX(), vertices[14]->getY(),
vertices[13]->getX(), vertices[13]->getY(),
vertices[15]->getX(), vertices[15]->getY()));
(*vertices)[12]->getX(), (*vertices)[12]->getY(),
(*vertices)[14]->getX(), (*vertices)[14]->getY(),
(*vertices)[13]->getX(), (*vertices)[13]->getY(),
(*vertices)[15]->getX(), (*vertices)[15]->getY()));
QSharedPointer<BitMatrix> linesMatrix = GridSampler::getInstance().sampleGrid(
image_->getBlackMatrix(), sampleDimensionX, sampleDimensionY, transform);

View File

@ -53,14 +53,14 @@ std::vector<QSharedPointer<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<
vector<ECB*> ecBlockArray = ecBlocks.getECBlocks();
// Now establish DataBlocks of the appropriate size and number of data codewords
std::vector<QSharedPointer<DataBlock> > result(totalBlocks);
std::vector<QSharedPointer<DataBlock>> result(totalBlocks);
int numResultBlocks = 0;
for (size_t j = 0; j < ecBlockArray.size(); j++) {
ECB *ecBlock = ecBlockArray[j];
for (int i = 0; i < ecBlock->getCount(); i++) {
int numDataCodewords = ecBlock->getDataCodewords();
int numBlockCodewords = ecBlocks.getECCodewordsPerBloc() + numDataCodewords;
QSharedPointer<std::vector<zxing::byte>> buffer(numBlockCodewords);
QSharedPointer<std::vector<zxing::byte>> buffer(new std::vector<zxing::byte>(numBlockCodewords));
QSharedPointer<DataBlock> blockRef(new DataBlock(numDataCodewords, buffer));
result[numResultBlocks++] = blockRef;
}
@ -88,19 +88,19 @@ std::vector<QSharedPointer<DataBlock> > DataBlock::getDataBlocks(QSharedPointer<
int rawCodewordsOffset = 0;
for (int i = 0; i < shorterBlocksNumDataCodewords; i++) {
for (int j = 0; j < numResultBlocks; j++) {
result[j]->codewords_[i] = rawCodewords[rawCodewordsOffset++];
(*result[j]->codewords_)[i] = (*rawCodewords)[rawCodewordsOffset++];
}
}
// Fill out the last data block in the longer ones
for (int j = longerBlocksStartAt; j < numResultBlocks; j++) {
result[j]->codewords_[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++];
(*result[j]->codewords_)[shorterBlocksNumDataCodewords] = (*rawCodewords)[rawCodewordsOffset++];
}
// Now add in error correction blocks
int max = result[0]->codewords_->size();
for (int i = shorterBlocksNumDataCodewords; i < max; i++) {
for (int j = 0; j < numResultBlocks; j++) {
int iOffset = j < longerBlocksStartAt ? i : i + 1;
result[j]->codewords_[iOffset] = rawCodewords[rawCodewordsOffset++];
(*result[j]->codewords_)[iOffset] = (*rawCodewords)[rawCodewordsOffset++];
}
}

View File

@ -186,7 +186,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(QSharedPointer<BitSource>
string& result,
int count,
CharacterSetECI const * currentCharacterSetECI,
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>> >& byteSegments,
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>>>>& byteSegments,
Hashtable const& hints) {
int nBytes = count;
BitSource& bits (*bits_);
@ -195,7 +195,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(QSharedPointer<BitSource>
throw FormatException();
}
QSharedPointer<std::vector<zxing::byte>> bytes_ (count);
QSharedPointer<std::vector<zxing::byte>> bytes_ (new std::vector<zxing::byte>(count));
byte* readBytes = &(*bytes_)[0];
for (int i = 0; i < count; i++) {
readBytes[i] = (zxing::byte) bits.readBits(8);
@ -217,7 +217,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(QSharedPointer<BitSource>
(void)ignored;
throw FormatException();
}
byteSegments->values().push_back(bytes_);
byteSegments->push_back(bytes_);
return encoding;
}
@ -359,7 +359,7 @@ DecodedBitStreamParser::decode(QSharedPointer<std::vector<zxing::byte>> bytes,
BitSource& bits (*bits_);
string result;
result.reserve(50);
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>> > byteSegments (0);
QSharedPointer<std::vector< QSharedPointer<std::vector<zxing::byte>>>> byteSegments (0);
const CharacterSetECI* currentCharacterSetECI = 0;
string charSet = "";
try {

View File

@ -47,10 +47,10 @@ namespace zxing
void Decoder::correctErrors(QSharedPointer<std::vector<zxing::byte>> codewordBytes, int numDataCodewords)
{
int numCodewords = codewordBytes->size();
QSharedPointer<std::vector<int>> codewordInts(numCodewords);
QSharedPointer<std::vector<int>> codewordInts(new std::vector<int>(numCodewords));
for (int i = 0; i < numCodewords; i++)
{
codewordInts[i] = codewordBytes[i] & 0xff;
(*codewordInts)[i] = (*codewordBytes)[i] & 0xff;
}
int numECCodewords = numCodewords - numDataCodewords;
@ -66,7 +66,7 @@ namespace zxing
for (int i = 0; i < numDataCodewords; i++)
{
codewordBytes[i] = (zxing::byte)codewordInts[i];
(*codewordBytes)[i] = (zxing::byte)(*codewordInts)[i];
}
}
@ -92,7 +92,7 @@ namespace zxing
{
totalBytes += dataBlocks[i]->getNumDataCodewords();
}
QSharedPointer<std::vector<zxing::byte>> resultBytes(totalBytes);
QSharedPointer<std::vector<zxing::byte>> resultBytes(new std::vector<zxing::byte>(totalBytes));
int resultOffset = 0;
// Error-correct and copy data blocks together into a stream of bytes
@ -104,7 +104,7 @@ namespace zxing
correctErrors(codewordBytes, numDataCodewords);
for (int i = 0; i < numDataCodewords; i++)
{
resultBytes[resultOffset++] = (zxing::byte)codewordBytes[i];
(*resultBytes)[resultOffset++] = (zxing::byte)(*codewordBytes)[i];
}
}

View File

@ -36,7 +36,7 @@ private:
static int MAX_MODULES;
QSharedPointer<BitMatrix> image_;
std::vector<AlignmentPattern *> *possibleCenters_;
std::vector<QSharedPointer<AlignmentPattern>> *possibleCenters_;
int startX_;
int startY_;
int width_;

View File

@ -127,9 +127,8 @@ QSharedPointer<AlignmentPattern> AlignmentPatternFinder::handlePossibleCenter(ve
return center->combineEstimate(centerI, centerJ, estimatedModuleSize);
}
}
AlignmentPattern *tmp = new AlignmentPattern(centerJ, centerI, estimatedModuleSize);
QSharedPointer<AlignmentPattern> tmp(new AlignmentPattern(centerJ, centerI, estimatedModuleSize));
// Hadn't found this before; save it
tmp->retain();
possibleCenters_->push_back(tmp);
if (callback_ != 0)
{
@ -142,7 +141,7 @@ QSharedPointer<AlignmentPattern> AlignmentPatternFinder::handlePossibleCenter(ve
AlignmentPatternFinder::AlignmentPatternFinder(QSharedPointer<BitMatrix> image, int startX, int startY, int width,
int height, float moduleSize,
QSharedPointer<ResultPointCallback> const &callback) : image_(image), possibleCenters_(new vector<AlignmentPattern *>()), startX_(startX), startY_(startY),
QSharedPointer<ResultPointCallback> const &callback) : image_(image), possibleCenters_(new vector<QSharedPointer<AlignmentPattern>>()), startX_(startX), startY_(startY),
width_(width), height_(height), moduleSize_(moduleSize), callback_(callback)
{
}
@ -151,7 +150,7 @@ AlignmentPatternFinder::~AlignmentPatternFinder()
{
for (int i = 0; i < int(possibleCenters_->size()); i++)
{
(*possibleCenters_)[i]->release();
(*possibleCenters_)[i].clear();
(*possibleCenters_)[i] = 0;
}
delete possibleCenters_;

View File

@ -27,8 +27,8 @@ public:
QSharedPointer<std::vector<zxing::byte>> getErrorCorrectionBytes() { return errorCorrection_; }
BlockPair& operator=(const BlockPair &other) {
data_->release();
errorCorrection_->release();
data_->clear();
errorCorrection_->clear();
data_ = other.data_;
errorCorrection_ = other.errorCorrection_;

View File

@ -49,7 +49,7 @@ std::string QRCode::toString() const
result << mode_.getName();
result << "\n ecLevel: ";
if(!ecLevel_ptr_.empty())
if(!ecLevel_ptr_.isNull())
result << ecLevel_ptr_->name();
else
result << "null";