diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.cpp b/code/components/jomjol_controlcamera/ClassControllCamera.cpp index 5095cb16..bd830ed9 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.cpp +++ b/code/components/jomjol_controlcamera/ClassControllCamera.cpp @@ -142,8 +142,10 @@ esp_err_t CCamera::InitCam(void) if (s != NULL) { + CCstatus.CamSensor_id = s->id.PID; + // Dump camera module, warn for unsupported modules. - switch (s->id.PID) + switch (CCstatus.CamSensor_id) { case OV2640_PID: ESP_LOGI(TAG, "OV2640 camera module detected"); @@ -151,6 +153,9 @@ esp_err_t CCamera::InitCam(void) case OV3660_PID: ESP_LOGI(TAG, "OV3660 camera module detected"); break; + case OV5640_PID: + ESP_LOGI(TAG, "OV5640 camera module detected"); + break; default: ESP_LOGE(TAG, "Camera module is unknown and not properly supported!"); CCstatus.CameraInitSuccessful = false; @@ -237,8 +242,6 @@ esp_err_t CCamera::setSensorDatenFromCCstatus(void) if (s != NULL) { s->set_framesize(s, CCstatus.ImageFrameSize); - s->set_gainceiling(s, CCstatus.ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) - s->set_quality(s, CCstatus.ImageQuality); // 0 - 63 s->set_brightness(s, CCstatus.ImageBrightness); // -2 to 2 @@ -247,34 +250,37 @@ esp_err_t CCamera::setSensorDatenFromCCstatus(void) // s->set_sharpness(s, CCstatus.ImageSharpness); // auto-sharpness is not officially supported, default to 0 SetCamSharpness(CCstatus.ImageAutoSharpness, CCstatus.ImageSharpness); - s->set_exposure_ctrl(s, CCstatus.ImageAec); // 0 = disable , 1 = enable + s->set_denoise(s, CCstatus.ImageDenoiseLevel); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) + + s->set_special_effect(s, CCstatus.ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) + s->set_wb_mode(s, CCstatus.ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) + s->set_ae_level(s, CCstatus.ImageAeLevel); // -2 to 2 s->set_aec_value(s, CCstatus.ImageAecValue); // 0 to 1200 + s->set_agc_gain(s, CCstatus.ImageAgcGain); // 0 to 30 - s->set_aec2(s, CCstatus.ImageAec2); // 0 = disable , 1 = enable + // s->set_gainceiling(s, CCstatus.ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) + ov5640_set_gainceiling(s, CCstatus.ImageGainceiling); - s->set_gain_ctrl(s, CCstatus.ImageAgc); // 0 = disable , 1 = enable - s->set_agc_gain(s, CCstatus.ImageAgcGain); // 0 to 30 + s->set_lenc(s, CCstatus.ImageLenc); // 0 = disable , 1 = enable + s->set_gain_ctrl(s, CCstatus.ImageAgc); // 0 = disable , 1 = enable + s->set_exposure_ctrl(s, CCstatus.ImageAec); // 0 = disable , 1 = enable + + s->set_hmirror(s, CCstatus.ImageHmirror); // 0 = disable , 1 = enable + s->set_vflip(s, CCstatus.ImageVflip); // 0 = disable , 1 = enable + s->set_aec2(s, CCstatus.ImageAec2); // 0 = disable , 1 = enable s->set_bpc(s, CCstatus.ImageBpc); // 0 = disable , 1 = enable s->set_wpc(s, CCstatus.ImageWpc); // 0 = disable , 1 = enable s->set_raw_gma(s, CCstatus.ImageRawGma); // 0 = disable , 1 = enable - s->set_lenc(s, CCstatus.ImageLenc); // 0 = disable , 1 = enable - s->set_hmirror(s, CCstatus.ImageHmirror); // 0 = disable , 1 = enable - s->set_vflip(s, CCstatus.ImageVflip); // 0 = disable , 1 = enable - - s->set_dcw(s, CCstatus.ImageDcw); // 0 = disable , 1 = enable - - s->set_wb_mode(s, CCstatus.ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) s->set_awb_gain(s, CCstatus.ImageAwbGain); // 0 = disable , 1 = enable s->set_whitebal(s, CCstatus.ImageAwb); // 0 = disable , 1 = enable - // special_effect muß als Letztes gesetzt werden, sonst geht es nicht - s->set_special_effect(s, CCstatus.ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) + s->set_dcw(s, CCstatus.ImageDcw); // 0 = disable , 1 = enable - TickType_t xDelay2 = 1000 / portTICK_PERIOD_MS; + TickType_t xDelay2 = 100 / portTICK_PERIOD_MS; vTaskDelay(xDelay2); return ESP_OK; @@ -291,6 +297,8 @@ esp_err_t CCamera::getSensorDatenToCCstatus(void) if (s != NULL) { + CCstatus.CamSensor_id = s->id.PID; + CCstatus.ImageFrameSize = (framesize_t)s->status.framesize; CCstatus.ImageGainceiling = (gainceiling_t)s->status.gainceiling; @@ -316,6 +324,7 @@ esp_err_t CCamera::getSensorDatenToCCstatus(void) CCstatus.ImageHmirror = s->status.hmirror; CCstatus.ImageVflip = s->status.vflip; CCstatus.ImageDcw = s->status.dcw; + CCstatus.ImageDenoiseLevel = s->status.denoise; return ESP_OK; } @@ -325,7 +334,93 @@ esp_err_t CCamera::getSensorDatenToCCstatus(void) } } -void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize) +// on the OV5640, gainceiling must be set with the real value (x2>>>level = 2, .... x128>>>level = 128) +int CCamera::ov5640_set_gainceiling(sensor_t *s, gainceiling_t level) +{ + int ret = 0; + + if (CCstatus.CamSensor_id == OV2640_PID) + { + ret = s->set_gainceiling(s, CCstatus.ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) + } + else + { + int _level = (1 << ((int)level + 1)); + + ret = s->set_reg(s, 0x3A18, 0xFF, (_level >> 8) & 3) || s->set_reg(s, 0x3A19, 0xFF, _level & 0xFF); + + if (ret == 0) + { + // ESP_LOGD(TAG, "Set gainceiling to: %d", level); + s->status.gainceiling = level; + } + } + + return ret; +} + +// - It always zooms to the image center when offsets are zero +// - if imageSize = 0 then the image is not zoomed +// - if imageSize = max value, then the image is fully zoomed in +// - a zoom step is >>> Width + 32 px / Height + 24 px +void CCamera::SanitizeZoomParams(int imageSize, int frameSizeX, int frameSizeY, int &imageWidth, int &imageHeight, int &zoomOffsetX, int &zoomOffsetY) +{ + // for OV2640, This works only if the aspect ratio of 4:3 is preserved in the window size. + // use only values divisible by 8 without remainder + imageWidth = CCstatus.ImageWidth + (imageSize * 4 * 8); + imageHeight = CCstatus.ImageHeight + (imageSize * 3 * 8); + + int _maxX = frameSizeX - imageWidth; + int _maxY = frameSizeY - imageHeight; + + if ((abs(zoomOffsetX) * 2) > _maxX) + { + if (zoomOffsetX > 0) + { + zoomOffsetX = _maxX; + } + else + { + zoomOffsetX = 0; + } + } + else + { + if (zoomOffsetX > 0) + { + zoomOffsetX = ((_maxX / 2) + zoomOffsetX); + } + else + { + zoomOffsetX = ((_maxX / 2) + zoomOffsetX); + } + } + + if ((abs(zoomOffsetY) * 2) > _maxY) + { + if (zoomOffsetY > 0) + { + zoomOffsetY = _maxY; + } + else + { + zoomOffsetY = 0; + } + } + else + { + if (zoomOffsetY > 0) + { + zoomOffsetY = ((_maxY / 2) + zoomOffsetY); + } + else + { + zoomOffsetY = ((_maxY / 2) + zoomOffsetY); + } + } +} + +void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip) { sensor_t *s = esp_camera_sensor_get(); @@ -333,89 +428,59 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in { if (zoomEnabled) { - // ov2640_sensor_mode_t _mode = OV2640_MODE_UXGA; // 1600x1200 - // ov2640_sensor_mode_t _mode = OV2640_MODE_SVGA; // 800x600 - // ov2640_sensor_mode_t _mode = OV2640_MODE_CIF; // 400x296 - int _mode = 0; - + int _imageSize_temp = 0; + int _imageWidth = CCstatus.ImageWidth; + int _imageHeight = CCstatus.ImageHeight; int _offsetx = zoomOffsetX; int _offsety = zoomOffsetY; - int _imageSize_temp = 0; - int _maxX = 0; - int _maxY = 0; + int frameSizeX; + int frameSizeY; - if (imageSize < 29) + switch (CCstatus.CamSensor_id) { - _imageSize_temp = (29 - imageSize); - } + case OV5640_PID: + frameSizeX = 2592; + frameSizeY = 1944; + // max imageSize = ((frameSizeX - CCstatus.ImageWidth) / 8 / 4) - 1 + // 59 = ((2560 - 640) / 8 / 4) - 1 + if (imageSize < 59) + { + _imageSize_temp = (59 - imageSize); + } + SanitizeZoomParams(_imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); + SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight, imageVflip); + break; - // This works only if the aspect ratio of 4:3 is preserved in the window size. - // use values divisible by 8 without remainder - int _imageWidth = CCstatus.ImageWidth + (_imageSize_temp * 4 * 8); - int _imageHeight = CCstatus.ImageHeight + (_imageSize_temp * 3 * 8); + case OV3660_PID: + frameSizeX = 2048; + frameSizeY = 1536; + // max imageSize = ((frameSizeX - CCstatus.ImageWidth) / 8 / 4) -1 + // 43 = ((2048 - 640) / 8 / 4) - 1 + if (imageSize < 43) + { + _imageSize_temp = (43 - imageSize); + } + SanitizeZoomParams(_imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); + SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight, imageVflip); + break; - _maxX = 1600 - _imageWidth; - _maxY = 1200 - _imageHeight; + case OV2640_PID: + frameSizeX = 1600; + frameSizeY = 1200; + // max imageSize = ((frameSizeX - CCstatus.ImageWidth) / 8 / 4) -1 + // 29 = ((1600 - 640) / 8 / 4) - 1 + if (imageSize < 29) + { + _imageSize_temp = (29 - imageSize); + } + SanitizeZoomParams(_imageSize_temp, frameSizeX, frameSizeY, _imageWidth, _imageHeight, _offsetx, _offsety); + SetCamWindow(s, frameSizeX, frameSizeY, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight, imageVflip); + break; - if ((abs(_offsetx) * 2) > _maxX) - { - if (_offsetx > 0) - { - _offsetx = _maxX; - } - else - { - _offsetx = 0; - } + default: + // do nothing + break; } - else - { - if (_offsetx > 0) - { - // wenn der Wert von _offsetx nicht durch 8 teilbar ist, - // werden die Farben sehr oft vertauscht(insbesondere Rot mit Blau) - _offsetx = ((_maxX / 2) + _offsetx); - } - else - { - // wenn der Wert von _offsetx nicht durch 8 teilbar ist, - // werden die Farben sehr oft vertauscht(insbesondere Rot mit Blau) - _offsetx = ((_maxX / 2) + _offsetx); - } - } - - if ((abs(_offsety) * 2) > _maxY) - { - if (_offsety > 0) - { - _offsety = _maxY; - } - else - { - _offsety = 0; - } - } - else - { - if (_offsety > 0) - { - // wenn der Wert von _offsety nicht durch 8 teilbar ist, - // werden die Farben sehr oft vertauscht(insbesondere Rot mit Blau) - _offsety = ((_maxY / 2) + _offsety); - } - else - { - // wenn der Wert von _offsety nicht durch 8 teilbar ist, - // werden die Farben sehr oft vertauscht(insbesondere Rot mit Blau) - _offsety = ((_maxY / 2) + _offsety); - } - } - - // _mode sets the sensor resolution (3 options available), - // _offsetx and _offsety set the start of the ROI, - // _imageWidth and _imageHeight set the size of the ROI, - // CCstatus.ImageWidth and CCstatus.ImageHeight set the output window size. - SetCamWindow(s, _mode, _offsetx, _offsety, _imageWidth, _imageHeight, CCstatus.ImageWidth, CCstatus.ImageHeight); } else { @@ -424,18 +489,22 @@ void CCamera::SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, in } } -void CCamera::SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize) +void CCamera::SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize, int imageVflip) { - qual = min(63, max(8, qual)); // Limit quality from 8..63 (values lower than 8 tent to be unstable) + sensor_t *s = esp_camera_sensor_get(); + + // OV2640 has no lower limit on jpeg quality + if (CCstatus.CamSensor_id == OV5640_PID) + { + qual = min(63, max(8, qual)); + } SetImageWidthHeightFromResolution(resol); - sensor_t *s = esp_camera_sensor_get(); - if (s != NULL) { s->set_quality(s, qual); - SetZoomSize(zoomEnabled, zoomOffsetX, zoomOffsetY, imageSize); + SetZoomSize(zoomEnabled, zoomOffsetX, zoomOffsetY, imageSize, imageVflip); } else { @@ -445,21 +514,36 @@ void CCamera::SetQualityZoomSize(int qual, framesize_t resol, bool zoomEnabled, void CCamera::SetCamSharpness(bool _autoSharpnessEnabled, int _sharpnessLevel) { - _sharpnessLevel = min(2, max(-2, _sharpnessLevel)); - sensor_t *s = esp_camera_sensor_get(); if (s != NULL) { - // post processing - if (_autoSharpnessEnabled) + if (CCstatus.CamSensor_id == OV2640_PID) { - s->set_sharpness(s, 0); - ov2640_enable_auto_sharpness(s); + _sharpnessLevel = min(2, max(-2, _sharpnessLevel)); + // The OV2640 does not officially support sharpness, so the detour is made with the ov2640_sharpness.cpp. + if (_autoSharpnessEnabled) + { + ov2640_enable_auto_sharpness(s); + } + else + { + ov2640_set_sharpness(s, _sharpnessLevel); + } } else { - ov2640_set_sharpness(s, _sharpnessLevel); + _sharpnessLevel = min(3, max(-3, _sharpnessLevel)); + // for CAMERA_OV5640 and CAMERA_OV3660 + if (_autoSharpnessEnabled) + { + // autoSharpness is not supported, default to zero + s->set_sharpness(s, 0); + } + else + { + s->set_sharpness(s, _sharpnessLevel); + } } } else @@ -468,47 +552,27 @@ void CCamera::SetCamSharpness(bool _autoSharpnessEnabled, int _sharpnessLevel) } } -/* - * resolution = 0 \\ OV2640_MODE_UXGA -> 1600 x 1200 - * resolution = 1 \\ OV2640_MODE_SVGA -> 800 x 600 - * resolution = 2 \\ OV2640_MODE_CIF -> 400 x 296 - * resolution = 3 \\ OV2640_MODE_MAX - */ -void CCamera::SetCamWindow(sensor_t *s, int resolution, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput) +void CCamera::SetCamWindow(sensor_t *s, int frameSizeX, int frameSizeY, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput, int imageVflip) { - // - (xOffset,yOffset) is the origin of the window in pixels and (xLength,yLength) is the size of the window in pixels. - // - (xOffset,yOffset) ist der Ursprung des Fensters in Pixel und (xLength,yLength) ist die Größe des Fensters in Pixel. + if (CCstatus.CamSensor_id == OV2640_PID) + { + s->set_res_raw(s, 0, 0, 0, 0, xOffset, yOffset, xTotal, yTotal, xOutput, yOutput, false, false); + } + else + { + // for CAMERA_OV5640 and CAMERA_OV3660 + bool scale = !(xOutput == xTotal && yOutput == yTotal); + bool binning = (xTotal >= (frameSizeX >> 1)); - // - Be aware that changing the resolution will effectively overwrite these settings. - // - Beachten Sie, dass eine Änderung der Auflösung diese Einstellungen effektiv überschreibt. - - // - This works only if the aspect ratio of 4:3 is preserved in the window size. - // - Dies funktioniert nur, wenn das Seitenverhältnis von 4:3 in der Fenstergröße beibehalten wird. - - // - total_x and total_y defines the size on the sensor - // - total_x und total_y definieren die Größe des Sensors - - // - width and height defines the resulting image(may be smaller than the size on the sensor) - // - width und height definieren das resultierende Bild (kann kleiner sein als die Größe des Sensor) - - // - keep the aspect total_x : total_y == width : height - // - Behalten Sie den Aspekt total_x : total_y == width : height bei - - // - use values divisible by 8 without remainder - // - Verwenden Sie Werte, die ohne Rest durch 8 teilbar sind - - // - start with total_x = width and total_y = height, reduce both values by eg.32 pixels - // - Beginnen Sie mit total_x = width und total_y = height und reduzieren Sie beide Werte um z.B.32 Pixel - - // - next try moving with offset_x or offset_y by 8 pixels - // - Versuchen Sie als Nächstes, mit offset_x oder offset_y um 8 Pixel zu verschieben - - // set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) - // set_window(sensor, (ov2640_sensor_mode_t)startX, offsetX, offsetY, totalX, totalY, outputX, outputY); - // set_window(sensor, mode, offset_x, offset_y, max_x, max_y, w, h); - - int unused = 0; - s->set_res_raw(s, resolution, unused, unused, unused, xOffset, yOffset, xTotal, yTotal, xOutput, yOutput, unused, unused); + if (imageVflip == true) + { + s->set_res_raw(s, xOffset, yOffset, xOffset + xTotal - 1, yOffset + yTotal - 1, 0, 0, frameSizeX, frameSizeY, xOutput, yOutput, scale, binning); + } + else + { + s->set_res_raw(s, xOffset, yOffset, xOffset + xTotal, yOffset + yTotal, 0, 0, frameSizeX, frameSizeY, xOutput, yOutput, scale, binning); + } + } } static size_t jpg_encode_stream(void *arg, size_t index, const void *data, size_t len) @@ -839,7 +903,7 @@ esp_err_t CCamera::CaptureToStream(httpd_req_t *req, bool FlashlightOn) if (CFstatus.changedCameraSettings) { Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); CFstatus.changedCameraSettings = false; } diff --git a/code/components/jomjol_controlcamera/ClassControllCamera.h b/code/components/jomjol_controlcamera/ClassControllCamera.h index b674ead3..cea05726 100644 --- a/code/components/jomjol_controlcamera/ClassControllCamera.h +++ b/code/components/jomjol_controlcamera/ClassControllCamera.h @@ -15,15 +15,10 @@ #include "CImageBasis.h" #include "../../include/defines.h" -typedef enum -{ - OV2640_MODE_UXGA, - OV2640_MODE_SVGA, - OV2640_MODE_CIF -} ov2640_sensor_mode_t; - 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) @@ -51,13 +46,14 @@ typedef struct 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 ImageZoomMode; int ImageZoomOffsetX; int ImageZoomOffsetY; int ImageZoomSize; @@ -79,33 +75,36 @@ protected: void ledc_init(void); bool loadNextDemoImage(camera_fb_t *fb); long GetFileSize(std::string filename); - void SetCamWindow(sensor_t *s, int resolution, int xOffset, int yOffset, int xTotal, int yTotal, int xOutput, int yOutput); + 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); public: CCamera(void); esp_err_t InitCam(void); - + void LightOnOff(bool status); void LEDOnOff(bool status); esp_err_t setSensorDatenFromCCstatus(void); esp_err_t getSensorDatenToCCstatus(void); + int ov5640_set_gainceiling(sensor_t *s, gainceiling_t level); + 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); - void SetZoomSize(bool zoomEnabled, int zoomOffsetX, int zoomOffsetY, int imageSize); + 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); void SetCamSharpness(bool _autoSharpnessEnabled, int _sharpnessLevel); - - void SetLEDIntensity(float _intrel); + + void SetLEDIntensity(float _intrel); bool testCamera(void); bool getCameraInitSuccessful(void); void useDemoMode(void); framesize_t TextToFramesize(const char *text); - + esp_err_t CaptureToFile(std::string nm, int delay = 0); esp_err_t CaptureToBasisImage(CImageBasis *_Image, int delay = 0); }; diff --git a/code/components/jomjol_controlcamera/server_camera.cpp b/code/components/jomjol_controlcamera/server_camera.cpp index e3a324e5..e858f14e 100644 --- a/code/components/jomjol_controlcamera/server_camera.cpp +++ b/code/components/jomjol_controlcamera/server_camera.cpp @@ -96,7 +96,7 @@ esp_err_t handler_capture(httpd_req_t *req) if (CFstatus.changedCameraSettings) { Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); CFstatus.changedCameraSettings = false; } @@ -154,7 +154,7 @@ esp_err_t handler_capture_with_light(httpd_req_t *req) if (CFstatus.changedCameraSettings) { Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); CFstatus.changedCameraSettings = false; } @@ -236,7 +236,7 @@ esp_err_t handler_capture_save_to_file(httpd_req_t *req) if (CFstatus.changedCameraSettings) { Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); CFstatus.changedCameraSettings = false; } diff --git a/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp b/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp index a6311ab5..62efe546 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowTakeImage.cpp @@ -197,7 +197,14 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageSharpness = std::stoi(splitted[1]); - CCstatus.ImageSharpness = clipInt(_ImageSharpness, 2, -2); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageSharpness = clipInt(_ImageSharpness, 2, -2); + } + else + { + CCstatus.ImageSharpness = clipInt(_ImageSharpness, 3, -3); + } } } @@ -289,7 +296,14 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) if (isStringNumeric(splitted[1])) { int _ImageAeLevel = std::stoi(splitted[1]); - CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 2, -2); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 2, -2); + } + else + { + CCstatus.ImageAeLevel = clipInt(_ImageAeLevel, 5, -5); + } } } @@ -351,6 +365,22 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) CCstatus.ImageDcw = alphanumericToBoolean(splitted[1]); } + else if ((toUpper(splitted[0]) == "CAMDENOISE") && (splitted.size() > 1)) + { + if (isStringNumeric(splitted[1])) + { + int _ImageDenoiseLevel = std::stoi(splitted[1]); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageDenoiseLevel = 0; + } + else + { + CCstatus.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0); + } + } + } + else if ((toUpper(splitted[0]) == "CAMZOOM") && (splitted.size() > 1)) { CCstatus.ImageZoomEnabled = alphanumericToBoolean(splitted[1]); @@ -360,7 +390,19 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) { if (isStringNumeric(splitted[1])) { - CCstatus.ImageZoomOffsetX = std::stoi(splitted[1]); + int _ImageZoomOffsetX = std::stoi(splitted[1]); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480); + } + else if (CCstatus.CamSensor_id == OV3660_PID) + { + CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704); + } + else if (CCstatus.CamSensor_id == OV5640_PID) + { + CCstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); + } } } @@ -368,7 +410,19 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) { if (isStringNumeric(splitted[1])) { - CCstatus.ImageZoomOffsetY = std::stoi(splitted[1]); + int _ImageZoomOffsetY = std::stoi(splitted[1]); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360); + } + else if (CCstatus.CamSensor_id == OV3660_PID) + { + CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528); + } + else if (CCstatus.CamSensor_id == OV5640_PID) + { + CCstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); + } } } @@ -376,7 +430,19 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) { if (isStringNumeric(splitted[1])) { - CCstatus.ImageZoomSize = std::stoi(splitted[1]); + int _ImageZoomSize = std::stoi(splitted[1]); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); + } + else if (CCstatus.CamSensor_id == OV3660_PID) + { + CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0); + } + else if (CCstatus.CamSensor_id == OV5640_PID) + { + CCstatus.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0); + } } } @@ -400,7 +466,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE *pfile, string &aktparamgraph) } Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); rawImage = new CImageBasis("rawImage"); rawImage->CreateEmptyImage(CCstatus.ImageWidth, CCstatus.ImageHeight, 3); @@ -443,7 +509,7 @@ bool ClassFlowTakeImage::doFlow(string zwtime) if (CFstatus.changedCameraSettings) { Camera.setSensorDatenFromCCstatus(); // CCstatus >>> Kamera - Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CCstatus.ImageQuality, CCstatus.ImageFrameSize, CCstatus.ImageZoomEnabled, CCstatus.ImageZoomOffsetX, CCstatus.ImageZoomOffsetY, CCstatus.ImageZoomSize, CCstatus.ImageVflip); CFstatus.changedCameraSettings = false; } diff --git a/code/components/jomjol_flowcontroll/MainFlowControl.cpp b/code/components/jomjol_flowcontroll/MainFlowControl.cpp index a429173a..d64e4056 100644 --- a/code/components/jomjol_flowcontroll/MainFlowControl.cpp +++ b/code/components/jomjol_flowcontroll/MainFlowControl.cpp @@ -145,6 +145,8 @@ bool doflow(void) esp_err_t setCCstatusToCFstatus(void) { + CFstatus.CamSensor_id = CCstatus.CamSensor_id; + CFstatus.ImageFrameSize = CCstatus.ImageFrameSize; CFstatus.ImageGainceiling = CCstatus.ImageGainceiling; @@ -171,11 +173,11 @@ esp_err_t setCCstatusToCFstatus(void) CFstatus.ImageHmirror = CCstatus.ImageHmirror; CFstatus.ImageVflip = CCstatus.ImageVflip; CFstatus.ImageDcw = CCstatus.ImageDcw; + CFstatus.ImageDenoiseLevel = CCstatus.ImageDenoiseLevel; CFstatus.ImageLedIntensity = CCstatus.ImageLedIntensity; CFstatus.ImageZoomEnabled = CCstatus.ImageZoomEnabled; - CFstatus.ImageZoomMode = CCstatus.ImageZoomMode; CFstatus.ImageZoomOffsetX = CCstatus.ImageZoomOffsetX; CFstatus.ImageZoomOffsetY = CCstatus.ImageZoomOffsetY; CFstatus.ImageZoomSize = CCstatus.ImageZoomSize; @@ -187,6 +189,8 @@ esp_err_t setCCstatusToCFstatus(void) esp_err_t setCFstatusToCCstatus(void) { + // CCstatus.CamSensor_id = CFstatus.CamSensor_id; + CCstatus.ImageFrameSize = CFstatus.ImageFrameSize; CCstatus.ImageGainceiling = CFstatus.ImageGainceiling; @@ -213,11 +217,11 @@ esp_err_t setCFstatusToCCstatus(void) CCstatus.ImageHmirror = CFstatus.ImageHmirror; CCstatus.ImageVflip = CFstatus.ImageVflip; CCstatus.ImageDcw = CFstatus.ImageDcw; + CCstatus.ImageDenoiseLevel = CFstatus.ImageDenoiseLevel; CCstatus.ImageLedIntensity = CFstatus.ImageLedIntensity; CCstatus.ImageZoomEnabled = CFstatus.ImageZoomEnabled; - CCstatus.ImageZoomMode = CFstatus.ImageZoomMode; CCstatus.ImageZoomOffsetX = CFstatus.ImageZoomOffsetX; CCstatus.ImageZoomOffsetY = CFstatus.ImageZoomOffsetY; CCstatus.ImageZoomSize = CFstatus.ImageZoomSize; @@ -234,8 +238,6 @@ esp_err_t setCFstatusToCam(void) if (s != NULL) { s->set_framesize(s, CFstatus.ImageFrameSize); - s->set_gainceiling(s, CFstatus.ImageGainceiling); - s->set_quality(s, CFstatus.ImageQuality); // 0 - 63 s->set_brightness(s, CFstatus.ImageBrightness); // -2 to 2 @@ -244,33 +246,37 @@ esp_err_t setCFstatusToCam(void) // s->set_sharpness(s, CFstatus.ImageSharpness); // auto-sharpness is not officially supported, default to 0 Camera.SetCamSharpness(CFstatus.ImageAutoSharpness, CFstatus.ImageSharpness); - s->set_exposure_ctrl(s, CFstatus.ImageAec); // 0 = disable , 1 = enable + s->set_denoise(s, CFstatus.ImageDenoiseLevel); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) + + s->set_special_effect(s, CFstatus.ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) + s->set_wb_mode(s, CFstatus.ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) + s->set_ae_level(s, CFstatus.ImageAeLevel); // -2 to 2 s->set_aec_value(s, CFstatus.ImageAecValue); // 0 to 1200 - s->set_aec2(s, CFstatus.ImageAec2); // 0 = disable , 1 = enable + s->set_agc_gain(s, CFstatus.ImageAgcGain); // 0 to 30 - s->set_gain_ctrl(s, CFstatus.ImageAgc); // 0 = disable , 1 = enable - s->set_agc_gain(s, CFstatus.ImageAgcGain); // 0 to 30 + // s->set_gainceiling(s, CFstatus.ImageGainceiling); // Image gain (GAINCEILING_x2, x4, x8, x16, x32, x64 or x128) + Camera.ov5640_set_gainceiling(s, CFstatus.ImageGainceiling); + + s->set_lenc(s, CFstatus.ImageLenc); // 0 = disable , 1 = enable + s->set_gain_ctrl(s, CFstatus.ImageAgc); // 0 = disable , 1 = enable + s->set_exposure_ctrl(s, CFstatus.ImageAec); // 0 = disable , 1 = enable + + s->set_hmirror(s, CFstatus.ImageHmirror); // 0 = disable , 1 = enable + s->set_vflip(s, CFstatus.ImageVflip); // 0 = disable , 1 = enable + s->set_aec2(s, CFstatus.ImageAec2); // 0 = disable , 1 = enable s->set_bpc(s, CFstatus.ImageBpc); // 0 = disable , 1 = enable s->set_wpc(s, CFstatus.ImageWpc); // 0 = disable , 1 = enable s->set_raw_gma(s, CFstatus.ImageRawGma); // 0 = disable , 1 = enable - s->set_lenc(s, CFstatus.ImageLenc); // 0 = disable , 1 = enable - s->set_hmirror(s, CFstatus.ImageHmirror); // 0 = disable , 1 = enable - s->set_vflip(s, CFstatus.ImageVflip); // 0 = disable , 1 = enable - - s->set_dcw(s, CFstatus.ImageDcw); // 0 = disable , 1 = enable - - s->set_wb_mode(s, CFstatus.ImageWbMode); // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) s->set_awb_gain(s, CFstatus.ImageAwbGain); // 0 = disable , 1 = enable s->set_whitebal(s, CFstatus.ImageAwb); // 0 = disable , 1 = enable - // special_effect muß als Letztes gesetzt werden, sonst geht es nicht - s->set_special_effect(s, CFstatus.ImageSpecialEffect); // 0 to 6 (0 - No Effect, 1 - Negative, 2 - Grayscale, 3 - Red Tint, 4 - Green Tint, 5 - Blue Tint, 6 - Sepia) + s->set_dcw(s, CFstatus.ImageDcw); // 0 = disable , 1 = enable - TickType_t xDelay2 = 1000 / portTICK_PERIOD_MS; + TickType_t xDelay2 = 100 / portTICK_PERIOD_MS; vTaskDelay(xDelay2); return ESP_OK; @@ -961,6 +967,21 @@ esp_err_t handler_editflow(httpd_req_t *req) } } + if (httpd_query_key_value(_query, "aecgc", _valuechar, 30) == ESP_OK) + { + int _aecgc = std::stoi(_valuechar); + switch (_aecgc) + { + case 1: CFstatus.ImageGainceiling = GAINCEILING_4X; break; + case 2: CFstatus.ImageGainceiling = GAINCEILING_8X; break; + case 3: CFstatus.ImageGainceiling = GAINCEILING_16X; break; + case 4: CFstatus.ImageGainceiling = GAINCEILING_32X; break; + case 5: CFstatus.ImageGainceiling = GAINCEILING_64X; break; + case 6: CFstatus.ImageGainceiling = GAINCEILING_128X; break; + default: CFstatus.ImageGainceiling = GAINCEILING_2X; + } + } + if (httpd_query_key_value(_query, "qual", _valuechar, 30) == ESP_OK) { std::string _qual = std::string(_valuechar); @@ -1007,7 +1028,14 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_shp)) { int _shp_ = std::stoi(_valuechar); - CFstatus.ImageSaturation = clipInt(_shp_, 2, -2); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CFstatus.ImageSharpness = clipInt(_shp_, 2, -2); + } + else + { + CFstatus.ImageSharpness = clipInt(_shp_, 3, -3); + } } } @@ -1067,7 +1095,14 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_ael)) { int _ael_ = std::stoi(_valuechar); - CFstatus.ImageAeLevel = clipInt(_ael_, 2, -2); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CFstatus.ImageAeLevel = clipInt(_ael_, 2, -2); + } + else + { + CFstatus.ImageAeLevel = clipInt(_ael_, 5, -5); + } } } @@ -1139,6 +1174,23 @@ esp_err_t handler_editflow(httpd_req_t *req) CFstatus.ImageDcw = alphanumericToBoolean(_dcw); } + if (httpd_query_key_value(_query, "den", _valuechar, 30) == ESP_OK) + { + std::string _idlv = std::string(_valuechar); + if (isStringNumeric(_idlv)) + { + int _ImageDenoiseLevel = std::stoi(_valuechar); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CCstatus.ImageDenoiseLevel = 0; + } + else + { + CFstatus.ImageDenoiseLevel = clipInt(_ImageDenoiseLevel, 8, 0); + } + } + } + if (httpd_query_key_value(_query, "zoom", _valuechar, 30) == ESP_OK) { std::string _zoom = std::string(_valuechar); @@ -1151,7 +1203,18 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_zoomx)) { int _ImageZoomOffsetX = std::stoi(_valuechar); - CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 480, -480); + } + else if (CCstatus.CamSensor_id == OV3660_PID) + { + CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 704, -704); + } + else if (CCstatus.CamSensor_id == OV5640_PID) + { + CFstatus.ImageZoomOffsetX = clipInt(_ImageZoomOffsetX, 960, -960); + } } } @@ -1161,7 +1224,18 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_zoomy)) { int _ImageZoomOffsetY = std::stoi(_valuechar); - CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 360, -360); + } + else if (CCstatus.CamSensor_id == OV3660_PID) + { + CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 528, -528); + } + else if (CCstatus.CamSensor_id == OV5640_PID) + { + CFstatus.ImageZoomOffsetY = clipInt(_ImageZoomOffsetY, 720, -720); + } } } @@ -1171,7 +1245,18 @@ esp_err_t handler_editflow(httpd_req_t *req) if (isStringNumeric(_zooms)) { int _ImageZoomSize = std::stoi(_valuechar); - CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); + if (CCstatus.CamSensor_id == OV2640_PID) + { + CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 29, 0); + } + else if (CCstatus.CamSensor_id == OV3660_PID) + { + CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 43, 0); + } + else if (CCstatus.CamSensor_id == OV5640_PID) + { + CFstatus.ImageZoomSize = clipInt(_ImageZoomSize, 59, 0); + } } } @@ -1205,8 +1290,8 @@ esp_err_t handler_editflow(httpd_req_t *req) // CFstatus >>> Kamera setCFstatusToCam(); - Camera.SetQualityZoomSize(CFstatus.ImageQuality, CFstatus.ImageFrameSize, CFstatus.ImageZoomEnabled, CFstatus.ImageZoomOffsetX, CFstatus.ImageZoomOffsetY, CFstatus.ImageZoomSize); - // Camera.SetZoomSize(CFstatus.ImageZoomEnabled, CFstatus.ImageZoomOffsetX, CFstatus.ImageZoomOffsetY, CFstatus.ImageZoomSize); + Camera.SetQualityZoomSize(CFstatus.ImageQuality, CFstatus.ImageFrameSize, CFstatus.ImageZoomEnabled, CFstatus.ImageZoomOffsetX, CFstatus.ImageZoomOffsetY, CFstatus.ImageZoomSize, CFstatus.ImageVflip); + // Camera.SetZoomSize(CFstatus.ImageZoomEnabled, CFstatus.ImageZoomOffsetX, CFstatus.ImageZoomOffsetY, CFstatus.ImageZoomSize, CFstatus.ImageVflip); // Kameraeinstellungen wurden verädert CFstatus.changedCameraSettings = true; diff --git a/code/components/jomjol_flowcontroll/MainFlowControl.h b/code/components/jomjol_flowcontroll/MainFlowControl.h index 2810837f..a2c2047e 100644 --- a/code/components/jomjol_flowcontroll/MainFlowControl.h +++ b/code/components/jomjol_flowcontroll/MainFlowControl.h @@ -13,8 +13,10 @@ 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) + 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 @@ -40,13 +42,14 @@ typedef struct 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 ImageZoomMode; int ImageZoomOffsetX; int ImageZoomOffsetY; int ImageZoomSize; diff --git a/code/sdkconfig.defaults b/code/sdkconfig.defaults index e41514a1..0fe53036 100644 --- a/code/sdkconfig.defaults +++ b/code/sdkconfig.defaults @@ -135,7 +135,8 @@ CONFIG_OV7670_SUPPORT=n CONFIG_OV7725_SUPPORT=n CONFIG_NT99141_SUPPORT=n CONFIG_OV3660_SUPPORT=n -CONFIG_OV5640_SUPPORT=n +CONFIG_OV2640_SUPPORT=y +CONFIG_OV5640_SUPPORT=y CONFIG_GC2145_SUPPORT=n CONFIG_GC032A_SUPPORT=n CONFIG_GC0308_SUPPORT=n diff --git a/param-docs/expert-params.txt b/param-docs/expert-params.txt index db38cc92..056b7128 100644 --- a/param-docs/expert-params.txt +++ b/param-docs/expert-params.txt @@ -19,6 +19,7 @@ CamWpc CamRawGma CamLenc CamDcw +CamDenoise CamZoom CamZoomSize CamZoomOffsetX diff --git a/param-docs/parameter-pages/TakeImage/CamAeLevel.md b/param-docs/parameter-pages/TakeImage/CamAeLevel.md index 4c235b9f..7f7c361e 100644 --- a/param-docs/parameter-pages/TakeImage/CamAeLevel.md +++ b/param-docs/parameter-pages/TakeImage/CamAeLevel.md @@ -13,4 +13,5 @@ Default Value: `0` The exposure offset for automatic exposure, lower values produce darker image. -Range (`-2` .. `2`) +available range on OV2640 (`-2` .. `2`) +available range on OV3660 and OV5640 (`-5` .. `5`) diff --git a/param-docs/parameter-pages/TakeImage/CamDenoise.md b/param-docs/parameter-pages/TakeImage/CamDenoise.md index 8a454ef1..56de939b 100644 --- a/param-docs/parameter-pages/TakeImage/CamDenoise.md +++ b/param-docs/parameter-pages/TakeImage/CamDenoise.md @@ -1,9 +1,11 @@ # Parameter `CamDenoise` -Default Value: `true` +Default Value: `0` !!! Warning This is an **Expert Parameter**! Only change it if you understand what it does! **Denoise** -Denoise Image (not supported and not implemented). +Denoise Image, is only supported by OV3660 and OV5640 + +Range (`0` .. `8`) diff --git a/param-docs/parameter-pages/TakeImage/CamVflip.md b/param-docs/parameter-pages/TakeImage/CamVflip.md index 4b1b2960..45e35921 100644 --- a/param-docs/parameter-pages/TakeImage/CamVflip.md +++ b/param-docs/parameter-pages/TakeImage/CamVflip.md @@ -7,6 +7,9 @@ Default Value: `false` !!! Note This parameter can also be set on the Reference Image configuration page! +!!! Note + On some OV5640 Cameras, the image becomes reddish when Vflip is used in conjunction with the zoom function! + **Flip Image** When **true**, the camera image is flipped top-to-bottom. diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 8f40444e..70e4e46d 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -26,6 +26,7 @@ CamLenc = true CamHmirror = false CamVflip = false CamDcw = true +CamDenoise = 0 CamZoom = false CamZoomOffsetX = 0 CamZoomOffsetY = 0 diff --git a/sd-card/html/edit_config_template.html b/sd-card/html/edit_config_template.html index 71383409..1b3c1770 100644 --- a/sd-card/html/edit_config_template.html +++ b/sd-card/html/edit_config_template.html @@ -375,8 +375,8 @@ Sharpness - + $TOOLTIP_TakeImage_CamSharpness @@ -472,8 +472,8 @@ Auto Exposure Level - + $TOOLTIP_TakeImage_CamAeLevel @@ -605,6 +605,17 @@ $TOOLTIP_TakeImage_CamDcw + + + Denoise + + + + + $TOOLTIP_TakeImage_CamDenoise + + Zoom @@ -623,8 +634,8 @@ Zoom Size - + $TOOLTIP_TakeImage_CamZoomSize @@ -634,8 +645,8 @@ Zoom Offset X - Pixel + Pixel $TOOLTIP_TakeImage_CamZoomOffsetX @@ -645,11 +656,11 @@ Zoom Offset Y - Pixel + Pixel $TOOLTIP_TakeImage_CamZoomOffsetY - + @@ -2231,6 +2242,7 @@ function UpdateInput() { WriteParameter(param, category, "TakeImage", "CamHmirror", false); WriteParameter(param, category, "TakeImage", "CamVflip", false); WriteParameter(param, category, "TakeImage", "CamDcw", false); + WriteParameter(param, category, "TakeImage", "CamDenoise", false); WriteParameter(param, category, "TakeImage", "CamZoom", false); WriteParameter(param, category, "TakeImage", "CamZoomOffsetX", false); WriteParameter(param, category, "TakeImage", "CamZoomOffsetY", false); @@ -2368,7 +2380,7 @@ function ReadParameterAll() { ReadParameter(param, "TakeImage", "RawImagesLocation", true); ReadParameter(param, "TakeImage", "RawImagesRetention", true); - ReadParameter(param, "TakeImage", "WaitBeforeTakingPicture", false); + ReadParameter(param, "TakeImage", "WaitBeforeTakingPicture", false); ReadParameter(param, "TakeImage", "CamGainceiling", false); ReadParameter(param, "TakeImage", "CamQuality", false); ReadParameter(param, "TakeImage", "CamBrightness", false); @@ -2392,7 +2404,8 @@ function ReadParameterAll() { ReadParameter(param, "TakeImage", "CamLenc", false); ReadParameter(param, "TakeImage", "CamHmirror", false); ReadParameter(param, "TakeImage", "CamVflip", false); - ReadParameter(param, "TakeImage", "CamDcw", false); + ReadParameter(param, "TakeImage", "CamDcw", false); + ReadParameter(param, "TakeImage", "CamDenoise", false); ReadParameter(param, "TakeImage", "CamZoom", false); ReadParameter(param, "TakeImage", "CamZoomOffsetX", false); ReadParameter(param, "TakeImage", "CamZoomOffsetY", false); @@ -2582,6 +2595,8 @@ function camSettingsSet(){ document.getElementById("overlaytext").innerHTML = "Save Cam Settings..."; var _waitb_temp = document.getElementById("TakeImage_WaitBeforeTakingPicture_value1").value; + + var _aecgc_temp = document.getElementById("TakeImage_CamGainceiling_value1").selectedIndex; var _qual_temp = document.getElementById("TakeImage_CamQuality_value1").value; var _bri_temp = document.getElementById("TakeImage_CamBrightness_value1").value; @@ -2699,10 +2714,12 @@ function camSettingsSet(){ } else { _dcw_temp = '0'; - } - + } + + var _denoise_temp = document.getElementById("TakeImage_CamDenoise_value1").value; + var _ledi_temp = document.getElementById("TakeImage_LEDIntensity_value1").value; - + var _zoom_temp = document.getElementById("TakeImage_CamZoom_value1").selectedIndex; if (_zoom_temp == '0') { _zoom_temp = '1'; @@ -2710,14 +2727,14 @@ function camSettingsSet(){ else { _zoom_temp = '0'; } - + var _zoomx_temp = document.getElementById("TakeImage_CamZoomOffsetX_value1").value; var _zoomy_temp = document.getElementById("TakeImage_CamZoomOffsetY_value1").value; var _zooms_temp = document.getElementById("TakeImage_CamZoomSize_value1").value; // bei einmal Alles senden kommt es zu problemen!!!!!!!!!!!!!!!!!!!! var url_1 = domainname + "/editflow?task=cam_settings"; - url_1 = url_1 + "&waitb=" + _waitb_temp + "&qual=" + _qual_temp; + url_1 = url_1 + "&waitb=" + _waitb_temp + "&aecgc=" + _aecgc_temp + "&qual=" + _qual_temp; url_1 = url_1 + "&bri=" + _bri_temp + "&con=" + _con_temp + "&sat=" + _sat_temp + "&shp=" + _shp_temp + "&ashp=" + _ashp_temp; url_1 = url_1 + "&spe=" + _spe_temp + "&wbm=" + _wbm_temp + "&awb=" + _awb_temp + "&awbg=" + _awbg_temp; url_1 = url_1 + "&aec=" + _aec_temp + "&aec2=" + _aec2_temp + "&ael=" + _ael_temp + "&aecv=" + _aecv_temp; @@ -2725,7 +2742,7 @@ function camSettingsSet(){ var url_2 = domainname + "/editflow?task=cam_settings"; url_2 = url_2 + "&agc=" + _agc_temp + "&agcg=" + _agcg_temp + "&bpc=" + _bpc_temp + "&wpc=" + _wpc_temp; url_2 = url_2 + "&rgma=" + _rgma_temp + "&lenc=" + _lenc_temp + "&mirror=" + _mirror_temp + "&flip=" + _flip_temp; - url_2 = url_2 + "&dcw=" + _dcw_temp + "&ledi=" + _ledi_temp; + url_2 = url_2 + "&dcw=" + _dcw_temp + "&den=" + _denoise_temp + "&ledi=" + _ledi_temp; if (_zoom_temp != '0') { url_2 = url_2 + "&zoom=" + _zoom_temp + "&zooms=" + _zooms_temp; diff --git a/sd-card/html/edit_reference.html b/sd-card/html/edit_reference.html index d6359bd4..8b0bb49a 100644 --- a/sd-card/html/edit_reference.html +++ b/sd-card/html/edit_reference.html @@ -184,8 +184,8 @@ - + $TOOLTIP_TakeImage_CamZoomOffsetX @@ -195,8 +195,8 @@ - + $TOOLTIP_TakeImage_CamZoomSize @@ -204,8 +204,8 @@ - + $TOOLTIP_TakeImage_CamZoomOffsetY diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index a0aea949..0a49399c 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -129,7 +129,8 @@ function ParseConfig() { ParamAddValue(param, catname, "CamLenc"); // lens correction (1 or 0) ParamAddValue(param, catname, "CamHmirror"); // (0 or 1) flip horizontally ParamAddValue(param, catname, "CamVflip"); // Invert image (0 or 1) - ParamAddValue(param, catname, "CamDcw"); // downsize enable (1 or 0) + ParamAddValue(param, catname, "CamDcw"); // downsize enable (1 or 0) + ParamAddValue(param, catname, "CamDenoise"); // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) ParamAddValue(param, catname, "CamZoom"); ParamAddValue(param, catname, "CamZoomOffsetX"); ParamAddValue(param, catname, "CamZoomOffsetY"); @@ -483,7 +484,7 @@ function getCamConfig() { param["TakeImage"]["CamContrast"]["enabled"] = true; //-2 - 2 param["TakeImage"]["CamSaturation"]["enabled"] = true; //-2 - 2 param["TakeImage"]["CamSharpness"]["enabled"] = true; //-2 - 2 - param["TakeImage"]["CamAutoSharpness"]["enabled"] = true; //(1 or 0) + param["TakeImage"]["CamAutoSharpness"]["enabled"] = true; //(1 or 0) param["TakeImage"]["CamSpecialEffect"]["enabled"] = true; // 0 - 6 param["TakeImage"]["CamWbMode"]["enabled"] = true; // 0 to 4 - if awb_gain enabled (0 - Auto, 1 - Sunny, 2 - Cloudy, 3 - Office, 4 - Home) param["TakeImage"]["CamAwb"]["enabled"] = true; // white balance enable (0 or 1) @@ -500,12 +501,13 @@ function getCamConfig() { param["TakeImage"]["CamLenc"]["enabled"] = true; // lens correction (1 or 0) param["TakeImage"]["CamHmirror"]["enabled"] = true; // (0 or 1) flip horizontally param["TakeImage"]["CamVflip"]["enabled"] = true; // Invert image (0 or 1) - param["TakeImage"]["CamDcw"]["enabled"] = true; // downsize enable (1 or 0) + param["TakeImage"]["CamDcw"]["enabled"] = true; // downsize enable (1 or 0) + param["TakeImage"]["CamDenoise"]["enabled"] = true; // The OV2640 does not support it, OV3660 and OV5640 (0 to 8) param["TakeImage"]["CamZoom"]["enabled"] = true; param["TakeImage"]["CamZoomOffsetX"]["enabled"] = true; param["TakeImage"]["CamZoomOffsetY"]["enabled"] = true; - param["TakeImage"]["CamZoomSize"]["enabled"] = true; - param["TakeImage"]["LEDIntensity"]["enabled"] = true; + param["TakeImage"]["CamZoomSize"]["enabled"] = true; + param["TakeImage"]["LEDIntensity"]["enabled"] = true; if (!param["System"]["Tooltip"]["found"]) { param["System"]["Tooltip"]["found"] = true; @@ -618,6 +620,10 @@ function getCamConfig() { param["TakeImage"]["CamDcw"]["found"] = true; param["TakeImage"]["CamDcw"].value1 = 'true'; } + if (!param["TakeImage"]["CamDenoise"]["found"]) { + param["TakeImage"]["CamDenoise"]["found"] = true; + param["TakeImage"]["CamDenoise"].value1 = '0'; + } if (!param["TakeImage"]["CamZoom"]["found"]) { param["TakeImage"]["CamZoom"]["found"] = true; param["TakeImage"]["CamZoom"].value1 = 'false';