Code Monkey home page Code Monkey logo

esp32qrcodereader's Introduction

ESP32 QR Code Reader

This library provides a interface to read QR Codes using an ESP32 with a camera.

Internally this lib uses a slight modified version of the Quirc library and some code from OpenMV port on the MaixPy project.

Demos

Usage

Is recommended to use PlatformIO to install this lib. Add ESP32QRCodeReader to your platformio.ini file.

From PlatformIO library:

lib_deps=
  ESP32QRCodeReader

Directly from Github:

lib_deps =
  alvarowolfx/ESP32QRCodeReader

Examples

This library comes with a number of example sketches. See File > Examples > ESP32QRCodeReader within the Arduino application. You can see them on the examples folder on this repository.

Basic example:

#include <ESP32QRCodeReader.h>

// See available models on README.md or ESP32CameraPins.h
ESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER);

void onQrCodeTask(void *pvParameters)
{
  struct QRCodeData qrCodeData;

  while (true)
  {
    if (reader.receiveQrCode(&qrCodeData, 100))
    {
      Serial.println("Found QRCode");
      if (qrCodeData.valid)
      {
        Serial.print("Payload: ");
        Serial.println((const char *)qrCodeData.payload);
      }
      else
      {
        Serial.print("Invalid: ");
        Serial.println((const char *)qrCodeData.payload);
      }
    }
    vTaskDelay(100 / portTICK_PERIOD_MS);
  }
}

void setup()
{
  Serial.begin(115200);
  Serial.println();

  reader.setup();
  reader.beginOnCore(1);
  xTaskCreate(onQrCodeTask, "onQrCode", 4 * 1024, NULL, 4, NULL);
}

Limitations

  • Need an ESP32 module with PSRAM - See below.

Compatible Hardware

The QR Code recognition lib required a lot of memory, so I was only able to get this to work with an ESP32 that has PSRRAM available and also the Quirc library is modified to use that directly.

  • ESP32 module
  • PSRAM Available
  • Camera module - Tested with OV2640

ESP32 modules with camera that have PSRAM and should work:

  • CAMERA_MODEL_WROVER_KIT
  • CAMERA_MODEL_ESP_EYE
  • CAMERA_MODEL_M5STACK_PSRAM
  • CAMERA_MODEL_M5STACK_V2_PSRAM
  • CAMERA_MODEL_M5STACK_WIDE
  • CAMERA_MODEL_AI_THINKER

ESP32 modules without PSRAM that will not work:

  • CAMERA_MODEL_M5STACK_ESP32CAM
  • CAMERA_MODEL_TTGO_T_JOURNAL

License

This code is released under the MIT License.

References

esp32qrcodereader's People

Contributors

alvarowolfx avatar tuxphone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp32qrcodereader's Issues

Best QR format to be decoded?

Hello,
First of all I wanna say thanks for your work.

Question:
I would like to know if there is a known format of QR wich is best for being recogniced by your library.
I´m getting a lot of ECC errors (10 and 20 random chars qrs) using ESP32-CAM, it reads 1 every 25/30 tries.

Background:
I´m developing a small control system and there is no any fixed qr format I´m attached to, thats why I´m asking.

Maybe decreasing or increasing the L factor when generating the qrs?
I just need 2000 qrs that will be used with the app.

Any advice wellcome.
Thanks again.

does not compile in PlatformIO

I'm getting tons of missing functions, like psram, memcpy, free, and a zillion others when I try to compile my project. My platformio has lib_deps = alvarowolfx/ESP32QRCodeReader@^1.1.0
Errors look like this (many clipped from the end)

