Camera Web server

Drickset27
Posts: 4
Joined: Fri Jul 08, 2022 2:48 pm

Camera Web server

Postby Drickset27 » Mon Jul 11, 2022 6:59 am

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

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: Camera Web server

Postby lbernstone » 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

Momin786
Posts: 13
Joined: Mon Jul 11, 2022 7:52 am
Contact:

Re: Camera Web server

Postby Momin786 » Mon Jul 11, 2022 8:00 am

This getting started guide might help you:
https://microcontrollerslab.com/esp32-c ... -tutorial/
I create ESP32 tutorials and Projects using ESP-IDF https://esp32tutorials.com/

Drickset27
Posts: 4
Joined: Fri Jul 08, 2022 2:48 pm

Re: Camera Web server

Postby Drickset27 » Mon Jul 11, 2022 9:50 am

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 ?

06userit
Posts: 5
Joined: Tue Jan 19, 2021 6:02 am

Re: Camera Web server

Postby 06userit » 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

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

Drickset27
Posts: 4
Joined: Fri Jul 08, 2022 2:48 pm

Re: Camera Web server

Postby Drickset27 » Thu Aug 18, 2022 12:03 am

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?

06userit
Posts: 5
Joined: Tue Jan 19, 2021 6:02 am

Re: Camera Web server

Postby 06userit » Mon Aug 22, 2022 7:45 pm

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)

proggi_DE
Posts: 4
Joined: Tue Oct 01, 2019 1:52 pm

Re: Camera Web server

Postby proggi_DE » Tue Oct 31, 2023 9:27 pm

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

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

Re: Camera Web server

Postby lbernstone » Tue Oct 31, 2023 11:02 pm

https://github.com/espressif/esp32-camera
The IDF libraries are compiled into archives for arduino-esp32
https://github.com/espressif/esp32-arduino-libs/

Who is online

Users browsing this forum: Google [Bot] and 116 guests