1

I have developed an app for reading bar codes using the ZXing library, it works without problems with short codes such as:

Short Bar Code

enter image description here

but with long codes like the following, the program simply can not get any reading:

Long Bar Code

enter image description here

Any ideas on how to solve this? I need to read longer bar codes

vm345
  • 813
  • 12
  • 28
César Troya
  • 11
  • 1
  • 2
  • Welcome to StackOverflow. You should [edit](https://stackoverflow.com/posts/49164833/edit) your question with additional info like: What did you try? Did you check if the actual camera image is too fuzzy to decode or the barcode format/length isn't acceptable? ZXing is open source so if you can look at the source to see if you can change something to make it work for you. – Morrison Chang Mar 08 '18 at 03:38
  • You can try this [barcode scanner](https://play.google.com/store/apps/details?id=com.barcodereader) which also using zxing for 1d scanning, I have just scanned this barcode and its gets scanned in fraction of seconds I think u just need to check this barcode type from Zxing settings – Akash Dubey Mar 09 '18 at 05:23

1 Answers1

0

I don't think the problem lies with ZXing.

As the barcode given in the question is a Code 128 format, which is supported by ZXing and the image attached in question is successfully scanned by ZXing Online Decoder and the output of scanned image is as:

+--------------------+----------------------------+
| Raw text           | DSEC3743T0040001P96837678  |
+--------------------+----------------------------+
| Raw bytes          | 68 24 33 25 23 63 25 2b    |
|                    | 64 34 10 63 04 00 01 64    |
|                    | 30 63 60 53 4c 4e 54 6a    |
+--------------------+----------------------------+
| Barcode format     | CODE_128                   |
+--------------------+----------------------------+
| Parsed Result Type | TEXT                       |
+--------------------+----------------------------+
| Parsed Result      | DSEC3743T0040001P96837678  |
+--------------------+----------------------------+

The image is too long to be scanned properly by certain phone's camera, as ZXing receives callbacks from screen while camera is on so make sure barcode is properly focused and camera is not that shaky.

global_warming
  • 833
  • 1
  • 7
  • 11
  • "The image is too long to be scanned properly by phone's camera" Do you have any evidence to support this? Barcode Scanner+, which is basically ZXing with portrait mode, reads it just fine. – Enrico Mar 08 '18 at 08:08
  • The problem is not with ZXing, my OnePlus 5 also scans the code with simple QR integrated app, while Moto E 2015 doesn't. So it depends on camera quality as there is no limit on digits for scanning Code 128 barcodes. – global_warming Mar 08 '18 at 09:04
  • Fair enough, I think that's worth clarifying in your post. Very small and very long barcodes are difficult to scan with _certain_ phone cameras. Does the Moto E camera have an infinite depth of field - i.e. no autofocus? I think those phones typically have the most trouble scanning barcodes – Enrico Mar 09 '18 at 02:46
  • @Enrico yeah right, but Moto E does have autofocus. – global_warming Mar 09 '18 at 04:51