当前位置: 首页>>代码示例>>Java>>正文


Java DecodeHintType类代码示例

本文整理汇总了Java中com.google.zxing.DecodeHintType的典型用法代码示例。如果您正苦于以下问题:Java DecodeHintType类的具体用法?Java DecodeHintType怎么用?Java DecodeHintType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DecodeHintType类属于com.google.zxing包,在下文中一共展示了DecodeHintType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DecodeThread

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
DecodeThread(CaptureActivity activity,
             Vector<BarcodeFormat> decodeFormats,
             String characterSet,
             ResultPointCallback resultPointCallback) {

  this.activity = activity;
  handlerInitLatch = new CountDownLatch(1);

  hints = new Hashtable<DecodeHintType, Object>(3);

  if (decodeFormats == null || decodeFormats.isEmpty()) {
  	 decodeFormats = new Vector<BarcodeFormat>();
  	 decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
  	 decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
  	 decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
  }
  
  hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

  if (characterSet != null) {
    hints.put(DecodeHintType.CHARACTER_SET, characterSet);
  }

  hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK, resultPointCallback);
}
 
开发者ID:CoderCF,项目名称:ZXingDemo,代码行数:26,代码来源:DecodeThread.java

示例2: DecodeThread

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
DecodeThread(CaptureActivity activity,
                Collection<BarcodeFormat> decodeFormats, String characterSet,
                ResultPointCallback resultPointCallback) {

	this.activity = activity;
	handlerInitLatch = new CountDownLatch(1);

	hints = new Hashtable<DecodeHintType, Object>(3);

	if (decodeFormats == null || decodeFormats.isEmpty()) {
		decodeFormats = new Vector<BarcodeFormat>();
		decodeFormats.addAll(ONE_D_FORMATS);
		decodeFormats.addAll(QR_CODE_FORMATS);
		decodeFormats.addAll(DATA_MATRIX_FORMATS);
	}
	hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);

	if (characterSet != null) {
		hints.put(DecodeHintType.CHARACTER_SET, characterSet);
	}
	hints.put(DecodeHintType.NEED_RESULT_POINT_CALLBACK,
			resultPointCallback);
	Log.i("DecodeThread", "Hints: " + hints);
}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:25,代码来源:DecodeThread.java

示例3: CaptureActivityHandler

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
          new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
开发者ID:kkyflying,项目名称:CodeScaner,代码行数:17,代码来源:CaptureActivityHandler.java

示例4: BarcodeReaderHandler

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
BarcodeReaderHandler(BarcodeReaderView barcodeReaderView,
                     Collection<BarcodeFormat> decodeFormats,
                     Map<DecodeHintType, ?> baseHints,
                     String characterSet,
                     ResultPointCallback resultPointCallback,
                     CameraManager cameraManager) {
    this.barcodeReaderView = barcodeReaderView;
    decodeThread = new DecodeThread(barcodeReaderView, decodeFormats, baseHints, characterSet, resultPointCallback);
    decodeThread.start();
    state = State.SUCCESS;

    // Start ourselves capturing previews and decoding.
    this.cameraManager = cameraManager;
    cameraManager.startPreview();
    restartPreviewAndDecode();
}
 
开发者ID:CoderChoy,项目名称:BarcodeReaderView,代码行数:17,代码来源:BarcodeReaderHandler.java

示例5: decodeQr

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
public static String decodeQr(String filePath) {
    String retStr = "";
    if ("".equalsIgnoreCase(filePath) && filePath.length() == 0) {
        return "图片路径为空!";
    }
    try {
        BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filePath));
        LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
        Binarizer binarizer = new HybridBinarizer(source);
        BinaryBitmap bitmap = new BinaryBitmap(binarizer);
        HashMap<DecodeHintType, Object> hintTypeObjectHashMap = new HashMap<>();
        hintTypeObjectHashMap.put(DecodeHintType.CHARACTER_SET, "UTF-8");
        Result result = new MultiFormatReader().decode(bitmap, hintTypeObjectHashMap);
        retStr = result.getText();
    } catch (Exception e) {
        logger.error("", e);
    }
    return retStr;
}
 
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:20,代码来源:QrcodeUtil.java

示例6: decodeByteSegment

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
private static void decodeByteSegment(BitSource bits, StringBuilder result, int count,
                                      CharacterSetECI currentCharacterSetECI,
                                      Collection<byte[]> byteSegments, Map<DecodeHintType, ?>
                                              hints) throws FormatException {
    if (count * 8 > bits.available()) {
        throw FormatException.getFormatInstance();
    }
    String encoding;
    byte[] readBytes = new byte[count];
    for (int i = 0; i < count; i++) {
        readBytes[i] = (byte) bits.readBits(8);
    }
    if (currentCharacterSetECI == null) {
        encoding = StringUtils.guessEncoding(readBytes, hints);
    } else {
        encoding = currentCharacterSetECI.name();
    }
    try {
        result.append(new String(readBytes, encoding));
        byteSegments.add(readBytes);
    } catch (UnsupportedEncodingException e) {
        throw FormatException.getFormatInstance();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:25,代码来源:DecodedBitStreamParser.java

示例7: CaptureActivityHandler

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
CaptureActivityHandler(QrCodeScannerActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType, ?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
    this.activity = activity;
    decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
            new ViewfinderResultPointCallback(activity.getViewfinderView()));
    decodeThread.start();
    state = State.SUCCESS;

    // Start ourselves capturing previews and decoding.
    this.cameraManager = cameraManager;
    cameraManager.startPreview();
    restartPreviewAndDecode();
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:17,代码来源:CaptureActivityHandler.java

示例8: decodePair

import com.google.zxing.DecodeHintType; //导入依赖的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;
  }
}
 
