ClassControllCamera.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. #pragma once
  2. #ifndef CLASSCONTROLLCAMERA_H
  3. #define CLASSCONTROLLCAMERA_H
  4. #include <string>
  5. #include <esp_http_server.h>
  6. #include <freertos/FreeRTOS.h>
  7. #include <freertos/task.h>
  8. #include <freertos/queue.h>
  9. #include <freertos/event_groups.h>
  10. #include "defines.h"
  11. #include "esp_camera.h"
  12. #include "CImageBasis.h"
  13. typedef struct
  14. {
  15. int CamXclkFreqMhz;
  16. framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10
  17. gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)
  18. int ImageQuality; // 0 - 63
  19. int ImageBrightness; // (-2 to 2) - set brightness
  20. int ImageContrast; //-2 - 2
  21. int ImageSaturation; //-2 - 2
  22. int ImageSharpness; //-2 - 2
  23. bool ImageAutoSharpness;
  24. int ImageSpecialEffect; // 0 - 6
  25. int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
  26. int ImageAwb; // white balance enable (0 or 1)
  27. int ImageAwbGain; // Auto White Balance enable (0 or 1)
  28. int ImageAec; // auto exposure off (1 or 0)
  29. int ImageAec2; // automatic exposure sensor (0 or 1)
  30. int ImageAeLevel; // auto exposure levels (-2 to 2)
  31. int ImageAecValue; // set exposure manually (0-1200)
  32. int ImageAgc; // auto gain off (1 or 0)
  33. int ImageAgcGain; // set gain manually (0 - 30)
  34. int ImageBpc; // black pixel correction
  35. int ImageWpc; // white pixel correction
  36. int ImageRawGma; // (1 or 0)
  37. int ImageLenc; // lens correction (1 or 0)
  38. int ImageHmirror; // (0 or 1) flip horizontally
  39. int ImageVflip; // Invert image (0 or 1)
  40. int ImageDcw; // downsize enable (1 or 0)
  41. int ImageDenoiseLevel; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)
  42. int ImageWidth;
  43. int ImageHeight;
  44. int ImageLedIntensity;
  45. bool ImageZoomEnabled;
  46. int ImageZoomOffsetX;
  47. int ImageZoomOffsetY;
  48. int ImageZoomSize;
  49. int WaitBeforePicture;
  50. } camera_controll_config_temp_t;
  51. extern camera_controll_config_temp_t CCstatus;
  52. extern camera_controll_config_temp_t CFstatus;
  53. class CCamera
  54. {
  55. protected:
  56. void ledc_init(void);
  57. bool load_next_demo_image(camera_fb_t *fb);
  58. long get_file_size(std::string filename);
  59. void set_camera_window(sensor_t *cam_sensor, int frameSizeX, int frameSizeY, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput, int imageVflip);
  60. void set_image_width_height_from_resolution(framesize_t resol);
  61. void sanitize_zoom_params(camera_controll_config_temp_t *camConfig, int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY);
  62. public:
  63. uint16_t CamSensorId = OV2640_PID;
  64. int LedIntensity = 4096;
  65. bool CaptureToBasisImageLed = false;
  66. bool CaptureToFileLed = false;
  67. bool CaptureToHTTPLed = false;
  68. bool CaptureToStreamLed = false;
  69. bool DemoMode = false;
  70. bool SaveAllFiles = false;
  71. bool ImageAntialiasing = false;
  72. float ImageInitialRotate = 0.0;
  73. bool ImageInitialFlip = false;
  74. bool CamDeepSleepEnable = false;
  75. bool CameraInitSuccessful = false;
  76. bool changedCameraSettings = false;
  77. bool CamTempImage = false;
  78. CCamera(void);
  79. esp_err_t init_camera(void);
  80. void power_reset_camera(void);
  81. void set_flash_light_on_off(bool status);
  82. void set_blink_led_on_off(bool status);
  83. esp_err_t set_sensor_controll_config(camera_controll_config_temp_t *camConfig);
  84. esp_err_t get_sensor_controll_config(camera_controll_config_temp_t *camConfig);
  85. esp_err_t set_camera_config_from_to(camera_controll_config_temp_t *camConfigFrom, camera_controll_config_temp_t *camConfigTo);
  86. int check_camera_settings_changed(void);
  87. int set_camera_deep_sleep(bool enable);
  88. int set_camera_gainceiling(sensor_t *cam_sensor, gainceiling_t gainceilingLevel);
  89. void set_camera_sharpness(bool autoSharpnessEnabled, int sharpnessLevel);
  90. void set_camera_special_effect(sensor_t *cam_sensor, int specialEffect);
  91. void set_camera_contrast_brightness(sensor_t *cam_sensor, int _contrast, int _brightness);
  92. esp_err_t capture_to_http(httpd_req_t *req, int flash_duration = 0);
  93. esp_err_t capture_to_stream(httpd_req_t *req, bool FlashlightOn);
  94. void set_quality_zoom_size(camera_controll_config_temp_t *camConfig);
  95. void set_zoom_size(camera_controll_config_temp_t *camConfig);
  96. int set_led_intensity(int _intrel);
  97. bool get_camera_init_successful(void);
  98. void use_demo_mode(void);
  99. framesize_t text_to_framesize(const char *text);
  100. esp_err_t capture_to_file(std::string file_name, int flash_duration = 0);
  101. esp_err_t capture_to_basis_image(CImageBasis *_Image, int flash_duration = 0);
  102. };
  103. extern CCamera Camera;
  104. #endif