本文整理匯總了Java中com.google.zxing.ResultPoint類的典型用法代碼示例。如果您正苦於以下問題:Java ResultPoint類的具體用法?Java ResultPoint怎麽用?Java ResultPoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ResultPoint類屬於com.google.zxing包,在下文中一共展示了ResultPoint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decodePair
import com.google.zxing.ResultPoint; //導入依賴的package包/類
private Pair decodePair(BitArray row, boolean right, int rowNumber, Map<DecodeHintType,?> hints) {
try {
int[] startEnd = findFinderPattern(row, right);
FinderPattern pattern = parseFoundFinderPattern(row, rowNumber, right, startEnd);
ResultPointCallback resultPointCallback = hints == null ? null :
(ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
if (resultPointCallback != null) {
float center = (startEnd[0] + startEnd[1]) / 2.0f;
if (right) {
// row is actually reversed
center = row.getSize() - 1 - center;
}
resultPointCallback.foundPossibleResultPoint(new ResultPoint(center, rowNumber));
}
DataCharacter outside = decodeDataCharacter(row, pattern, true);
DataCharacter inside = decodeDataCharacter(row, pattern, false);
return new Pair(1597 * outside.getValue() + inside.getValue(),
outside.getChecksumPortion() + 4 * inside.getChecksumPortion(),
pattern);
} catch (NotFoundException ignored) {
return null;
}
}
示例2: findRowSkip
import com.google.zxing.ResultPoint; //導入依賴的package包/類
private int findRowSkip() {
if (this.possibleCenters.size() <= 1) {
return 0;
}
ResultPoint firstConfirmedCenter = null;
for (ResultPoint center : this.possibleCenters) {
if (center.getCount() >= 2) {
if (firstConfirmedCenter == null) {
firstConfirmedCenter = center;
} else {
this.hasSkipped = true;
return ((int) (Math.abs(firstConfirmedCenter.getX() - center.getX()) - Math
.abs(firstConfirmedCenter.getY() - center.getY()))) / 2;
}
}
}
return 0;
}
示例3: detect
import com.google.zxing.ResultPoint; //導入依賴的package包/類
/**
* <p>Detects a PDF417 Code in an image. Only checks 0 and 180 degree rotations.</p>
*
* @param image barcode image to decode
* @param hints optional hints to detector
* @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will
* be found and returned
* @return {@link PDF417DetectorResult} encapsulating results of detecting a PDF417 code
* @throws NotFoundException if no PDF417 Code can be found
*/
public static PDF417DetectorResult detect(BinaryBitmap image, Map<DecodeHintType,?> hints, boolean multiple)
throws NotFoundException {
// TODO detection improvement, tryHarder could try several different luminance thresholds/blackpoints or even
// different binarizers
//boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
BitMatrix bitMatrix = image.getBlackMatrix();
List<ResultPoint[]> barcodeCoordinates = detect(multiple, bitMatrix);
if (barcodeCoordinates.isEmpty()) {
bitMatrix = bitMatrix.clone();
bitMatrix.rotate180();
barcodeCoordinates = detect(multiple, bitMatrix);
}
return new PDF417DetectorResult(bitMatrix, barcodeCoordinates);
}
示例4: ViewfinderView
import com.google.zxing.ResultPoint; //導入依賴的package包/類
public ViewfinderView(Context context, AttributeSet attrs) {
super(context, attrs);
mContext = context;
density = context.getResources().getDisplayMetrics().density;
Resources res = getResources();
bitmap = BitmapFactory.decodeResource(res, R.mipmap.qrcode_scan_line);
// 將像素轉換成dp
ScreenRate = (int) (20 * density);
paint = new Paint();
Resources resources = getResources();
maskColor = resources.getColor(R.color.color_black_0D);
resultColor = resources.getColor(R.color.color_black_0D);
resultPointColor = resources.getColor(R.color.color_yellow);
possibleResultPoints = new HashSet<ResultPoint>(5);
}
示例5: createTransform
import com.google.zxing.ResultPoint; //導入依賴的package包/類
private static PerspectiveTransform createTransform(ResultPoint topLeft, ResultPoint
topRight, ResultPoint bottomLeft, ResultPoint alignmentPattern, int dimension) {
float bottomRightX;
float bottomRightY;
float sourceBottomRightX;
float sourceBottomRightY;
float dimMinusThree = ((float) dimension) - 3.5f;
if (alignmentPattern != null) {
bottomRightX = alignmentPattern.getX();
bottomRightY = alignmentPattern.getY();
sourceBottomRightX = dimMinusThree - IPhotoView.DEFAULT_MAX_SCALE;
sourceBottomRightY = sourceBottomRightX;
} else {
bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
sourceBottomRightX = dimMinusThree;
sourceBottomRightY = dimMinusThree;
}
return PerspectiveTransform.quadrilateralToQuadrilateral(3.5f, 3.5f, dimMinusThree, 3.5f,
sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree, topLeft.getX(),
topLeft.getY(), topRight.getX(), topRight.getY(), bottomRightX, bottomRightY,
bottomLeft.getX(), bottomLeft.getY());
}
示例6: decode
import com.google.zxing.ResultPoint; //導入依賴的package包/類
private static Result[] decode(BinaryBitmap image, Map<DecodeHintType, ?> hints, boolean multiple)
throws NotFoundException, FormatException, ChecksumException {
List<Result> results = new ArrayList<>();
PDF417DetectorResult detectorResult = Detector.detect(image, hints, multiple);
for (ResultPoint[] points : detectorResult.getPoints()) {
DecoderResult decoderResult = PDF417ScanningDecoder.decode(detectorResult.getBits(), points[4], points[5],
points[6], points[7], getMinCodewordWidth(points), getMaxCodewordWidth(points));
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.PDF_417);
result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, decoderResult.getECLevel());
PDF417ResultMetadata pdf417ResultMetadata = (PDF417ResultMetadata) decoderResult.getOther();
if (pdf417ResultMetadata != null) {
result.putMetadata(ResultMetadataType.PDF417_EXTRA_METADATA, pdf417ResultMetadata);
}
results.add(result);
}
return results.toArray(new Result[results.size()]);
}
示例7: decodeRow
import com.google.zxing.ResultPoint; //導入依賴的package包/類
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
StringBuilder result = decodeRowStringBuffer;
result.setLength(0);
int end = decodeMiddle(row, extensionStartRange, result);
String resultString = result.toString();
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
Result extensionResult =
new Result(resultString,
null,
new ResultPoint[] {
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, rowNumber),
new ResultPoint(end, rowNumber),
},
BarcodeFormat.UPC_EAN_EXTENSION);
if (extensionData != null) {
extensionResult.putAllMetadata(extensionData);
}
return extensionResult;
}
示例8: computeDimension
import com.google.zxing.ResultPoint; //導入依賴的package包/類
/**
* <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 (dimension & 0x03) { // mod 4
case 0:
dimension++;
break;
// 1? do nothing
case 2:
dimension--;
break;
case 3:
throw NotFoundException.getNotFoundInstance();
}
return dimension;
}
示例9: constructResult
import com.google.zxing.ResultPoint; //導入依賴的package包/類
static Result constructResult(List<ExpandedPair> pairs) throws NotFoundException, FormatException {
BitArray binary = BitArrayBuilder.buildBitArray(pairs);
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
String resultingString = decoder.parseInformation();
ResultPoint[] firstPoints = pairs.get(0).getFinderPattern().getResultPoints();
ResultPoint[] lastPoints = pairs.get(pairs.size() - 1).getFinderPattern().getResultPoints();
return new Result(
resultingString,
null,
new ResultPoint[]{firstPoints[0], firstPoints[1], lastPoints[0], lastPoints[1]},
BarcodeFormat.RSS_EXPANDED
);
}
示例10: centerEdges
import com.google.zxing.ResultPoint; //導入依賴的package包/類
private ResultPoint[] centerEdges(ResultPoint y, ResultPoint z, ResultPoint x, ResultPoint t) {
float yi = y.getX();
float yj = y.getY();
float zi = z.getX();
float zj = z.getY();
float xi = x.getX();
float xj = x.getY();
float ti = t.getX();
float tj = t.getY();
if (yi < ((float) this.width) / 2.0f) {
return new ResultPoint[]{new ResultPoint(ti - 1.0f, 1.0f + tj), new ResultPoint(1.0f
+ zi, 1.0f + zj), new ResultPoint(xi - 1.0f, xj - 1.0f), new ResultPoint(1.0f
+ yi, yj - 1.0f)};
}
return new ResultPoint[]{new ResultPoint(1.0f + ti, 1.0f + tj), new ResultPoint(1.0f +
zi, zj - 1.0f), new ResultPoint(xi - 1.0f, 1.0f + xj), new ResultPoint(yi - 1.0f,
yj - 1.0f)};
}
示例11: drawResultPoints
import com.google.zxing.ResultPoint; //導入依賴的package包/類
/**
* Superimpose a line for 1D or dots for 2D to highlight the key features of the barcode.
*
* @param barcode A bitmap of the captured image.
* @param scaleFactor amount by which thumbnail was scaled
* @param rawResult The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, float scaleFactor, Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(getResources().getColor(R.color.result_points));
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1], scaleFactor);
} else if (points.length == 4 &&
(rawResult.getBarcodeFormat() == BarcodeFormat.UPC_A ||
rawResult.getBarcodeFormat() == BarcodeFormat.EAN_13)) {
// Hacky special case -- draw two lines, for the barcode and metadata
drawLine(canvas, paint, points[0], points[1], scaleFactor);
drawLine(canvas, paint, points[2], points[3], scaleFactor);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
if (point != null) {
canvas.drawPoint(scaleFactor * point.getX(), scaleFactor * point.getY(), paint);
}
}
}
}
}
示例12: decodeRow
import com.google.zxing.ResultPoint; //導入依賴的package包/類
Result decodeRow(int rowNumber, BitArray row, int[] extensionStartRange) throws NotFoundException {
StringBuilder result = decodeRowStringBuffer;
result.setLength(0);
int end = decodeMiddle(row, extensionStartRange, result);
String resultString = result.toString();
Map<ResultMetadataType,Object> extensionData = parseExtensionString(resultString);
Result extensionResult =
new Result(resultString,
null,
new ResultPoint[] {
new ResultPoint((extensionStartRange[0] + extensionStartRange[1]) / 2.0f, (float) rowNumber),
new ResultPoint((float) end, (float) rowNumber),
},
BarcodeFormat.UPC_EAN_EXTENSION);
if (extensionData != null) {
extensionResult.putAllMetadata(extensionData);
}
return extensionResult;
}
示例13: decode
import com.google.zxing.ResultPoint; //導入依賴的package包/類
@Override
public Result decode(BinaryBitmap image,
Map<DecodeHintType,?> hints) throws NotFoundException, FormatException {
try {
return doDecode(image, hints);
} catch (NotFoundException nfe) {
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
if (tryHarder && image.isRotateSupported()) {
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
Result result = doDecode(rotatedImage, hints);
// Record that we found it rotated 90 degrees CCW / 270 degrees CW
Map<ResultMetadataType,?> metadata = result.getResultMetadata();
int orientation = 270;
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
// But if we found it reversed in doDecode(), add in that result here:
orientation = (orientation +
(Integer) metadata.get(ResultMetadataType.ORIENTATION)) % 360;
}
result.putMetadata(ResultMetadataType.ORIENTATION, orientation);
// Update result points
ResultPoint[] points = result.getResultPoints();
if (points != null) {
int height = rotatedImage.getHeight();
for (int i = 0; i < points.length; i++) {
points[i] = new ResultPoint(height - points[i].getY() - 1, points[i].getX());
}
}
return result;
} else {
throw nfe;
}
}
}
示例14: sampleGrid
import com.google.zxing.ResultPoint; //導入依賴的package包/類
/**
* Creates a BitMatrix by sampling the provided image.
* topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the
* diagonal just outside the bull's eye.
*/
private BitMatrix sampleGrid(BitMatrix image,
ResultPoint topLeft,
ResultPoint topRight,
ResultPoint bottomRight,
ResultPoint bottomLeft) throws NotFoundException {
GridSampler sampler = GridSampler.getInstance();
int dimension = getDimension();
float low = dimension / 2.0f - nbCenterLayers;
float high = dimension / 2.0f + nbCenterLayers;
return sampler.sampleGrid(image,
dimension,
dimension,
low, low, // topleft
high, low, // topright
high, high, // bottomright
low, high, // bottomleft
topLeft.getX(), topLeft.getY(),
topRight.getX(), topRight.getY(),
bottomRight.getX(), bottomRight.getY(),
bottomLeft.getX(), bottomLeft.getY());
}
示例15: decode
import com.google.zxing.ResultPoint; //導入依賴的package包/類
@Override
public 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);
points = NO_POINTS;
} else {
DetectorResult detectorResult = new Detector(image.getBlackMatrix()).detect();
decoderResult = decoder.decode(detectorResult.getBits());
points = detectorResult.getPoints();
}
Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points,
BarcodeFormat.DATA_MATRIX);
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);
}
return result;
}