ESP32 Cam - bottom half of frame buffer not updating

This is my first time on this forum, and also my first time using an ESP32-CAM, so my current understanding is quite limited.

I'm programming an ESP32-CAM (AI Thinker) with FRAMESIZE_QQVGA and PIXFORMAT_GRAYSCALE, and have come across an issue where the frame buffer does not update on the bottom half (i.e. the top half of the Serial output changes each iteration, but the bottom half does not). In addition to this, the output is 16bit, but I thought grayscale would be 8bit. Is this a problem with how I have programmed it?
Here is the loop (called with delay of 1000ms) I am using to capture the image and display the pixels (every 5th) using Serial print:

#define WIDTH 160
#define HEIGHT 120
... //in setup
config.pixel_format = PIXFORMAT_GRAYSCALE;
config.frame_size = FRAMESIZE_QQVGA;
...
bool capture_image(){
  camera_fb_t * frame = NULL;
  frame = esp_camera_fb_get();
  if(!frame) return false;
  uint16_t *data= (uint16_t*)frame->buf;

  for(int row=0; row<HEIGHT; row+=5){
    for(int col=0; col<WIDTH; col+=5){
      int pix = row * WIDTH + col;
      Serial.print((String)data[pix] + ", ");
    }
    Serial.println("");
  }
  esp_camera_fb_return(frame);
  return true;
}

Thanks

I moved your topic to a more appropriate forum category @jojo197.

The Nano ESP32 category you chose is only used for discussions directly related to the Arduino Nano ESP32 board.

In the future, please take the time to pick the forum category that best suits the subject of your question. There is an "About the _____ category" topic at the top of each category that explains its purpose.

Thanks in advance for your cooperation.

1 Like

I have discovered the issue on my own, and just posting it here:

Grayscale is only 8 bits, but I have defined the buffer as 16 bits, so it is storing essentially two pixels in each element of my array. Hence the bottom half is not getting updated.

Changing the array to 8 bit fixed the issue :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.