Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f0ce61d
working auto focus
jasaw Jan 13, 2025
3b7ca4d
support manual focus
jasaw Jan 16, 2025
3f8d6c0
use manual focus
jasaw Jan 16, 2025
f93d421
support both auto focus and manual focus modes
jasaw Jan 17, 2025
4c88ef2
create reference image supports focus control
jasaw Jan 23, 2025
c7f5f96
restore focus config at start up
jasaw Jan 23, 2025
91d9d23
add focus control to configuration page
jasaw Jan 23, 2025
7b4b517
fix: better focus control when creating new reference image
jasaw Jan 24, 2025
82b1d53
feat: camera deep sleep
jasaw Jan 24, 2025
650df39
feat: hide focus control if not supported
jasaw Jan 24, 2025
94e2226
feat: hide focus control
jasaw Jan 25, 2025
d03446c
fix: restore camera config after wake up from sleep
jasaw Jan 26, 2025
466b5b5
refactor: clean up how camera config is managed
jasaw Jan 30, 2025
bbfe2a2
fix typo
jasaw Jan 30, 2025
f773155
increase delay around deep sleep wake and cam config to allow for hig…
jasaw Jan 31, 2025
84d2c98
Merge branch 'main' into feature/focus_support
jasaw Jan 31, 2025
e4e93d1
fix occassional weird brightness and colour in photo
jasaw Feb 1, 2025
e3e7227
attempt to workaround occasional camera config corruption
jasaw Feb 8, 2025
84b605f
ov2640 deepsleep
jasaw Feb 8, 2025
6eec2c2
initialize autofocus on demand
jasaw Feb 10, 2025
353bda2
cam: take 4 captures per flow for camera to adjust exposure and white…
jasaw Feb 12, 2025
28f98d8
fix: delay after camera config
jasaw Feb 13, 2025
d1ef026
revert pinning wifi to core 1
jasaw Feb 13, 2025
42421f3
support 80MHz CPU frequency
jasaw Feb 13, 2025
86761ab
fix: default CPU frequency when invalid config
jasaw Feb 13, 2025
cca3785
Merge branch 'main' into feature/focus_support
jasaw Feb 25, 2025
424edeb
Merge branch 'main' into feature/focus_support
jasaw Mar 4, 2025
2b17ac6
fix: code format
jasaw Mar 4, 2025
054d035
fix: spaces and tabs
jasaw Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
607 changes: 470 additions & 137 deletions code/components/jomjol_controlcamera/ClassControllCamera.cpp

Large diffs are not rendered by default.

80 changes: 28 additions & 52 deletions code/components/jomjol_controlcamera/ClassControllCamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,56 +13,23 @@
#include <string>
#include <esp_http_server.h>
#include "CImageBasis.h"
#include "camera_config.h"
#include "../../include/defines.h"

typedef struct
{
uint16_t CamSensor_id;

framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10
gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)

int ImageQuality; // 0 - 63
int ImageBrightness; // (-2 to 2) - set brightness
int ImageContrast; //-2 - 2
int ImageSaturation; //-2 - 2
int ImageSharpness; //-2 - 2
bool ImageAutoSharpness;
int ImageSpecialEffect; // 0 - 6
int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
int ImageAwb; // white balance enable (0 or 1)
int ImageAwbGain; // Auto White Balance enable (0 or 1)
int ImageAec; // auto exposure off (1 or 0)
int ImageAec2; // automatic exposure sensor (0 or 1)
int ImageAeLevel; // auto exposure levels (-2 to 2)
int ImageAecValue; // set exposure manually (0-1200)
int ImageAgc; // auto gain off (1 or 0)
int ImageAgcGain; // set gain manually (0 - 30)
int ImageBpc; // black pixel correction
int ImageWpc; // white pixel correction
int ImageRawGma; // (1 or 0)
int ImageLenc; // lens correction (1 or 0)
int ImageHmirror; // (0 or 1) flip horizontally
int ImageVflip; // Invert image (0 or 1)
int ImageDcw; // downsize enable (1 or 0)

int ImageDenoiseLevel; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)

int ImageWidth;
int ImageHeight;

int ImageLedIntensity;

bool ImageZoomEnabled;
int ImageZoomOffsetX;
int ImageZoomOffsetY;
int ImageZoomSize;
cam_config_t CamConfig;

uint16_t CameraFocusLevel; // temporary storage for the latest focus level
int WaitBeforePicture;
bool isImageSize;
bool isTempImage;

