use of com.google.zxing.ResultPoint in project incubator-weex by apache.
the class QRCodeReader method decode.
@Override
public final Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException, ChecksumException, FormatException {
DecoderResult decoderResult;
ResultPoint[] points;
if (hints != null && hints.containsKey(DecodeHintType.PURE_BARCODE)) {
BitMatrix bits = extractPureBits(image.getBlackMatrix());
decoderResult = decoder.decode(bits, hints);
points = NO_POINTS;
} else {
DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect(hints);
decoderResult = decoder.decode(detectorResult.getBits(), hints);
points = detectorResult.getPoints();
}
// If the code was mirrored: swap the bottom-left and the top-right points.
if (decoderResult.getOther() instanceof QRCodeDecoderMetaData) {
((QRCodeDecoderMetaData) decoderResult.getOther()).applyMirroredCorrection(points);
}
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.QR_CODE);
List<byte[]> byteSegments = decoderResult.getByteSegments();
if (byteSegments != null) {
result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
}
String ecLevel = decoderResult.getECLevel();
if (ecLevel != null) {
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
}
if (decoderResult.hasStructuredAppend()) {
result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, decoderResult.getStructuredAppendSequenceNumber());
result.putMetadata(ResultMetadataType.STRUCTURED_APPEND_PARITY, decoderResult.getStructuredAppendParity());
}
return result;
}
use of com.google.zxing.ResultPoint in project incubator-weex by apache.
the class BoundingBox method addMissingRows.
BoundingBox addMissingRows(int missingStartRows, int missingEndRows, boolean isLeft) throws NotFoundException {
ResultPoint newTopLeft = topLeft;
ResultPoint newBottomLeft = bottomLeft;
ResultPoint newTopRight = topRight;
ResultPoint newBottomRight = bottomRight;
if (missingStartRows > 0) {
ResultPoint top = isLeft ? topLeft : topRight;
int newMinY = (int) top.getY() - missingStartRows;
if (newMinY < 0) {
newMinY = 0;
}
ResultPoint newTop = new ResultPoint(top.getX(), newMinY);
if (isLeft) {
newTopLeft = newTop;
} else {
newTopRight = newTop;
}
}
if (missingEndRows > 0) {
ResultPoint bottom = isLeft ? bottomLeft : bottomRight;
int newMaxY = (int) bottom.getY() + missingEndRows;
if (newMaxY >= image.getHeight()) {
newMaxY = image.getHeight() - 1;
}
ResultPoint newBottom = new ResultPoint(bottom.getX(), newMaxY);
if (isLeft) {
newBottomLeft = newBottom;
} else {
newBottomRight = newBottom;
}
}
calculateMinMaxValues();
return new BoundingBox(image, newTopLeft, newBottomLeft, newTopRight, newBottomRight);
}
use of com.google.zxing.ResultPoint in project incubator-weex by apache.
the class QRCodeDecoderMetaData method applyMirroredCorrection.
/**
* Apply the result points' order correction due to mirroring.
*
* @param points Array of points to apply mirror correction to.
*/
public void applyMirroredCorrection(ResultPoint[] points) {
if (!mirrored || points == null || points.length < 3) {
return;
}
ResultPoint bottomLeft = points[0];
points[0] = points[2];
points[2] = bottomLeft;
// No need to 'fix' top-left and alignment pattern.
}
use of com.google.zxing.ResultPoint in project incubator-weex by apache.
the class Detector method computeDimension.
/**
* <p>Computes the dimension (number of modules on a size) of the QR Code based on the position
* of the finder patterns and estimated module size.</p>
*/
private static int computeDimension(ResultPoint topLeft, ResultPoint topRight, ResultPoint bottomLeft, float moduleSize) throws NotFoundException {
int tltrCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, topRight) / moduleSize);
int tlblCentersDimension = MathUtils.round(ResultPoint.distance(topLeft, bottomLeft) / moduleSize);
int dimension = ((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
switch(// mod 4
dimension & 0x03) {
case 0:
dimension++;
break;
// 1? do nothing
case 2:
dimension--;
break;
case 3:
throw NotFoundException.getNotFoundInstance();
}
return dimension;
}
use of com.google.zxing.ResultPoint in project keepass2android by PhilippC.
the class ViewfinderView method addPossibleResultPoint.
public void addPossibleResultPoint(ResultPoint point) {
List<ResultPoint> points = possibleResultPoints;
synchronized (points) {
points.add(point);
int size = points.size();
if (size > MAX_RESULT_POINTS) {
// trim it
points.subList(0, size - MAX_RESULT_POINTS / 2).clear();
}
}
}
Aggregations