initialize.ino 1.0 KB

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