用的使用手册里的二维码

代码
public Map qr(MultipartFile img) throws IOException, FormatException, ChecksumException, NotFoundException { Map<String,String> hashMap = new HashMap<>(); log.info(img.getOriginalFilename()); BufferedImage qrImg = ImageIO.read(img.getInputStream()); LuminanceSource source = new BufferedImageLuminanceSource(qrImg); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); QRCodeReader qrCodeReader = new QRCodeReader(); Result result = qrCodeReader.decode(bitmap); hashMap.put("res",result.getText()); return hashMap; }
报错如下
{ "timestamp": "2021-02-24T14:24:38.823+00:00", "status": 500, "error": "Internal Server Error", "trace": "com.google.zxing.NotFoundException\r\n", "message": "No message available", "path": "/qrdecode" }
普通的二维码没事。
用的使用手册里的二维码

代码
public Map qr(MultipartFile img) throws IOException, FormatException, ChecksumException, NotFoundException { Map<String,String> hashMap = new HashMap<>(); log.info(img.getOriginalFilename()); BufferedImage qrImg = ImageIO.read(img.getInputStream()); LuminanceSource source = new BufferedImageLuminanceSource(qrImg); BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); QRCodeReader qrCodeReader = new QRCodeReader(); Result result = qrCodeReader.decode(bitmap); hashMap.put("res",result.getText()); return hashMap; }报错如下
{ "timestamp": "2021-02-24T14:24:38.823+00:00", "status": 500, "error": "Internal Server Error", "trace": "com.google.zxing.NotFoundException\r\n", "message": "No message available", "path": "/qrdecode" }普通的二维码没事。