本文整理汇总了Java中com.google.zxing.Result.getResultPoints方法的典型用法代码示例。如果您正苦于以下问题:Java Result.getResultPoints方法的具体用法?Java Result.getResultPoints怎么用?Java Result.getResultPoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.Result
的用法示例。
在下文中一共展示了Result.getResultPoints方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的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);
}
}
}
}
}
示例2: decode
import com.google.zxing.Result; //导入方法依赖的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;
}
}
}
示例3: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(), result.getRawBytes(), newResultPoints, result.getBarcodeFormat());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例4: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的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);
}
}
}
}
}
示例5: translateResultPoints
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result translateResultPoints(Result result, int xOffset, int yOffset) {
ResultPoint[] oldResultPoints = result.getResultPoints();
if (oldResultPoints == null) {
return result;
}
ResultPoint[] newResultPoints = new ResultPoint[oldResultPoints.length];
for (int i = 0; i < oldResultPoints.length; i++) {
ResultPoint oldPoint = oldResultPoints[i];
if (oldPoint != null) {
newResultPoints[i] = new ResultPoint(oldPoint.getX() + xOffset, oldPoint.getY() + yOffset);
}
}
Result newResult = new Result(result.getText(),
result.getRawBytes(),
result.getNumBits(),
newResultPoints,
result.getBarcodeFormat(),
result.getTimestamp());
newResult.putAllMetadata(result.getResultMetadata());
return newResult;
}
示例6: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的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 rawResult The decoded results which contains the points to draw.
*/
private void drawResultPoints(Bitmap barcode, Result rawResult) {
ResultPoint[] points = rawResult.getResultPoints();
if (points != null && points.length > 0) {
Canvas canvas = new Canvas(barcode);
Paint paint = new Paint();
paint.setColor(0xc099cc00);
if (points.length == 2) {
paint.setStrokeWidth(4.0f);
drawLine(canvas, paint, points[0], points[1]);
} 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]);
drawLine(canvas, paint, points[2], points[3]);
} else {
paint.setStrokeWidth(10.0f);
for (ResultPoint point : points) {
canvas.drawPoint(point.getX(), point.getY(), paint);
}
}
}
}
示例7: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的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);
}
}
}
}
}
示例8: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的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);
}
}
}
}
}
示例9: maybeReturnResult
import com.google.zxing.Result; //导入方法依赖的package包/类
private static Result maybeReturnResult(Result result) throws FormatException {
String text = result.getText();
if (text.charAt(0) == '0') {
return new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
} else {
throw FormatException.getFormatInstance();
}
}
示例10: drawResultPoints
import com.google.zxing.Result; //导入方法依赖的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(Color.parseColor("#c099cc00"));
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);
}
}
}
}
}
示例11: decode
import com.google.zxing.Result; //导入方法依赖的package包/类
public Result decode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
NotFoundException, FormatException {
Result doDecode;
try {
doDecode = doDecode(image, hints);
} catch (NotFoundException nfe) {
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
if (tryHarder && image.isRotateSupported()) {
BinaryBitmap rotatedImage = image.rotateCounterClockwise();
doDecode = doDecode(rotatedImage, hints);
Map<ResultMetadataType, ?> metadata = doDecode.getResultMetadata();
int orientation = 270;
if (metadata != null && metadata.containsKey(ResultMetadataType.ORIENTATION)) {
orientation = (((Integer) metadata.get(ResultMetadataType.ORIENTATION))
.intValue() + 270) % 360;
}
doDecode.putMetadata(ResultMetadataType.ORIENTATION, Integer.valueOf(orientation));
ResultPoint[] points = doDecode.getResultPoints();
if (points != null) {
int height = rotatedImage.getHeight();
for (int i = 0; i < points.length; i++) {
points[i] = new ResultPoint((((float) height) - points[i].getY()) - 1.0f,
points[i].getX());
}
}
} else {
throw nfe;
}
}
return doDecode;
}
示例12: decodeRow
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException {
// Compute this location once and reuse it on multiple implementations
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
for (UPCEANReader reader : readers) {
Result result;
try {
result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
} catch (ReaderException ignored) {
continue;
}
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
// Individually these are correct and their readers will both read such a code
// and correctly call it EAN-13, or UPC-A, respectively.
//
// In this case, if we've been looking for both types, we'd like to call it
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
//
// But, don't return UPC-A if UPC-A was not a requested format!
boolean ean13MayBeUPCA =
result.getBarcodeFormat() == BarcodeFormat.EAN_13 &&
result.getText().charAt(0) == '0';
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats =
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
if (ean13MayBeUPCA && canReturnUPCA) {
// Transfer the metdata across
Result resultUPCA = new Result(result.getText().substring(1),
result.getRawBytes(),
result.getResultPoints(),
BarcodeFormat.UPC_A);
resultUPCA.putAllMetadata(result.getResultMetadata());
return resultUPCA;
}
return result;
}
throw NotFoundException.getNotFoundInstance();
}
示例13: decodeRow
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
public Result decodeRow(int rowNumber,
BitArray row,
Map<DecodeHintType,?> hints) throws NotFoundException {
// Compute this location once and reuse it on multiple implementations
int[] startGuardPattern = UPCEANReader.findStartGuardPattern(row);
for (UPCEANReader reader : readers) {
try {
Result result = reader.decodeRow(rowNumber, row, startGuardPattern, hints);
// Special case: a 12-digit code encoded in UPC-A is identical to a "0"
// followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
// UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
// Individually these are correct and their readers will both read such a code
// and correctly call it EAN-13, or UPC-A, respectively.
//
// In this case, if we've been looking for both types, we'd like to call it
// a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
//
// But, don't return UPC-A if UPC-A was not a requested format!
boolean ean13MayBeUPCA =
result.getBarcodeFormat() == BarcodeFormat.EAN_13 &&
result.getText().charAt(0) == '0';
@SuppressWarnings("unchecked")
Collection<BarcodeFormat> possibleFormats =
hints == null ? null : (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
boolean canReturnUPCA = possibleFormats == null || possibleFormats.contains(BarcodeFormat.UPC_A);
if (ean13MayBeUPCA && canReturnUPCA) {
// Transfer the metdata across
Result resultUPCA = new Result(result.getText().substring(1),
result.getRawBytes(),
result.getResultPoints(),
BarcodeFormat.UPC_A);
resultUPCA.putAllMetadata(result.getResultMetadata());
return resultUPCA;
}
return result;
} catch (ReaderException ignored) {
// continue
}
}
throw NotFoundException.getNotFoundInstance();
}
示例14: doInBackground
import com.google.zxing.Result; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... ignored) {
if (isCancelled()) {
return null;
}
Camera.Size size = camera.getParameters().getPreviewSize();
int width = size.width;
int height = size.height;
// rotate for zxing if orientation is portrait
if (RCTCamera.getInstance().getActualDeviceOrientation() == 0) {
byte[] rotated = new byte[imageData.length];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
rotated[x * height + height - y - 1] = imageData[x + y * width];
}
}
width = size.height;
height = size.width;
imageData = rotated;
}
try {
PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(imageData, width, height, 0, 0, width, height, false);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Result result = _multiFormatReader.decodeWithState(bitmap);
ReactContext reactContext = RCTCameraModule.getReactContextSingleton();
WritableMap event = Arguments.createMap();
WritableArray resultPoints = Arguments.createArray();
ResultPoint[] points = result.getResultPoints();
if(points != null) {
for (ResultPoint point : points) {
WritableMap newPoint = Arguments.createMap();
newPoint.putString("x", String.valueOf(point.getX()));
newPoint.putString("y", String.valueOf(point.getY()));
resultPoints.pushMap(newPoint);
}
}
event.putArray("bounds", resultPoints);
event.putString("data", result.getText());
event.putString("type", result.getBarcodeFormat().toString());
reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class).emit("CameraBarCodeReadAndroid", event);
} catch (Throwable t) {
// meh
} finally {
_multiFormatReader.reset();
RCTCameraViewFinder.barcodeScannerTaskLock = false;
return null;
}
}
示例15: doDecode
import com.google.zxing.Result; //导入方法依赖的package包/类
private Result doDecode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws
NotFoundException {
int maxLines;
int width = image.getWidth();
int height = image.getHeight();
BitArray row = new BitArray(width);
int middle = height >> 1;
boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
int rowStep = Math.max(1, height >> (tryHarder ? 8 : 5));
if (tryHarder) {
maxLines = height;
} else {
maxLines = 15;
}
for (int x = 0; x < maxLines; x++) {
int rowStepsAboveOrBelow = (x + 1) / 2;
if (!((x & 1) == 0)) {
rowStepsAboveOrBelow = -rowStepsAboveOrBelow;
}
int rowNumber = middle + (rowStep * rowStepsAboveOrBelow);
if (rowNumber < 0 || rowNumber >= height) {
break;
}
try {
row = image.getBlackRow(rowNumber, row);
int attempt = 0;
while (attempt < 2) {
if (attempt == 1) {
row.reverse();
if (hints != null && hints.containsKey(DecodeHintType
.NEED_RESULT_POINT_CALLBACK)) {
Map<DecodeHintType, Object> newHints = new EnumMap(DecodeHintType
.class);
newHints.putAll(hints);
newHints.remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
hints = newHints;
}
}
try {
Result result = decodeRow(rowNumber, row, hints);
if (attempt == 1) {
result.putMetadata(ResultMetadataType.ORIENTATION, Integer.valueOf
(180));
ResultPoint[] points = result.getResultPoints();
if (points != null) {
points[0] = new ResultPoint((((float) width) - points[0].getX())
- 1.0f, points[0].getY());
points[1] = new ResultPoint((((float) width) - points[1].getX())
- 1.0f, points[1].getY());
}
}
return result;
} catch (ReaderException e) {
attempt++;
}
}
continue;
} catch (NotFoundException e2) {
}
}
throw NotFoundException.getNotFoundInstance();
}