Esp32-Cam Qr reader

chiffa
Posts: 7
Joined: Thu Oct 15, 2020 3:22 pm

Esp32-Cam Qr reader

Postby chiffa » Thu Oct 15, 2020 3:29 pm

Hello. I try create QR-reader with ESPino32CAM libs. I use code from example:

Code: Select all

#include "ESPino32CAM.h"
#include "ESPino32CAM_QRCode.h"

#define CAMERA_MODEL_AI_THINKER

#include "camera_pins.h"

ESPino32CAM cam;
ESPino32QRCode qr;

#include <TFT_eSPI.h>
#include <SPI.h>
TFT_eSPI tft = TFT_eSPI();
#define SIZEX 480
#define SIZEY 320

#define BUTTON_QR 0
void setup() {
  //pinMode(4,OUTPUT);
  //digitalWrite(4,HIGH);
  Serial.begin(115200);
  Serial.println("\r\nESPino32CAM");
  if (cam.init() != ESP_OK)
  {
    Serial.println(F("Fail"));
    while (1);
  }
  qr.init(&cam);
  sensor_t *s = cam.sensor();
  s->set_framesize(s, FRAMESIZE_CIF);
  s->set_whitebal(s, true);

  tft.init();
  tft.setRotation(1);
  tft.fillScreen(TFT_BLACK);
  delay(1000);
  tft.fillScreen(TFT_WHITE);
  delay(1000);
  tft.fillScreen(TFT_BLACK);
}
void loop()
{
  unsigned long pv_time  = millis();
  camera_fb_t *fb = cam.capture();
  if (!fb)
  {
    Serial.println("Camera capture failed");
    return;
  }
  dl_matrix3du_t *rgb888, *rgb565;
  if (cam.jpg2rgb(fb, &rgb888))
  {
    rgb565 = cam.rgb565(rgb888);
    tft.pushImage(40, 11, rgb565->w, rgb565->h, (uint16_t*) rgb565->item);
  }
  cam.clearMemory(rgb888);
  cam.clearMemory(rgb565);
  //Serial.write(fb->buf, fb->len);
  dl_matrix3du_t *image_rgb;
  if (cam.jpg2rgb(fb, &image_rgb))
  {
    cam.clearMemory(fb);
    if (!digitalRead(BUTTON_QR))
    {
      cam.printDebug("\r\nQR Read:");
      qrResoult res = qr.recognition(image_rgb);
      if (res.status)
      {
        cam.printDebug("Payload: " + res.payload);
        tft.setTextColor(TFT_WHITE, TFT_BLUE);
        String text = "QR Read:" + res.payload;
        tft.drawCentreString(text, 240, 280, 4);
        delay(1000);
      }
      else
      {
        cam.printDebug("FAIL");
        tft.setTextColor(TFT_WHITE, TFT_BLUE);
        String text = "QR Read: FAIL";
        tft.drawCentreString(text, 240, 280, 4);
      }
    }
  }
  cam.clearMemory(image_rgb);
}

but after upload, in terminal, I get an error:

Code: Select all

[E][camera.c:1335] esp_camera_fb_get(): Failed to get the frame on time!
Camera capture failed
Anyone know how to fix it? Please help!

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: Esp32-Cam Qr reader

Postby ESP_Sprite » Fri Oct 16, 2020 1:30 am

Code: Select all

#define CAMERA_MODEL_AI_THINKER
Are you sure this line matches your hardware?

chiffa
Posts: 7
Joined: Thu Oct 15, 2020 3:22 pm

Re: Esp32-Cam Qr reader

Postby chiffa » Fri Oct 16, 2020 5:10 am

ESP_Sprite wrote:
Fri Oct 16, 2020 1:30 am

Code: Select all

#define CAMERA_MODEL_AI_THINKER
Are you sure this line matches your hardware?
yes. but i try with another/without it -not work

Who is online

Users browsing this forum: No registered users and 65 guests