X-Git-Url: http://git.rot13.org/?p=zxing.git;a=blobdiff_plain;f=zxingorg%2Fsrc%2Fcom%2Fgoogle%2Fzxing%2Fweb%2FDecodeServlet.java;h=ea213d3fa3cb7f9f7b55e252bebf2f878866777b;hp=2f5e198f0e54f3b33edae7d12d4f9ee475563e63;hb=8c91e26190f4d312f0c5d000d676efadd352ef81;hpb=de6f57f5cfd923b42c2c9665b2db381c3a7a3f53 diff --git a/zxingorg/src/com/google/zxing/web/DecodeServlet.java b/zxingorg/src/com/google/zxing/web/DecodeServlet.java index 2f5e198f..ea213d3f 100644 --- a/zxingorg/src/com/google/zxing/web/DecodeServlet.java +++ b/zxingorg/src/com/google/zxing/web/DecodeServlet.java @@ -63,6 +63,7 @@ import java.net.SocketException; import java.net.URI; import java.net.URISyntaxException; import java.net.UnknownHostException; +import java.util.Collection; import java.util.Hashtable; import java.util.List; import java.util.Vector; @@ -93,7 +94,7 @@ public final class DecodeServlet extends HttpServlet { static { HINTS = new Hashtable(5); HINTS.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); - Vector possibleFormats = new Vector(); + Collection possibleFormats = new Vector(); possibleFormats.add(BarcodeFormat.UPC_A); possibleFormats.add(BarcodeFormat.UPC_E); possibleFormats.add(BarcodeFormat.EAN_8); @@ -253,9 +254,16 @@ public final class DecodeServlet extends HttpServlet { BinaryBitmap bitmap = new BinaryBitmap(new GlobalHistogramBinarizer(source)); result = reader.decode(bitmap, HINTS); } catch (ReaderException re) { - log.info("DECODE FAILED: " + re.toString()); - response.sendRedirect("notfound.jspx"); - return; + try { + // Try again with other binarizer + LuminanceSource source = new BufferedImageLuminanceSource(image); + BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source)); + result = reader.decode(bitmap, HINTS); + } catch (ReaderException re2) { + log.info("DECODE FAILED: " + re.toString()); + response.sendRedirect("notfound.jspx"); + return; + } } if (request.getParameter("full") == null) {