You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey! I am using this library with my own sketch and everything seemed to work well the first few times but now it always shows a "Decoding Failed" error every time I try to decode a Qr code. As I am not a pro in Arduino, can someone direct me to where my mistake is?
Note: I once tried to establish a com between Esp32 and the cam module does that happen to be a problem? Also, the cam module once fell from my hand. But the camera is working pretty fine.
This is my code ----
`
/* ======================================== Including the libraries. /
#include "esp_camera.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "quirc.h"
/ ======================================== */
// creating a task handle
TaskHandle_t QRCodeReader_Task;
/* ======================================== Select camera model */
#define CAMERA_MODEL_AI_THINKER
/* ======================================== */
/* ======================================== GPIO of camera models */
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
ESP.restart();
}
sensor_t * s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_QVGA);
Serial.println("Configure and initialize the camera successfully.");
Serial.println();
/* ---------------------------------------- */
/* ---------------------------------------- create "QRCodeReader_Task" using the xTaskCreatePinnedToCore() function /
xTaskCreatePinnedToCore(
QRCodeReader, / Task function. /
"QRCodeReader_Task", / name of task. /
10000, / Stack size of task /
NULL, / parameter of the task /
1, / priority of the task /
&QRCodeReader_Task, / Task handle to keep track of created task /
0); / pin task to core 0 /
/ ---------------------------------------- /
}
/ ________________________________________________________________________________ /
void loop() {
delay(100);
}
/ ________________________________________________________________________________ */
/* ________________________________________________________________________________ The function to be executed by "QRCodeReader_Task" /
// This function is to instruct the camera to take or capture a QR Code image, then it is processed and translated into text.
void QRCodeReader( void * pvParameters ){
/ ---------------------------------------- /
Serial.println("QRCodeReader is ready.");
Serial.print("QRCodeReader running on core ");
Serial.println(xPortGetCoreID());
Serial.println();
/ ---------------------------------------- */
/* ---------------------------------------- Loop to read QR Code in real time. */
while(1){
q = quirc_new();
if (q == NULL){
Serial.print("can't create quirc object\r\n");
continue;
}
/* ________________________________________________________________________________ Function to display the results of reading the QR Code on the serial monitor. */
void dumpData(const struct quirc_data *data)
{
Serial.printf("Version: %d\n", data->version);
Serial.printf("ECC level: %c\n", "MLHQ"[data->ecc_level]);
Serial.printf("Mask: %d\n", data->mask);
Serial.printf("Length: %d\n", data->payload_len);
Serial.printf("Payload: %s\n", data->payload);
QRCodeResult = (const char *)data->payload;
}
`
The text was updated successfully, but these errors were encountered:
Hey! I am using this library with my own sketch and everything seemed to work well the first few times but now it always shows a "Decoding Failed" error every time I try to decode a Qr code. As I am not a pro in Arduino, can someone direct me to where my mistake is?
Note: I once tried to establish a com between Esp32 and the cam module does that happen to be a problem? Also, the cam module once fell from my hand. But the camera is working pretty fine.
This is my code ----
`
/* ======================================== Including the libraries. /
#include "esp_camera.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "quirc.h"
/ ======================================== */
// creating a task handle
TaskHandle_t QRCodeReader_Task;
/* ======================================== Select camera model */
#define CAMERA_MODEL_AI_THINKER
/* ======================================== */
/* ======================================== GPIO of camera models */
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
/* ======================================== Variables declaration */
struct QRCodeData
{
bool valid;
int dataType;
uint8_t payload[1024];
int payloadLen;
};
struct quirc *q = NULL;
uint8_t image = NULL;
camera_fb_t * fb = NULL;
struct quirc_code code;
struct quirc_data data;
quirc_decode_error_t err;
struct QRCodeData qrCodeData;
String QRCodeResult = "";
/ ======================================== */
/* ________________________________________________________________________________ VOID SETTUP() */
void setup() {
// Disable brownout detector.
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);
/* ---------------------------------------- Init serial communication speed (baud rate). /
Serial.begin(112500);
Serial.setDebugOutput(true);
Serial.println();
/ ---------------------------------------- */
/* ---------------------------------------- Camera configuration. */
Serial.println("Start configuring and initializing the camera...");
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 10000000;
config.pixel_format = PIXFORMAT_GRAYSCALE;
config.frame_size = FRAMESIZE_QVGA;
config.jpeg_quality = 15;
config.fb_count = 1;
#if defined(CAMERA_MODEL_ESP_EYE)
pinMode(13, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
#endif
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
ESP.restart();
}
sensor_t * s = esp_camera_sensor_get();
s->set_framesize(s, FRAMESIZE_QVGA);
Serial.println("Configure and initialize the camera successfully.");
Serial.println();
/* ---------------------------------------- */
/* ---------------------------------------- create "QRCodeReader_Task" using the xTaskCreatePinnedToCore() function /
xTaskCreatePinnedToCore(
QRCodeReader, / Task function. /
"QRCodeReader_Task", / name of task. /
10000, / Stack size of task /
NULL, / parameter of the task /
1, / priority of the task /
&QRCodeReader_Task, / Task handle to keep track of created task /
0); / pin task to core 0 /
/ ---------------------------------------- /
}
/ ________________________________________________________________________________ /
void loop() {
delay(100);
}
/ ________________________________________________________________________________ */
/* ________________________________________________________________________________ The function to be executed by "QRCodeReader_Task" /
// This function is to instruct the camera to take or capture a QR Code image, then it is processed and translated into text.
void QRCodeReader( void * pvParameters ){
/ ---------------------------------------- /
Serial.println("QRCodeReader is ready.");
Serial.print("QRCodeReader running on core ");
Serial.println(xPortGetCoreID());
Serial.println();
/ ---------------------------------------- */
/* ---------------------------------------- Loop to read QR Code in real time. */
while(1){
q = quirc_new();
if (q == NULL){
Serial.print("can't create quirc object\r\n");
continue;
}
}
/* ---------------------------------------- /
}
/ ________________________________________________________________________________ */
/* ________________________________________________________________________________ Function to display the results of reading the QR Code on the serial monitor. */
void dumpData(const struct quirc_data *data)
{
Serial.printf("Version: %d\n", data->version);
Serial.printf("ECC level: %c\n", "MLHQ"[data->ecc_level]);
Serial.printf("Mask: %d\n", data->mask);
Serial.printf("Length: %d\n", data->payload_len);
Serial.printf("Payload: %s\n", data->payload);
QRCodeResult = (const char *)data->payload;
}
`
The text was updated successfully, but these errors were encountered: