ClassControllCamera.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #pragma once
  2. #ifndef CLASSCONTROLLCAMERA_H
  3. #define CLASSCONTROLLCAMERA_H
  4. #include <string>
  5. #include "freertos/FreeRTOS.h"
  6. #include "freertos/task.h"
  7. #include "freertos/queue.h"
  8. #include "freertos/event_groups.h"
  9. #include "esp_camera.h"
  10. #include <string>
  11. #include <esp_http_server.h>
  12. #include "CImageBasis.h"
  13. #include "../../include/defines.h"
  14. typedef enum
  15. {
  16. OV2640_MODE_UXGA,
  17. OV2640_MODE_SVGA,
  18. OV2640_MODE_CIF
  19. } ov2640_sensor_mode_t;
  20. typedef struct
  21. {
  22. framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10
  23. gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)
  24. int ImageQuality; // 0 - 63
  25. int ImageBrightness; // (-2 to 2) - set brightness
  26. int ImageContrast; //-2 - 2
  27. int ImageSaturation; //-2 - 2
  28. int ImageSharpness; //-2 - 2
  29. bool ImageAutoSharpness;
  30. int ImageSpecialEffect; // 0 - 6
  31. int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
  32. int ImageAwb; // white balance enable (0 or 1)
  33. int ImageAwbGain; // Auto White Balance enable (0 or 1)
  34. int ImageAec; // auto exposure off (1 or 0)
  35. int ImageAec2; // automatic exposure sensor (0 or 1)
  36. int ImageAeLevel; // auto exposure levels (-2 to 2)
  37. int ImageAecValue; // set exposure manually (0-1200)
  38. int ImageAgc; // auto gain off (1 or 0)
  39. int ImageAgcGain; // set gain manually (0 - 30)
  40. int ImageBpc; // black pixel correction
  41. int ImageWpc; // white pixel correction
  42. int ImageRawGma; // (1 or 0)
  43. int ImageLenc; // lens correction (1 or 0)
  44. int ImageHmirror; // (0 or 1) flip horizontally
  45. int ImageVflip; // Invert image (0 or 1)
  46. int ImageDcw; // downsize enable (1 or 0)
  47. int ImageWidth;
  48. int ImageHeight;
  49. int ImageLedIntensity;
  50. bool ImageZoomEnabled;
  51. int ImageZoomMode;
  52. int ImageZoomOffsetX;
  53. int ImageZoomOffsetY;
  54. int ImageZoomSize;
  55. int WaitBeforePicture;
  56. bool isImageSize;
  57. bool CameraInitSuccessful;
  58. bool changedCameraSettings;
  59. bool DemoMode;
  60. bool SaveAllFiles;
  61. } camera_controll_config_temp_t;
  62. extern camera_controll_config_temp_t CCstatus;
  63. class CCamera
  64. {
  65. protected:
  66. void ledc_init(void);
  67. bool loadNextDemoImage(camera_fb_t *fb);
  68. long GetFileSize(std::string filename);
  69. void SetCamWindow(sensor_t *s, int resolution, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput);
  70. void SetImageWidthHeightFromResolution(framesize_t resol);
  71. public:
  72. CCamera(void);
  73. esp_err_t InitCam(void);
  74. void LightOnOff(bool status);
  75. void LEDOnOff(bool status);
  76. esp_err_t setSensorDatenFromCCstatus(void);
  77. esp_err_t getSensorDatenToCCstatus(void);
  78. esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
  79. esp_err_t CaptureToStream(httpd_req_t *req, bool FlashlightOn);
  80. void SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize);
  81. void SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize);
  82. void SetCamSharpness(bool _autoSharpnessEnabled, int _sharpnessLevel);
  83. void SetLEDIntensity(float _intrel);
  84. bool testCamera(void);
  85. bool getCameraInitSuccessful(void);
  86. void useDemoMode(void);
  87. framesize_t TextToFramesize(const char *text);
  88. esp_err_t CaptureToFile(std::string nm, int delay = 0);
  89. esp_err_t CaptureToBasisImage(CImageBasis *_Image, int delay = 0);
  90. };
  91. extern CCamera Camera;
  92. #endif