开发者ID:simplezhli,项目名称:Tesseract-OCR-Scanner,代码行数:27,代码来源:RSS14Reader.java

示例9: analyzeBitmap

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
/**
 * 解析二维码图片工具类
 *
 * @param bitmap
 */
public static String analyzeBitmap(Bitmap bitmap) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();

    // 解码的参数
    Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(2);
    // 可以解析的编码类型
    Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>();
    if (decodeFormats == null || decodeFormats.isEmpty()) {
        decodeFormats = new Vector<BarcodeFormat>();

        // 这里设置可扫描的类型,我这里选择了都支持
        decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }
    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    // 设置继续的字符编码格式为UTF8
    hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
    // 设置解析配置参数
    multiFormatReader.setHints(hints);

    // 开始对图像资源解码
    Result rawResult = null;
    try {
        rawResult = multiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(bitmap))));
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (rawResult != null) {
        return rawResult.getText();
    } else {
        return "Failed";
    }
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:41,代码来源:ImageUtils.java

示例10: MultiFormatUPCEANReader

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
public MultiFormatUPCEANReader(Map<DecodeHintType,?> hints) {
  @SuppressWarnings("unchecked")
  Collection<BarcodeFormat> possibleFormats = hints == null ? null :
      (Collection<BarcodeFormat>) hints.get(DecodeHintType.POSSIBLE_FORMATS);
  Collection<UPCEANReader> readers = new ArrayList<>();
  if (possibleFormats != null) {
    if (possibleFormats.contains(BarcodeFormat.EAN_13)) {
      readers.add(new EAN13Reader());
    } else if (possibleFormats.contains(BarcodeFormat.UPC_A)) {
      readers.add(new UPCAReader());
    }
    if (possibleFormats.contains(BarcodeFormat.EAN_8)) {
      readers.add(new EAN8Reader());
    }
    if (possibleFormats.contains(BarcodeFormat.UPC_E)) {
      readers.add(new UPCEReader());
    }
  }
  if (readers.isEmpty()) {
    readers.add(new EAN13Reader());
    // UPC-A is covered by EAN-13
    readers.add(new EAN8Reader());
    readers.add(new UPCEReader());
  }
  this.readers = readers.toArray(new UPCEANReader[readers.size()]);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:MultiFormatUPCEANReader.java

示例11: decodePair

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
private Pair decodePair(BitArray row, boolean right, int rowNumber, Map<DecodeHintType,?> hints) {
  try {
    int[] startEnd = findFinderPattern(row, 0, 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;
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:RSS14Reader.java

示例12: CaptureActivityHandler

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
CaptureActivityHandler(CaptureActivity activity,
                       Collection<BarcodeFormat> decodeFormats,
                       Map<DecodeHintType,?> baseHints,
                       String characterSet,
                       CameraManager cameraManager) {
  this.activity = activity;
  decodeThread = new DecodeThread(activity, decodeFormats, baseHints, characterSet,
      new ViewfinderResultPointCallback(activity.getViewfinderView()));
  decodeThread.start();
  state = State.SUCCESS;

  // Start ourselves capturing previews and decoding.
  this.cameraManager = cameraManager;
  cameraManager.startPreview();
  restartPreviewAndDecode();
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:17,代码来源:CaptureActivityHandler.java

示例13: decodeQr

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
public static String decodeQr(String filePath) {
	String retStr = "";
	if ("".equalsIgnoreCase(filePath) && filePath.length() == 0) {
		return "图片路径为空!";
	}
	try {
		BufferedImage bufferedImage = ImageIO.read(new FileInputStream(filePath));
		LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
		Binarizer binarizer = new HybridBinarizer(source);
		BinaryBitmap bitmap = new BinaryBitmap(binarizer);
		HashMap<DecodeHintType, Object> hintTypeObjectHashMap = new HashMap<>();
		hintTypeObjectHashMap.put(DecodeHintType.CHARACTER_SET, "UTF-8");
		Result result = new MultiFormatReader().decode(bitmap, hintTypeObjectHashMap);
		retStr = result.getText();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return retStr;
}
 
开发者ID:youngMen1,项目名称:JAVA-,代码行数:20,代码来源:QrcodeUtil.java

示例14: decode

import com.google.zxing.DecodeHintType; //导入依赖的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;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:27,代码来源:DataMatrixReader.java

示例15: detectMulti

import com.google.zxing.DecodeHintType; //导入依赖的package包/类
public DetectorResult[] detectMulti(Map<DecodeHintType,?> hints) throws NotFoundException {
  BitMatrix image = getImage();
  ResultPointCallback resultPointCallback =
      hints == null ? null : (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
  MultiFinderPatternFinder finder = new MultiFinderPatternFinder(image, resultPointCallback);
  FinderPatternInfo[] infos = finder.findMulti(hints);

  if (infos.length == 0) {
    throw NotFoundException.getNotFoundInstance();
  }

  List<DetectorResult> result = new ArrayList<>();
  for (FinderPatternInfo info : infos) {
    try {
      result.add(processFinderPatternInfo(info));
    } catch (ReaderException e) {
      // ignore
    }
  }
  if (result.isEmpty()) {
    return EMPTY_DETECTOR_RESULTS;
  } else {
    return result.toArray(new DetectorResult[result.size()]);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:26,代码来源:MultiDetector.java


注:本文中的com.google.zxing.DecodeHintType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。