2

Is barcode scanning with an ESP32 possible? Is there an existing project, of a library that I could use?

Any idea how to go about it?

If not feasible, would it make sense to stream video from the ESP32's camera to a server and have the server detect the barcode, then signal success to the ESP32?


[Update] just to be clear, I want to make a portable device.

Also, I would prefer to use the ESP32's camera, rather than adding barcode reading hardware, although I won't rule that out, if it is the only solution

Mawg
  • 3,147
  • 1
  • 13
  • 35

3 Answers3

2

If you get a CCD or laser barcode module with RS232 or TTL output, it's pretty straightforward. The decoding is handled for you and you just need to read the serial data that it outputs.

John S
  • 481
  • 2
  • 7
2

I don't happen to have one of these with me, but I think you could have some fun with a laser and some CV.

Laser barcode scanners work by shining a laser line on the code and reading how the light reflects back to it. If you have a laser (I would recommend green, based on some 3D scanning tests in the past) and a camera, why not trying to make it happen?

Go ahead and 3D print a case for the ESPcam and the laser, tweak some camera parameters (exposure and brightness) and see if the image gets you some results.

barcode

The image above shows a barcode on a white background with a 7pt green line with 50% opacity on top of it. Note how the colors differ. Now setup some thresholds and you should be able to see only the light on top of the white parts. Voila, you are done.

That is a hardware solution, with some very simple computer vision. Thresholds and color filtering should be good for the ESP32 to handle. If you want a software-only solution, you can always convert the barcode to the vertical lines and play with their distance, which should also not be a problem for the LX6 beast (Or, would it?).

If it shows not feasible, I'm sure that you can do this with some python a RPi and stream the image data with some simple HTTP (base 64, you know). Server response gets you the data. With the expected delays and errors.

1

I suppose that I could just purchase a portable barcode reader with BlueTooth, read from that & use the ESP's WiFi to communicate with my server, but, realistically, I don't really see the point of the ESP32 in that scenario.

As a project, it would be fun to do it myself, and I still hope for alternatives, but, as an actual answer, I think that this particular wheel has already been invented.

Mawg
  • 3,147
  • 1
  • 13
  • 35