Page 1 of 1

Camera Web server

Posted: Mon Jul 11, 2022 6:59 am
by Drickset27
I'm currently trying to understand the cam web server code one of the examples on Arduino IDE but I'm struggling to understand this part of the code. What is it checking for and what is it configuring and lastly why is it needed in our code ?I I have an AI thinker so do I still need this part of code ? Any help, links, etc. would be appreciated.

Code: Select all

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

  // camera init
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x", err);
    return;
  }

  sensor_t * s = esp_camera_sensor_get();
  // initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1); // flip it back
    s->set_brightness(s, 1); // up the brightness just a bit
    s->set_saturation(s, -2); // lower the saturation
  }
  // drop down frame size for higher initial frame rate
  if(config.pixel_format == PIXFORMAT_JPEG){
    s->set_framesize(s, FRAMESIZE_QVGA);
  }

#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
  s->set_vflip(s, 1);
  s->set_hmirror(s, 1);
#endif

#if defined(CAMERA_MODEL_ESP32S3_EYE)
  s->set_vflip(s, 1);
#endif

Re: Camera Web server

Posted: Mon Jul 11, 2022 7:29 am
by lbernstone
These are quirks for the specific sensors.
Perhaps you are just looking for the source code to the functions?
https://github.com/espressif/esp32-camera

Re: Camera Web server

Posted: Mon Jul 11, 2022 8:00 am
by Momin786
This getting started guide might help you:
https://microcontrollerslab.com/esp32-c ... -tutorial/

Re: Camera Web server

Posted: Mon Jul 11, 2022 9:50 am
by Drickset27
No, I'm not looking for the source code, I would just like to understand the purpose of those lines of code.

I'm using an ESP32 Cam AI Thinker to be specific, Do I also need theses lines of code ?

Re: Camera Web server

Posted: Wed Jul 13, 2022 1:45 pm
by 06userit
If you are using ESP32CAM AI Thinker, the embedded camera is an OV2640 so only part of the code will be compiled/executed, see below.
The bottom line is you could leave code as-is, it should be ok
Note that frame size can take following values :
frame size QQVGA(160x120),HQVGA(240x176),QVGA(320x240),CIF(400x296),VGA(640x480),SVGA(800x600),XGA(1024x768),SXGA(1280x1024),UXGA(1600x1200)

Hope this helps

Code: Select all

// NOT COMPILED/EXECUTED FOR ESP32CAM AI Thinker
#if defined(CAMERA_MODEL_ESP_EYE)
  pinMode(13, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
#endif

// COMPILED/EXECUTED FOR ESP32CAM AI Thinker
// camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
  Serial.printf("Camera init failed with error 0x%x", err);
  return;
}

// COMPILED/EXECUTED FOR ESP32CAM AI Thinker
sensor_t * s = esp_camera_sensor_get();

// NOT COMPILED/EXECUTED FOR ESP32CAM AI Thinker  
// initial sensors are flipped vertically and colors are a bit saturated
if (s->id.PID == OV3660_PID) {
  s->set_vflip(s, 1); // flip it back
  s->set_brightness(s, 1); // up the brightness just a bit
  s->set_saturation(s, -2); // lower the saturation
}

// COMPILED/EXECUTED FOR ESP32CAM AI Thinker
// drop down frame size for higher initial frame rate
if(config.pixel_format == PIXFORMAT_JPEG){
  s->set_framesize(s, FRAMESIZE_QVGA);
}

// NOT COMPILED/EXECUTED FOR ESP32CAM AI Thinker
#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
  s->set_vflip(s, 1);
  s->set_hmirror(s, 1);
#endif

// NOT COMPILED/EXECUTED FOR ESP32CAM AI Thinker
#if defined(CAMERA_MODEL_ESP32S3_EYE)
  s->set_vflip(s, 1);
#endif

Re: Camera Web server

Posted: Thu Aug 18, 2022 12:03 am
by Drickset27
06userit wrote:
Wed Jul 13, 2022 1:45 pm
If you are using ESP32CAM AI Thinker, the embedded camera is an OV2640 so only part of the code will be compiled/executed, see below.
The bottom line is you could leave code as-is, it should be ok
Note that frame size can take following values :
frame size QQVGA(160x120),HQVGA(240x176),QVGA(320x240),CIF(400x296),VGA(640x480),SVGA(800x600),XGA(1024x768),SXGA(1280x1024),UXGA(1600x1200)

Hope this helps
Thanks

So would it affect anything if I removed the code that will not be compiled?

Re: Camera Web server

Posted: Mon Aug 22, 2022 7:45 pm
by 06userit
So would it affect anything if I removed the code that will not be compiled?
Answer is no. In other words, you may remove the code which is not compiled (no impact)

Re: Camera Web server

Posted: Tue Oct 31, 2023 9:27 pm
by proggi_DE
lbernstone wrote:
Mon Jul 11, 2022 7:29 am
These are quirks for the specific sensors.
Perhaps you are just looking for the source code to the functions?
https://github.com/espressif/esp32-camera
When compiling the Camera WebcamServer project where does the compiler find the c-code file? I can find the header files only....

Thanks

Re: Camera Web server

Posted: Tue Oct 31, 2023 11:02 pm
by lbernstone
https://github.com/espressif/esp32-camera
The IDF libraries are compiled into archives for arduino-esp32
https://github.com/espressif/esp32-arduino-libs/