Compiling .pio\build\esp32cam\libc84\ESP32QRCodeReader\quirc\decode.c.o
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c: In function 'lifo_alloc':
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:20:23: warning: implicit declaration of function 'ps_malloc'; did you mean 'lifo_alloc'? [-Wimplicit-function-declaration]
   ptr->data = (char *)ps_malloc(size * data_len);
                       ^~~~~~~~~
                       lifo_alloc
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c: In function 'lifo_free':
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:36:5: warning: implicit declaration of function 'free' [-Wimplicit-function-declaration]
     free(ptr->data);
     ^~~~
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:36:5: warning: incompatible implicit declaration of built-in function 'free'
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:36:5: note: include '<stdlib.h>' or provide a declaration of 'free'
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:7:1:
+#include <stdlib.h>
 #define CHAR_BITS (sizeof(char) * 8)
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:36:5:
     free(ptr->data);
     ^~~~
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c: In function 'lifo_enqueue':
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:62:3: warning: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
   memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len);
   ^~~~~~
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:62:3: warning: incompatible implicit declaration of built-in function 'memcpy'
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:62:3: note: include '<string.h>' or provide a declaration of 'memcpy'
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:7:1:
+#include <string.h>
 #define CHAR_BITS (sizeof(char) * 8)
.pio/libdeps/esp32cam/ESP32QRCodeReader/src/openmv/collections.c:62:3:
   memcpy(ptr->data + (ptr->len * ptr->data_len), data, ptr->data_len);
   ^~~~~~

What could I be doing wrong?

Will this repo be supported?

Hey all them who has a lot of issues with this package, but couldn't find any alternative. Will this repo be continued to be supported?I don't have enough knowledge in C/C++ to fix the issues came with 4 years(currently) after the latest support.

@alvarowolfx is it archive or not?

Is there any alternatives to this so I can use for on-run qr scanning?

ESP EYE sepcific config always loaded

Hi there,

Thanks for the great code, but I encountered a minor issue when using it with a ESP32-CAM board.

You can find the following lines below in the cpp. This will always be true even if ESP EYE is not used, as it is always defined in the header file. As this changes the pinMode, unwanted behaviour will occur if pin 13 and /or 14 are used. For us, it caused I2C on pin 13/14 to stop working due to the internal pullup that got enabled.

#if defined(CAMERA_MODEL_ESP_EYE)
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
#endif

Working with format other than GRAYSCALE

Is it possible to initialize camera with some other format than GRAYSCALE for example JPEG or RGB and still make the reader work? Or is it possible to capture RGB picture and convert it to GRAYSCALE and feed that to the reader?

Problems encountered when using higher resolution

It didn't work when I changed the image size to 800*600.
Since the more complex QR codes cannot be recognized when the default image size is working, I tried to modify the image size, but it did not work
`ESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER,FRAMESIZE_QVGA);//320 * 240//Original

ESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER,FRAMESIZE_SVGA);//800 * 600//Modified
`

Xiao ESP32-S3 Sense

Hi,
would be great if you lib could also use the camera of the Xiao ESP32S3 Sense.
Maybe anyone can add this?

THX

Camera Quality

Is there any way to adjust the settings of the camera via your library? For example, increase brightness? I find that a large white and black qr code will scan. but anything small, or using a non standard color does not scan. I have some large codes that are a black/gray scale that won't scan. They scan fine with a iPhone, but that is obviously a much better camera.

failing to capture the payload on my pythn IDLE. needed to add the payload to a locslhost database e.g XAMPP

#include <Arduino.h>
#include <ESP32QRCodeReader.h>

ESP32QRCodeReader reader(CAMERA_MODEL_AI_THINKER);

void onQrCodeTask(void *pvParameters){
struct QRCodeData qrCodeData;
while (true){
if (reader.receiveQrCode(&qrCodeData, 100)){
if (qrCodeData.valid){
Serial.println((const char *)qrCodeData.payload);
}
}
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}

void setup(){
Serial.begin(115200);
reader.setup();
reader.beginOnCore(1);
xTaskCreate(onQrCodeTask, "onQrCode", 4 * 1024, NULL, 4, NULL);
}

void loop(){
delay(50);
}

How to add library to arduino other than PlatformIO

Hi~
Thank you for your library.
I managed to succeed making your library run in PlatformIO environment.
Then I'd like to know how to add library in Arduino IDE.

Can u advise me how to add library in arduino ide?
I googled how to add library to arduino ide then I tried but failed.

Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.