这是一个车身VIN码
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Hashtable;import javax.imageio.ImageIO;import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;/**
 * @blog http://sjsky.iteye.com
 * @author Michael
 */
public class ZxingDecoderHandler {    /**
     * @param imgPath
     * @return String
     */
    public String decode(String imgPath) {
        BufferedImage image = null;
        Result result = null;
        try {
            image = ImageIO.read(new File(imgPath));
            if (image == null) {
                System.out.println("the decode image may be not exit.");
            }
            LuminanceSource source = new BufferedImageLuminanceSource(image);
            BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));            Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
            hints.put(DecodeHintType.CHARACTER_SET, "utf-8");            result = new MultiFormatReader().decode(bitmap, hints);
            return result.getText();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }    /**
     * @param args
     */
    public static void main(String[] args) {
        String imgPath = "D:/code39_0.jpg";
        ZxingDecoderHandler handler = new ZxingDecoderHandler();
        String decodeContent = handler.decode(imgPath);
        System.out.println("OK");
        System.out.println(decodeContent);  
    }
}
使用上面的代码老是提示com.google.zxing.NotFoundException

解决方案 »

  1.   

    那你肯定要下载这个zxing以及他相关jar包才可以使用。https://code.google.com/p/zxing/
      

  2.   

    可以的,NotFoundException说明解析的不正确。
      

  3.   

    二维码可以识别 条形码就一直报NOT FOUND ....
      

  4.   

    解决了~ 把图片转成byte[] yuvdata 放入PlanarYUVLuminanceSource  模仿相机扫描的原理
      

  5.   

    http://www.java2s.com/Code/JarDownload/zxing/zxing-javase.jar.zip
    把这个下载下来,解压,导入jar包
      

  6.   

    还有一种可能是,你这个条形码的图不是code39编码(甚至不是code系列编码)
      

  7.   

    BufferedImage    ImageIO   BufferedImageLuminanceSource 这三个是在干什么??
      

  8.   

    楼主能不能发全代码,BufferedImage    ImageIO   BufferedImageLuminanceSource 这三个是在干什么??不会写啊