當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。