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


Java Binarizer类代码示例

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


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

示例1: decodeQr

import com.google.zxing.Binarizer; //导入依赖的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

示例2: decodeQr

import com.google.zxing.Binarizer; //导入依赖的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:guokezheng,项目名称:automat,代码行数:20,代码来源:QrcodeUtil.java

示例3: readQrCode

import com.google.zxing.Binarizer; //导入依赖的package包/类
/**
 * 读取二维码
 * @param qrCodeFile
 * @return
 */
public String readQrCode(File qrCodeFile){
	String ret = null;
	try {			
		QRCodeReader reader = new QRCodeReader();
		BufferedImage image = ImageIO.read(qrCodeFile);
		LuminanceSource source = new BufferedImageLuminanceSource(image);
		Binarizer binarizer = new HybridBinarizer(source);
		BinaryBitmap imageBinaryBitmap = new BinaryBitmap(binarizer);
		Result result = reader.decode(imageBinaryBitmap);
		ret = result.getText();
	} catch (IOException |NotFoundException | ChecksumException | FormatException e) {
		Exceptions.printException(e);
	}
	return ret;		
}
 
开发者ID:simbest,项目名称:simbest-cores,代码行数:21,代码来源:QrCodeUtil.java

示例4: parse

import com.google.zxing.Binarizer; //导入依赖的package包/类
private static void parse() throws IOException, NotFoundException, ChecksumException, FormatException {
	BufferedImage image = ImageReader.readImage(Paths.get("d:/qr.png").toUri());
	LuminanceSource source = new BufferedImageLuminanceSource(image);
	Binarizer bin = new HybridBinarizer(source);
	BinaryBitmap bitmap = new BinaryBitmap(bin);
	Result result = new QRCodeReader().decode(bitmap);
	System.out.println(result.toString());
}
 
开发者ID:yoking-zhang,项目名称:demo,代码行数:9,代码来源:QRGeneratorTest.java

示例5: binarization

import com.google.zxing.Binarizer; //导入依赖的package包/类
private Bitmap binarization(Bitmap bitmap, int lowColor, int highColor) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int pixels[] = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
    LuminanceSource source = new RGBLuminanceSource(width, height, pixels);
    Binarizer binarizer = new HybridBinarizer(source);

    Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

    try {
        BitMatrix matrix = binarizer.getBlackMatrix();
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < width; j++) {
                if (matrix.get(j, i)) {
                    result.setPixel(j, i, highColor);
                } else {
                    result.setPixel(j, i, lowColor);
                }
            }
        }
    } catch (NotFoundException e) {
        e.printStackTrace();
    }

    return result;
}
 
开发者ID:Tinker-S,项目名称:FaceBarCodeDemo,代码行数:28,代码来源:FaceQREffect.java

示例6: binarization

import com.google.zxing.Binarizer; //导入依赖的package包/类
/**
     * 二值化
     *
     * @param bitmap
     * @return
     */
    private Bitmap binarization(Bitmap bitmap, int lowColor, int highStartColor, int highEndColor) {
        int width = bitmap.getWidth();
        int height = bitmap.getHeight();
        int pixels[] = new int[width * height];
        bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
        LuminanceSource source = new RGBLuminanceSource(width, height, pixels);
        Binarizer binarizer = new HybridBinarizer(source);

        Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

        try {
            BitMatrix matrix = binarizer.getBlackMatrix();
            int highColor;
            for (int i = 0; i < height; i++) {
//                highColor = getGradientColor(highStartColor, highEndColor, i / (float) height);
                highColor = getGradientColorByCurve(highStartColor, highEndColor, 0, height, i);
                for (int j = 0; j < width; j++) {
                    if (matrix.get(j, i)) {
                        result.setPixel(j, i, highColor);
                    } else {
                        result.setPixel(j, i, lowColor);
                    }
                }
            }
        } catch (NotFoundException e) {
            e.printStackTrace();
        }

        return result;
    }
 
开发者ID:Tinker-S,项目名称:FaceBarCodeDemo,代码行数:37,代码来源:GradientQREffect.java

示例7: createBinarizer

import com.google.zxing.Binarizer; //导入依赖的package包/类
@Override
public Binarizer createBinarizer(LuminanceSource source) {
  return new GlobalHistogramBinarizer(source);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:5,代码来源:GlobalHistogramBinarizer.java

示例8: createBinarizer

import com.google.zxing.Binarizer; //导入依赖的package包/类
@Override
public Binarizer createBinarizer(LuminanceSource source) {
  return new HybridBinarizer(source);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:5,代码来源:HybridBinarizer.java

示例9: createBinarizer

import com.google.zxing.Binarizer; //导入依赖的package包/类
public Binarizer createBinarizer(LuminanceSource source) {
    return new GlobalHistogramBinarizer(source);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:GlobalHistogramBinarizer.java

示例10: createBinarizer

import com.google.zxing.Binarizer; //导入依赖的package包/类
public Binarizer createBinarizer(LuminanceSource source) {
    return new HybridBinarizer(source);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:HybridBinarizer.java

示例11: createBinarizer

import com.google.zxing.Binarizer; //导入依赖的package包/类
@Override
public Binarizer createBinarizer(LuminanceSource source) {
    return new GlobalHistogramBinarizer(source);
}
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:5,代码来源:GlobalHistogramBinarizer.java

示例12: createBinarizer

import com.google.zxing.Binarizer; //导入依赖的package包/类
@Override
public Binarizer createBinarizer(LuminanceSource source) {
    return new HybridBinarizer(source);
}
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:5,代码来源:HybridBinarizer.java


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