dlbeer/quirc

grayscale framebuffer into uint8_t buffer

Closed this issue · 3 comments

Hey sorry for this novice question but I think im just missing something obvious... Would be very happy with the some guidance 🥇

code getting framebuffer

camera_fb_t * fb = NULL;
  esp_err_t res = ESP_OK;

  fb = esp_camera_fb_get(); // framebuffer in grayscale

and feed it somehow to quirc?

int w, h;
    int i, count;
    uint8_t *buf = quirc_begin(qr, &w, &h);
    //
    //Feed 'fb' into 'buf' somehow?
    
    //
    quirc_end(qr);

I've looked through the code, source files etc, but as i'm a novice ive no clue how to merge or copy the two buffers.

from esp32 code:

//replace this with your own function
        display_image(fb->width, fb->height, fb->pixformat, fb->buf, fb->len);

Luckily for me this is my camera config :D

config.pixel_format = PIXFORMAT_GRAYSCALE;
  config.frame_size = FRAMESIZE_QVGA;

Going to try out your advice, and already thanks for actually explaining the whole concept.

@dlbeer Thanks for the reply, it works! Atleast my Serial output tells me it found 1 code, but that's enough for me. Tells me it gets through from the camera buffer into quirc!

  int w, h;
  int i, count;
  uint8_t *buff = quirc_begin(qr, &w, &h);
  //
  int total_pixels = w * h;

  for (int i = 0; i < total_pixels; i++) {
    // grab a pixel from your source image at element i
    // convert it somehow, then store it
    buff[i] = fb->buf[i]; //?
  }
  //
  quirc_end(qr);

  count = quirc_count(qr);
  Serial.println("count found codes:");
  Serial.println(count);