initialize.ino 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "initialize.h"
  2. void initialize(camera_config_t* config) {
  3. // Initialize camera.
  4. esp_err_t err = esp_camera_init(config);
  5. if (err != ESP_OK) {
  6. return;
  7. }
  8. // Get the camera model reference.
  9. CameraModel* model = CameraModel::getInstance();
  10. // Check if the flash is already on, if it is turn it off.
  11. if (model->getIsFlashEnabled()) {
  12. pinMode(FLASH_GPIO_NUM, OUTPUT);
  13. digitalWrite(FLASH_GPIO_NUM, LOW);
  14. model->setIsFlashEnabled(false);
  15. }
  16. // Get the camera sensor reference.
  17. sensor_t* cam = esp_camera_sensor_get();
  18. // Set up the frame buffer reference.
  19. camera_fb_t* frame_buffer = esp_camera_fb_get();
  20. // Set initial brightness.
  21. cam->set_brightness(cam, 0);
  22. // Set initial contrast.
  23. cam->set_contrast(cam, 0);
  24. // Set initial rotation.
  25. cam->set_vflip(cam, true);
  26. cam->set_hmirror(cam, true);
  27. // Set initial saturation.
  28. cam->set_saturation(cam, 0);
  29. // Set initial sharpness.
  30. cam->set_sharpness(cam, 0);
  31. }