无法使用Java中的Google Zxing从子图像获取条形码值
使用ZXing,我尝试从输入图像获取条形码值。我使用以下代码获取条形码值。
BufferedImage img = ImageIO.read(new File("C:/Demo_Project/Project/input.jpeg"));
BufferedImage subimage = img.getSubimage(350, 300, 600, 600); // Since few posts mentioned like if filesize exceeds Zxing not works properly. I get subimage of barcode part from actual image.
LuminanceSource source = new BufferedImageLuminanceSource(subimage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
Result result = reader.decode(bitmap);
System.out.println("Barcode is ::"+result.getText());
低于例外,
com.google.zxing.notfoundexception。
任何修复或其他直接方法都可以从图像文件中获取条形码值。我的iamge文件实际上是在接近8MB的移动相机中获取的。获得子图像后,它变为4至10 kb,我的形象仍然无法正确识别。任何帮助将不胜感激。 当然,我已经验证了子图像包含条形码。请参阅附件。
Using Zxing I tried to get barcode value from input image. I used the below code for getting barcode value.
BufferedImage img = ImageIO.read(new File("C:/Demo_Project/Project/input.jpeg"));
BufferedImage subimage = img.getSubimage(350, 300, 600, 600); // Since few posts mentioned like if filesize exceeds Zxing not works properly. I get subimage of barcode part from actual image.
LuminanceSource source = new BufferedImageLuminanceSource(subimage);
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
Result result = reader.decode(bitmap);
System.out.println("Barcode is ::"+result.getText());
Getting below exception,
com.google.zxing.NotFoundException .
Any fixes or other straight forward approaches to get barcode value from image files. My iamge files are actually taken in mobile camera which sizes close to 8MB. After getting subimage it become 4 to 10 KB still my image is not recognized properly. Any help would be appreciated.
Of course, I have verified the sub-image contains the barcode. Please see the attachment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论