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