mirror of https://github.com/status-im/qzxing.git
change array to vector
This commit is contained in:
parent
d48a139d03
commit
a892b38bf3
|
@ -167,7 +167,7 @@ Detector::getMatrixCornerPoints(std::vector<Ref<Point> > bullEyeCornerPoints) {
|
|||
!isValid(targetdx, targetdy)) {
|
||||
throw ReaderException("matrix extends over image bounds");
|
||||
}
|
||||
Array< Ref<ResultPoint> >* array = new Array< Ref<ResultPoint> >();
|
||||
std::vector< Ref<ResultPoint> >* array = new std::vector< Ref<ResultPoint> >();
|
||||
vector< Ref<ResultPoint> >& returnValue (array->values());
|
||||
returnValue.push_back(Ref<ResultPoint>(new ResultPoint(float(targetax), float(targetay))));
|
||||
returnValue.push_back(Ref<ResultPoint>(new ResultPoint(float(targetbx), float(targetby))));
|
||||
|
@ -190,7 +190,7 @@ void Detector::correctParameterData(Ref<zxing::BitArray> parameterData, bool com
|
|||
|
||||
int numECCodewords = numCodewords - numDataCodewords;
|
||||
|
||||
ArrayRef<int> parameterWords(new Array<int>(numCodewords));
|
||||
ArrayRef<int> parameterWords(new std::vector<int>(numCodewords));
|
||||
|
||||
int codewordSize = 4;
|
||||
for (int i = 0; i < numCodewords; i++) {
|
||||
|
|
|
@ -22,152 +22,153 @@
|
|||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <zxing/common/Counted.h>
|
||||
//#include <zxing/common/Counted.h>
|
||||
|
||||
namespace zxing {
|
||||
//namespace zxing {
|
||||
|
||||
template<typename T> class Array : public Counted {
|
||||
protected:
|
||||
public:
|
||||
std::vector<T> values_;
|
||||
Array() {}
|
||||
Array(int n) :
|
||||
Counted(), values_(n, T()) {
|
||||
}
|
||||
Array(T const* ts, int n) :
|
||||
Counted(), values_(ts, ts+n) {
|
||||
}
|
||||
Array(T const* ts, T const* te) :
|
||||
Counted(), values_(ts, te) {
|
||||
}
|
||||
Array(T v, int n) :
|
||||
Counted(), values_(n, v) {
|
||||
}
|
||||
Array(std::vector<T> &v) :
|
||||
Counted(), values_(v) {
|
||||
}
|
||||
Array(Array<T> &other) :
|
||||
Counted(), values_(other.values_) {
|
||||
}
|
||||
Array(Array<T> *other) :
|
||||
Counted(), values_(other->values_) {
|
||||
}
|
||||
virtual ~Array() {
|
||||
}
|
||||
Array<T>& operator=(const Array<T> &other) {
|
||||
values_ = other.values_;
|
||||
return *this;
|
||||
}
|
||||
Array<T>& operator=(const std::vector<T> &array) {
|
||||
values_ = array;
|
||||
return *this;
|
||||
}
|
||||
T const& operator[](int i) const {
|
||||
return values_[i];
|
||||
}
|
||||
T& operator[](int i) {
|
||||
return values_[i];
|
||||
}
|
||||
int size() const {
|
||||
return int(values_.size());
|
||||
}
|
||||
bool empty() const {
|
||||
return values_.size() == 0;
|
||||
}
|
||||
std::vector<T> const& values() const {
|
||||
return values_;
|
||||
}
|
||||
std::vector<T>& values() {
|
||||
return values_;
|
||||
}
|
||||
void push_back(T value) {
|
||||
values_.push_back(value);
|
||||
}
|
||||
};
|
||||
//template<typename T> class Array : public Counted {
|
||||
//protected:
|
||||
//public:
|
||||
// std::vector<T> values_;
|
||||
// Array() {}
|
||||
// Array(int n) :
|
||||
// Counted(), values_(n, T()) {
|
||||
// }
|
||||
// Array(T const* ts, int n) :
|
||||
// Counted(), values_(ts, ts+n) {
|
||||
// }
|
||||
// Array(T const* ts, T const* te) :
|
||||
// Counted(), values_(ts, te) {
|
||||
// }
|
||||
// Array(T v, int n) :
|
||||
// Counted(), values_(n, v) {
|
||||
// }
|
||||
// Array(std::vector<T> &v) :
|
||||
// Counted(), values_(v) {
|
||||
// }
|
||||
// Array(std::vector<T> &other) :
|
||||
// Counted(), values_(other.values_) {
|
||||
// }
|
||||
// Array(std::vector<T> *other) :
|
||||
// Counted(), values_(other->values_) {
|
||||
// }
|
||||
// virtual ~Array() {
|
||||
// }
|
||||
// std::vector<T>& operator=(const std::vector<T> &other) {
|
||||
// values_ = other.values_;
|
||||
// return *this;
|
||||
// }
|
||||
// std::vector<T>& operator=(const std::vector<T> &array) {
|
||||
// values_ = array;
|
||||
// return *this;
|
||||
// }
|
||||
// T const& operator[](int i) const {
|
||||
// return values_[i];
|
||||
// }
|
||||
// T& operator[](int i) {
|
||||
// return values_[i];
|
||||
// }
|
||||
// int size() const {
|
||||
// return int(values_.size());
|
||||
// }
|
||||
// bool empty() const {
|
||||
// return values_.size() == 0;
|
||||
// }
|
||||
// std::vector<T> const& values() const {
|
||||
// return values_;
|
||||
// }
|
||||
// std::vector<T>& values() {
|
||||
// return values_;
|
||||
// }
|
||||
// void push_back(T value) {
|
||||
// values_.push_back(value);
|
||||
// }
|
||||
//};
|
||||
|
||||
template<typename T> class ArrayRef : public Counted {
|
||||
private:
|
||||
public:
|
||||
Array<T> *array_;
|
||||
ArrayRef() :
|
||||
array_(0) {
|
||||
}
|
||||
explicit ArrayRef(int n) :
|
||||
array_(0) {
|
||||
reset(new Array<T> (n));
|
||||
}
|
||||
ArrayRef(T *ts, int n) :
|
||||
array_(0) {
|
||||
reset(new Array<T> (ts, n));
|
||||
}
|
||||
ArrayRef(Array<T> *a) :
|
||||
array_(0) {
|
||||
reset(a);
|
||||
}
|
||||
ArrayRef(const ArrayRef &other) :
|
||||
Counted(), array_(0) {
|
||||
reset(other.array_);
|
||||
}
|
||||
//template<typename T> class ArrayRef : public Counted {
|
||||
//private:
|
||||
//public:
|
||||
// std::vector<T> *array_;
|
||||
// ArrayRef() :
|
||||
// array_(0) {
|
||||
// }
|
||||
// explicit ArrayRef(int n) :
|
||||
// array_(0) {
|
||||
// reset(new std::vector<T> (n));
|
||||
// }
|
||||
// ArrayRef(T *ts, int n) :
|
||||
// array_(0) {
|
||||
// reset(new std::vector<T> (ts, n));
|
||||
// }
|
||||
// ArrayRef(std::vector<T> *a) :
|
||||
// array_(0) {
|
||||
// reset(a);
|
||||
// }
|
||||
// ArrayRef(const ArrayRef &other) :
|
||||
// Counted(), array_(0) {
|
||||
// reset(other.array_);
|
||||
// }
|
||||
|
||||
template<class Y>
|
||||
ArrayRef(const ArrayRef<Y> &other) :
|
||||
array_(0) {
|
||||
reset(static_cast<const Array<T> *>(other.array_));
|
||||
}
|
||||
// template<class Y>
|
||||
// ArrayRef(const ArrayRef<Y> &other) :
|
||||
// array_(0) {
|
||||
// reset(static_cast<const std::vector<T> *>(other.array_));
|
||||
// }
|
||||
|
||||
~ArrayRef() {
|
||||
if (array_) {
|
||||
array_->release();
|
||||
}
|
||||
array_ = 0;
|
||||
}
|
||||
// ~ArrayRef() {
|
||||
// if (array_) {
|
||||
// array_->release();
|
||||
// }
|
||||
// array_ = 0;
|
||||
// }
|
||||
|
||||
T const& operator[](int i) const {
|
||||
return (*array_)[i];
|
||||
}
|
||||
// T const& operator[](int i) const {
|
||||
// return (*array_)[i];
|
||||
// }
|
||||
|
||||
T& operator[](int i) {
|
||||
return (*array_)[i];
|
||||
}
|
||||
// T& operator[](int i) {
|
||||
// return (*array_)[i];
|
||||
// }
|
||||
|
||||
void reset(Array<T> *a) {
|
||||
if (a) {
|
||||
a->retain();
|
||||
}
|
||||
if (array_) {
|
||||
array_->release();
|
||||
}
|
||||
array_ = a;
|
||||
}
|
||||
void reset(const ArrayRef<T> &other) {
|
||||
reset(other.array_);
|
||||
}
|
||||
ArrayRef<T>& operator=(const ArrayRef<T> &other) {
|
||||
reset(other);
|
||||
return *this;
|
||||
}
|
||||
ArrayRef<T>& operator=(Array<T> *a) {
|
||||
reset(a);
|
||||
return *this;
|
||||
}
|
||||
// void reset(std::vector<T> *a) {
|
||||
// if (a) {
|
||||
// a->retain();
|
||||
// }
|
||||
// if (array_) {
|
||||
// array_->release();
|
||||
// }
|
||||
// array_ = a;
|
||||
// }
|
||||
// void reset(const ArrayRef<T> &other) {
|
||||
// reset(other.array_);
|
||||
// }
|
||||
// ArrayRef<T>& operator=(const ArrayRef<T> &other) {
|
||||
// reset(other);
|
||||
// return *this;
|
||||
// }
|
||||
// ArrayRef<T>& operator=(std::vector<T> *a) {
|
||||
// reset(a);
|
||||
// return *this;
|
||||
// }
|
||||
|
||||
Array<T>& operator*() const {
|
||||
return *array_;
|
||||
}
|
||||
// std::vector<T>& operator*() const {
|
||||
// return *array_;
|
||||
// }
|
||||
|
||||
Array<T>* operator->() const {
|
||||
return array_;
|
||||
}
|
||||
// std::vector<T>* operator->() const {
|
||||
// return array_;
|
||||
// }
|
||||
|
||||
operator bool () const {
|
||||
return array_ != 0;
|
||||
}
|
||||
bool operator ! () const {
|
||||
return array_ == 0;
|
||||
}
|
||||
};
|
||||
// operator bool () const {
|
||||
// return array_ != 0;
|
||||
// }
|
||||
// bool operator ! () const {
|
||||
// return array_ == 0;
|
||||
// }
|
||||
//};
|
||||
|
||||
} // namespace zxing
|
||||
//} // namespace zxing
|
||||
|
||||
#endif // ZXING_ARRAY_H
|
||||
|
|
|
@ -132,11 +132,11 @@ ArrayRef<int> ReedSolomonDecoder::findErrorLocations(Ref<GenericGFPoly> errorLoc
|
|||
// This is a direct application of Chien's search
|
||||
int numErrors = errorLocator->getDegree();
|
||||
if (numErrors == 1) { // shortcut
|
||||
ArrayRef<int> result(new Array<int>(1));
|
||||
ArrayRef<int> result(new std::vector<int>(1));
|
||||
result[0] = errorLocator->getCoefficient(1);
|
||||
return result;
|
||||
}
|
||||
ArrayRef<int> result(new Array<int>(numErrors));
|
||||
ArrayRef<int> result(new std::vector<int>(numErrors));
|
||||
int e = 0;
|
||||
for (size_t i = 1; i < field->getSize() && e < numErrors; i++) {
|
||||
if (errorLocator->evaluateAt(i) == 0) {
|
||||
|
@ -153,7 +153,7 @@ ArrayRef<int> ReedSolomonDecoder::findErrorLocations(Ref<GenericGFPoly> errorLoc
|
|||
ArrayRef<int> ReedSolomonDecoder::findErrorMagnitudes(Ref<GenericGFPoly> errorEvaluator, ArrayRef<int> errorLocations) {
|
||||
// This is directly applying Forney's Formula
|
||||
int s = errorLocations->size();
|
||||
ArrayRef<int> result(new Array<int>(s));
|
||||
ArrayRef<int> result(new std::vector<int>(s));
|
||||
for (int i = 0; i < s; i++) {
|
||||
int xiInverse = field->inverse(errorLocations[i]);
|
||||
int denominator = 1;
|
||||
|
|
|
@ -246,7 +246,7 @@ Ref<DetectorResult> Detector::detect() {
|
|||
bits = sampleGrid(image_, dimensionCorrected, dimensionCorrected, transform);
|
||||
}
|
||||
|
||||
ArrayRef< Ref<ResultPoint> > points (new Array< Ref<ResultPoint> >(4));
|
||||
ArrayRef< Ref<ResultPoint> > points (new std::vector< Ref<ResultPoint> >(4));
|
||||
points[0].reset(topLeft);
|
||||
points[1].reset(bottomLeft);
|
||||
points[2].reset(correctedTopRight);
|
||||
|
|
|
@ -45,7 +45,7 @@ const int N = 1; // Pixed width of a narrow line
|
|||
|
||||
const int DEFAULT_ALLOWED_LENGTHS_[] =
|
||||
{ 48, 44, 24, 20, 18, 16, 14, 12, 10, 8, 6 };
|
||||
const ArrayRef<int> DEFAULT_ALLOWED_LENGTHS (new Array<int>(VECTOR_INIT(DEFAULT_ALLOWED_LENGTHS_)));
|
||||
const ArrayRef<int> DEFAULT_ALLOWED_LENGTHS (new std::vector<int>(VECTOR_INIT(DEFAULT_ALLOWED_LENGTHS_)));
|
||||
|
||||
/**
|
||||
* Start/end guard pattern.
|
||||
|
|
|
@ -72,9 +72,9 @@ ArrayRef<int> BitMatrixParser::readCodewords()
|
|||
//int width = bitMatrix_->getWidth();
|
||||
int height = bitMatrix_->getHeight();
|
||||
|
||||
erasures_ = new Array<int>(MAX_CW_CAPACITY);
|
||||
erasures_ = new std::vector<int>(MAX_CW_CAPACITY);
|
||||
|
||||
ArrayRef<int> codewords (new Array<int>(MAX_CW_CAPACITY));
|
||||
ArrayRef<int> codewords (new std::vector<int>(MAX_CW_CAPACITY));
|
||||
int next = 0;
|
||||
int rowNumber = 0;
|
||||
for (int i = 0; i < height; i++) {
|
||||
|
@ -187,7 +187,7 @@ ArrayRef<int> BitMatrixParser::trimArray(ArrayRef<int> array, int size)
|
|||
throw IllegalArgumentException("BitMatrixParser::trimArray: negative size!");
|
||||
}
|
||||
// 2012-10-12 hfn don't throw "NoErrorException" when size == 0
|
||||
ArrayRef<int> a = new Array<int>(size);
|
||||
ArrayRef<int> a = new std::vector<int>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
a[i] = array[i];
|
||||
}
|
||||
|
|
|
@ -366,8 +366,8 @@ int DecodedBitStreamParser::byteCompaction(int mode,
|
|||
// is not a multiple of 6
|
||||
int count = 0;
|
||||
int64_t value = 0;
|
||||
ArrayRef<zxing::byte> decodedData = new Array<zxing::byte>(6);
|
||||
ArrayRef<int> byteCompactedCodewords = new Array<int>(6);
|
||||
ArrayRef<zxing::byte> decodedData = new std::vector<zxing::byte>(6);
|
||||
ArrayRef<int> byteCompactedCodewords = new std::vector<int>(6);
|
||||
bool end = false;
|
||||
int nextCode = codewords[codeIndex++];
|
||||
while ((codeIndex < codewords[0]) && !end) {
|
||||
|
@ -442,7 +442,7 @@ int DecodedBitStreamParser::byteCompaction(int mode,
|
|||
if ((count % 5 == 0) && (count > 0)) {
|
||||
// Decode every 5 codewords
|
||||
// Convert to Base 256
|
||||
ArrayRef<zxing::byte> decodedData = new Array<zxing::byte>(6);
|
||||
ArrayRef<zxing::byte> decodedData = new std::vector<zxing::byte>(6);
|
||||
for (int j = 0; j < 6; ++j) {
|
||||
decodedData[5 - j] = (zxing::byte) (value & 0xFF);
|
||||
value >>= 8;
|
||||
|
@ -470,7 +470,7 @@ int DecodedBitStreamParser::numericCompaction(ArrayRef<int> codewords,
|
|||
int count = 0;
|
||||
bool end = false;
|
||||
|
||||
ArrayRef<int> numericCodewords = new Array<int>(MAX_NUMERIC_CODEWORDS);
|
||||
ArrayRef<int> numericCodewords = new std::vector<int>(MAX_NUMERIC_CODEWORDS);
|
||||
|
||||
while (codeIndex < codewords[0] && !end) {
|
||||
int code = codewords[codeIndex++];
|
||||
|
|
|
@ -49,7 +49,7 @@ void ErrorCorrection::decode(ArrayRef<int> received,
|
|||
ArrayRef<int> erasures)
|
||||
{
|
||||
Ref<ModulusPoly> poly (new ModulusPoly(field_, received));
|
||||
ArrayRef<int> S( new Array<int>(numECCodewords));
|
||||
ArrayRef<int> S( new std::vector<int>(numECCodewords));
|
||||
bool error = false;
|
||||
for (int i = numECCodewords; i > 0; i--) {
|
||||
int eval = poly->evaluateAt(field_.exp(i));
|
||||
|
@ -65,7 +65,7 @@ void ErrorCorrection::decode(ArrayRef<int> received,
|
|||
for (int i=0;i<erasures->size();i++) {
|
||||
int b = field_.exp(received->size() - 1 - erasures[i]);
|
||||
// Add (1 - bx) term:
|
||||
ArrayRef<int> one_minus_b_x(new Array<int>(2));
|
||||
ArrayRef<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;
|
||||
Ref<ModulusPoly> term (new ModulusPoly(field_,one_minus_b_x));
|
||||
|
@ -160,7 +160,7 @@ vector<Ref<ModulusPoly> > ErrorCorrection::runEuclideanAlgorithm(Ref<ModulusPol
|
|||
ArrayRef<int> ErrorCorrection::findErrorLocations(Ref<ModulusPoly> errorLocator) {
|
||||
// This is a direct application of Chien's search
|
||||
int numErrors = errorLocator->getDegree();
|
||||
ArrayRef<int> result( new Array<int>(numErrors));
|
||||
ArrayRef<int> result( new std::vector<int>(numErrors));
|
||||
int e = 0;
|
||||
for (int i = 1; i < field_.getSize() && e < numErrors; i++) {
|
||||
if (errorLocator->evaluateAt(i) == 0) {
|
||||
|
@ -193,7 +193,7 @@ ArrayRef<int> ErrorCorrection::findErrorMagnitudes(Ref<ModulusPoly> errorEvaluat
|
|||
ArrayRef<int> errorLocations) {
|
||||
int i;
|
||||
int errorLocatorDegree = errorLocator->getDegree();
|
||||
ArrayRef<int> formalDerivativeCoefficients (new Array<int>(errorLocatorDegree));
|
||||
ArrayRef<int> formalDerivativeCoefficients (new std::vector<int>(errorLocatorDegree));
|
||||
for (i = 1; i <= errorLocatorDegree; i++) {
|
||||
formalDerivativeCoefficients[errorLocatorDegree - i] =
|
||||
field_.multiply(i, errorLocator->getCoefficient(i));
|
||||
|
@ -202,7 +202,7 @@ ArrayRef<int> ErrorCorrection::findErrorMagnitudes(Ref<ModulusPoly> errorEvaluat
|
|||
|
||||
// This is directly applying Forney's Formula
|
||||
int s = errorLocations->size();
|
||||
ArrayRef<int> result ( new Array<int>(s));
|
||||
ArrayRef<int> result ( new std::vector<int>(s));
|
||||
for (i = 0; i < s; i++) {
|
||||
int xiInverse = field_.inverse(errorLocations[i]);
|
||||
int numerator = field_.subtract(0, errorEvaluator->evaluateAt(xiInverse));
|
||||
|
|
|
@ -40,8 +40,8 @@ ModulusGF ModulusGF::PDF417_GF(929,3);
|
|||
|
||||
ModulusGF::ModulusGF(int modulus, int generator)
|
||||
: modulus_(modulus) {
|
||||
expTable_ = new Array<int>(modulus_);
|
||||
logTable_ = new Array<int>(modulus_);
|
||||
expTable_ = new std::vector<int>(modulus_);
|
||||
logTable_ = new std::vector<int>(modulus_);
|
||||
int x = 1,i;
|
||||
for (i = 0; i < modulus_; i++) {
|
||||
expTable_[i] = x;
|
||||
|
@ -51,7 +51,7 @@ ModulusGF::ModulusGF(int modulus, int generator)
|
|||
logTable_[expTable_[i]] = i;
|
||||
}
|
||||
// logTable[0] == 0 but this should never be used
|
||||
ArrayRef<int>aZero(new Array<int>(1)),aOne(new Array<int>(1));
|
||||
ArrayRef<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);
|
||||
|
@ -74,7 +74,7 @@ Ref<ModulusPoly> ModulusGF::buildMonomial(int degree, int coefficient)
|
|||
return zero_;
|
||||
}
|
||||
int nCoefficients = degree + 1;
|
||||
ArrayRef<int> coefficients (new Array<int>(nCoefficients));
|
||||
ArrayRef<int> coefficients (new std::vector<int>(nCoefficients));
|
||||
coefficients[0] = coefficient;
|
||||
Ref<ModulusPoly> result(new ModulusPoly(*this,coefficients));
|
||||
return result;
|
||||
|
|
|
@ -45,18 +45,18 @@ ModulusPoly::ModulusPoly(ModulusGF& field, ArrayRef<int> coefficients)
|
|||
}
|
||||
if (firstNonZero == coefficientsLength) {
|
||||
coefficientsLength = field_.getZero()->getCoefficients()->size();
|
||||
coefficients_.reset(new Array<int> (coefficientsLength));
|
||||
coefficients_.reset(new std::vector<int> (coefficientsLength));
|
||||
*coefficients_ = *(field_.getZero()->getCoefficients());
|
||||
} else {
|
||||
ArrayRef<int> c(coefficients);
|
||||
coefficientsLength -= firstNonZero;
|
||||
coefficients_.reset(new Array<int> (coefficientsLength));
|
||||
coefficients_.reset(new std::vector<int> (coefficientsLength));
|
||||
for (int i = 0; i < coefficientsLength; i++) {
|
||||
coefficients_[i] = c[i + firstNonZero];
|
||||
}
|
||||
/*
|
||||
coefficientsLength -= firstNonZero;
|
||||
coefficients_.reset(new Array<int>(coefficientsLength - firstNonZero));
|
||||
coefficients_.reset(new std::vector<int>(coefficientsLength - firstNonZero));
|
||||
for (int i = 0; i < coefficientsLength; i++) {
|
||||
coefficients_[i] = coefficients[i + firstNonZero];
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ Ref<ModulusPoly> ModulusPoly::add(Ref<ModulusPoly> other) {
|
|||
smallerCoefficients = largerCoefficients;
|
||||
largerCoefficients = temp;
|
||||
}
|
||||
ArrayRef<int> sumDiff (new Array<int>(largerCoefficients->size()));
|
||||
ArrayRef<int> sumDiff (new std::vector<int>(largerCoefficients->size()));
|
||||
int lengthDiff = largerCoefficients->size() - smallerCoefficients->size();
|
||||
// Copy high-order terms only found in higher-degree polynomial's coefficients
|
||||
for (int i = 0; i < lengthDiff; i++) {
|
||||
|
@ -171,7 +171,7 @@ Ref<ModulusPoly> ModulusPoly::multiply(Ref<ModulusPoly> other) {
|
|||
int aLength = aCoefficients->size();
|
||||
ArrayRef<int> bCoefficients = other->coefficients_;
|
||||
int bLength = bCoefficients->size();
|
||||
ArrayRef<int> product (new Array<int>(aLength + bLength - 1));
|
||||
ArrayRef<int> product (new std::vector<int>(aLength + bLength - 1));
|
||||
for (i = 0; i < aLength; i++) {
|
||||
int aCoeff = aCoefficients[i];
|
||||
for (j = 0; j < bLength; j++) {
|
||||
|
@ -183,7 +183,7 @@ Ref<ModulusPoly> ModulusPoly::multiply(Ref<ModulusPoly> other) {
|
|||
|
||||
Ref<ModulusPoly> ModulusPoly::negative() {
|
||||
int size = coefficients_->size();
|
||||
ArrayRef<int> negativeCoefficients (new Array<int>(size));
|
||||
ArrayRef<int> negativeCoefficients (new std::vector<int>(size));
|
||||
for (int i = 0; i < size; i++) {
|
||||
negativeCoefficients[i] = field_.subtract(0, coefficients_[i]);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ Ref<ModulusPoly> ModulusPoly::multiply(int scalar) {
|
|||
return Ref<ModulusPoly>(this);
|
||||
}
|
||||
int size = coefficients_->size();
|
||||
ArrayRef<int> product( new Array<int>(size));
|
||||
ArrayRef<int> product( new std::vector<int>(size));
|
||||
for (int i = 0; i < size; i++) {
|
||||
product[i] = field_.multiply(coefficients_[i], scalar);
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ Ref<ModulusPoly> ModulusPoly::multiplyByMonomial(int degree, int coefficient) {
|
|||
return field_.getZero();
|
||||
}
|
||||
int size = coefficients_->size();
|
||||
ArrayRef<int> product (new Array<int>(size + degree));
|
||||
ArrayRef<int> product (new std::vector<int>(size + degree));
|
||||
for (int i = 0; i < size; i++) {
|
||||
product[i] = field_.multiply(coefficients_[i], coefficient);
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ ArrayRef< Ref<ResultPoint> > Detector::findVertices(Ref<BitMatrix> matrix, int r
|
|||
ArrayRef< Ref<ResultPoint> > result(16);
|
||||
bool found = false;
|
||||
|
||||
ArrayRef<int> counters(new Array<int>(START_PATTERN_LENGTH));
|
||||
ArrayRef<int> counters(new std::vector<int>(START_PATTERN_LENGTH));
|
||||
|
||||
// Top Left
|
||||
for (int i = 0; i < height; i += rowStep) {
|
||||
|
@ -179,7 +179,7 @@ ArrayRef< Ref<ResultPoint> > Detector::findVertices(Ref<BitMatrix> matrix, int r
|
|||
}
|
||||
}
|
||||
|
||||
counters = new Array<int>(STOP_PATTERN_LENGTH);
|
||||
counters = new std::vector<int>(STOP_PATTERN_LENGTH);
|
||||
|
||||
// Top right
|
||||
if (found) { // Found the Bottom Left vertex
|
||||
|
@ -221,7 +221,7 @@ ArrayRef< Ref<ResultPoint> > Detector::findVertices180(Ref<BitMatrix> matrix, in
|
|||
ArrayRef< Ref<ResultPoint> > result(16);
|
||||
bool found = false;
|
||||
|
||||
ArrayRef<int> counters = new Array<int>(START_PATTERN_REVERSE_LENGTH);
|
||||
ArrayRef<int> counters = new std::vector<int>(START_PATTERN_REVERSE_LENGTH);
|
||||
|
||||
// Top Left
|
||||
for (int i = height - 1; i > 0; i -= rowStep) {
|
||||
|
@ -251,7 +251,7 @@ ArrayRef< Ref<ResultPoint> > Detector::findVertices180(Ref<BitMatrix> matrix, in
|
|||
}
|
||||
}
|
||||
|
||||
counters = new Array<int>(STOP_PATTERN_REVERSE_LENGTH);
|
||||
counters = new std::vector<int>(STOP_PATTERN_REVERSE_LENGTH);
|
||||
|
||||
// Top Right
|
||||
if (found) { // Found the Bottom Left vertex
|
||||
|
@ -317,7 +317,7 @@ ArrayRef<int> Detector::findGuardPattern(Ref<BitMatrix> matrix,
|
|||
if (counterPosition == patternLength - 1) {
|
||||
if (patternMatchVariance(counters, pattern,
|
||||
MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) {
|
||||
ArrayRef<int> result = new Array<int>(2);
|
||||
ArrayRef<int> result = new std::vector<int>(2);
|
||||
result[0] = patternStart;
|
||||
result[1] = x;
|
||||
return result;
|
||||
|
|
|
@ -118,7 +118,7 @@ Ref<DetectorResult> Detector::processFinderPatternInfo(Ref<FinderPatternInfo> in
|
|||
|
||||
Ref<PerspectiveTransform> transform = createTransform(topLeft, topRight, bottomLeft, alignmentPattern, dimension);
|
||||
Ref<BitMatrix> bits(sampleGrid(image_, dimension, transform));
|
||||
ArrayRef< Ref<ResultPoint> > points(new Array< Ref<ResultPoint> >(alignmentPattern == 0 ? 3 : 4));
|
||||
ArrayRef< Ref<ResultPoint> > points(new std::vector< Ref<ResultPoint> >(alignmentPattern == 0 ? 3 : 4));
|
||||
points[0].reset(bottomLeft);
|
||||
points[1].reset(topLeft);
|
||||
points[2].reset(topRight);
|
||||
|
|
Loading…
Reference in New Issue