title: com.google.zxing.NotFoundException while using zxing to decode qrcode
body: <p>We are using zxing to decode qrcode from images, most of qrcode could normally be extracted from the original images, but some not. I will show the decoder codes and shall we together discuss about what causes NotFoundException and find out solutions. </p>
  
  <p>First of all, need some zxing dependencies:</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;
      &lt;artifactId&gt;core&lt;/artifactId&gt;
      &lt;version&gt;3.2.1&lt;/version&gt;
  &lt;/dependency&gt;
  
  &lt;dependency&gt;
    &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;
    &lt;artifactId&gt;javase&lt;/artifactId&gt;
    &lt;version&gt;3.2.1&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Then see the detail codes:</p>
  
  <pre><code> public static String decodeQrCode(BufferedImage image) throws DependencyServiceException
  {
      // Convert the image to a binary bitmap source
      LuminanceSource source = new BufferedImageLuminanceSource(image);
      BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
  
      // Decode the barcode
      QRCodeReader reader = new QRCodeReader();
      Result result = null;
      try
      {
          result = reader.decode(bitmap);
      }
      catch (NotFoundException | ChecksumException | FormatException e)
      {
          throw new DependencyServiceException(e);
      }
      return result == null ? null : result.getText();
  }
  
  public static void main(String[] args)
  {
      File file = new File("/tmp/ivan_qr_code.jpg");
      String qrCodeOriginUrlExtracted = "";
      try
      {
          FileInputStream imageInFile = new FileInputStream(file);
          byte imageData[] = new byte[(int) file.length()];
          imageInFile.read(imageData);
  
          String qrCodeBase64 = Base64.encodeBase64URLSafeString(imageData);
          BufferedImage image = Base64StringToImageUtil.generateImageFromString(qrCodeBase64);
          qrCodeOriginUrlExtracted = QrCodeDecoderUtil.decodeQrCode(image);
          imageInFile.close();
      }
      catch (Exception e)
      {
          // TODO: handle exception
      }
      System.out.println(String.format("Extracted text from qr code: %1$s", qrCodeOriginUrlExtracted));
  }
  </code></pre>
  
  <p>Errors generated:</p>
  
  <pre><code>Exception in thread "main"  {"errorCode": "3000", "debugInfo":"null","message": "com.google.zxing.NotFoundException"}
  at com.waijule.common.util.image.QrCodeDecoderUtil.decodeQrCode(QrCodeDecoderUtil.java:44)
  at com.waijule.common.util.image.QrCodeDecoderUtil.main(QrCodeDecoderUtil.java:58)
  </code></pre>
  
  <p>Caused by: com.google.zxing.NotFoundException</p>
  
  <p>The template qr code provided as following:</p>
  
  <p><a href="https://i.stack.imgur.com/mhIbM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mhIbM.jpg" alt="enter image description here"></a></p>
  
  <p>Thanks for all the little helps. </p>