bool CameraInitSuccessful;
bool changedCameraSettings;
bool CameraAFInitSuccessful;
bool CameraDeepSleepEnable;
bool DemoMode;
bool SaveAllFiles;
} camera_controll_config_temp_t;
Expand All @@ -75,36 +42,45 @@ class CCamera
void ledc_init(void);
bool loadNextDemoImage(camera_fb_t *fb);
long GetFileSize(std::string filename);

int SetCamGainceiling(sensor_t *s, gainceiling_t gainceilingLevel);
void SetCamSharpness(bool autoSharpnessEnabled, int sharpnessLevel);
void SetCamSpecialEffect(sensor_t *s, int specialEffect);
void SetCamContrastBrightness(sensor_t *s, int _contrast, int _brightness);
void SetCamWindow(sensor_t *s, int frameSizeX, int frameSizeY, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput, int imageVflip);
void SetImageWidthHeightFromResolution(framesize_t resol);
void SanitizeZoomParams(int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY);
void SetImageWidthHeightFromResolution(cam_config_t *camConfig, framesize_t resol);
void SanitizeZoomParams(cam_config_t *camConfig, int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY);
void SetQualityZoomSize(cam_config_t *camConfig);
void SetZoomSize(cam_config_t *camConfig, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip);
void ResetZoomSizeOnCamera(cam_config_t *camConfig);
int SetCamFocus(bool focusEnabled, bool manualFocus, uint16_t manualFocusLevel);
int ReleaseCamFocus(bool focusEnabled, bool manualFocus);

public:
int LedIntensity = 4096;
void readSensorConfig(sensor_t *s, cam_config_t *camConfig);

int PrecaptureCamSetup(bool *focusEnabled, bool *manualFocus, bool *needReloadZoomConfig);

bool initCameraAF(void);
int CameraDeepSleep(bool sleep);

public:
CCamera(void);
esp_err_t InitCam(void);

void LightOnOff(bool status);
void LEDOnOff(bool status);

esp_err_t configureSensor(cam_config_t *camConfig);
esp_err_t setSensorDatenFromCCstatus(void);
esp_err_t getSensorDatenToCCstatus(void);

int SetCamGainceiling(sensor_t *s, gainceiling_t gainceilingLevel);
void SetCamSharpness(bool autoSharpnessEnabled, int sharpnessLevel);
void SetCamSpecialEffect(sensor_t *s, int specialEffect);
void SetCamContrastBrightness(sensor_t *s, int _contrast, int _brightness);

esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
esp_err_t CaptureToStream(httpd_req_t *req, bool FlashlightOn);

void SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip);
void SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip);

int SetLEDIntensity(int _intrel);
int CalculateLEDIntensity(int _intrel);
bool testCamera(void);
bool getCameraInitSuccessful(void);
bool getCameraAFInitSuccessful(void);
void useDemoMode(void);

framesize_t TextToFramesize(const char *text);
Expand Down
47 changes: 47 additions & 0 deletions code/components/jomjol_controlcamera/camera_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "esp_camera.h"

typedef struct
{
framesize_t ImageFrameSize = FRAMESIZE_VGA; // 0 - 10
gainceiling_t ImageGainceiling; // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128)

int ImageQuality; // 0 - 63
int ImageBrightness; // (-2 to 2) - set brightness
int ImageContrast; //-2 - 2
int ImageSaturation; //-2 - 2
int ImageSharpness; //-2 - 2
bool ImageAutoSharpness;
int ImageSpecialEffect; // 0 - 6
int ImageWbMode; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home)
int ImageAwb; // white balance enable (0 or 1)
int ImageAwbGain; // Auto White Balance enable (0 or 1)
int ImageAec; // auto exposure off (1 or 0)
int ImageAec2; // automatic exposure sensor (0 or 1)
int ImageAeLevel; // auto exposure levels (-2 to 2)
int ImageAecValue; // set exposure manually (0-1200)
int ImageAgc; // auto gain off (1 or 0)
int ImageAgcGain; // set gain manually (0 - 30)
int ImageBpc; // black pixel correction
int ImageWpc; // white pixel correction
int ImageRawGma; // (1 or 0)
int ImageLenc; // lens correction (1 or 0)
int ImageHmirror; // (0 or 1) flip horizontally
int ImageVflip; // Invert image (0 or 1)
int ImageDcw; // downsize enable (1 or 0)

int ImageDenoiseLevel; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8)

int ImageWidth;
int ImageHeight;

int ImageLedIntensity = 4096;

bool ImageZoomEnabled;
int ImageZoomOffsetX;
int ImageZoomOffsetY;
int ImageZoomSize;

bool CameraFocusEnabled;
bool CameraManualFocus;
uint16_t CameraManualFocusLevel;
} cam_config_t;
Loading