mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-11 22:16:56 +03:00
Support crop image on sensor, grayscale, auto exposure level
This commit is contained in:
@@ -31,7 +31,7 @@ void ClassFlowAlignment::SetInitialParameter(void)
|
||||
AlignAndCutImage = NULL;
|
||||
ImageBasis = NULL;
|
||||
ImageTMP = NULL;
|
||||
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
|
||||
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
|
||||
AlgROI = (ImageData*)malloc_psram_heap(std::string(TAG) + "->AlgROI", sizeof(ImageData), MALLOC_CAP_8BIT | MALLOC_CAP_SPIRAM);
|
||||
#endif
|
||||
previousElement = NULL;
|
||||
|
||||
@@ -50,6 +50,15 @@ void ClassFlowTakeImage::SetInitialParameter(void)
|
||||
ImageQuality = 5;
|
||||
rawImage = NULL;
|
||||
ImageSize = FRAMESIZE_VGA;
|
||||
ZoomEnabled = false;
|
||||
ZoomMode = 0;
|
||||
zoomOffsetX = 0;
|
||||
zoomOffsetY = 0;
|
||||
#ifdef GRAYSCALE_AS_DEFAULT
|
||||
ImageGrayscale = true;
|
||||
#else
|
||||
ImageGrayscale = false;
|
||||
#endif
|
||||
SaveAllFiles = false;
|
||||
disabled = false;
|
||||
FixedExposure = false;
|
||||
@@ -73,6 +82,7 @@ bool ClassFlowTakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
int _brightness = -100;
|
||||
int _contrast = -100;
|
||||
int _saturation = -100;
|
||||
int _autoExposureLevel = 0;
|
||||
|
||||
if (aktparamgraph.size() == 0)
|
||||
if (!this->GetNextParagraph(pfile, aktparamgraph))
|
||||
@@ -92,6 +102,29 @@ bool ClassFlowTakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
if ((toUpper(splitted[0]) == "IMAGEQUALITY") && (splitted.size() > 1))
|
||||
ImageQuality = std::stod(splitted[1]);
|
||||
|
||||
if ((toUpper(splitted[0]) == "ZOOM") && (splitted.size() > 1))
|
||||
{
|
||||
if (toUpper(splitted[1]) == "TRUE")
|
||||
ZoomEnabled = true;
|
||||
else if (toUpper(splitted[1]) == "FALSE")
|
||||
ZoomEnabled = false;
|
||||
}
|
||||
if ((toUpper(splitted[0]) == "ZOOMMODE") && (splitted.size() > 1))
|
||||
ZoomMode = std::stod(splitted[1]);
|
||||
if ((toUpper(splitted[0]) == "ZOOMOFFSETX") && (splitted.size() > 1))
|
||||
zoomOffsetX = std::stod(splitted[1]);
|
||||
if ((toUpper(splitted[0]) == "ZOOMOFFSETY") && (splitted.size() > 1))
|
||||
zoomOffsetY = std::stod(splitted[1]);
|
||||
if ((toUpper(splitted[0]) == "GRAYSCALE") && (splitted.size() > 1))
|
||||
{
|
||||
if (toUpper(splitted[1]) == "TRUE")
|
||||
ImageGrayscale = true;
|
||||
else if (toUpper(splitted[1]) == "FALSE")
|
||||
ImageGrayscale = false;
|
||||
}
|
||||
if ((toUpper(splitted[0]) == "AUTOEXPOSURELEVEL") && (splitted.size() > 1))
|
||||
_autoExposureLevel = std::stod(splitted[1]);
|
||||
|
||||
if ((toUpper(splitted[0]) == "IMAGESIZE") && (splitted.size() > 1))
|
||||
{
|
||||
ImageSize = Camera.TextToFramesize(splitted[1].c_str());
|
||||
@@ -150,8 +183,8 @@ bool ClassFlowTakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
}
|
||||
}
|
||||
|
||||
Camera.SetBrightnessContrastSaturation(_brightness, _contrast, _saturation);
|
||||
Camera.SetQualitySize(ImageQuality, ImageSize);
|
||||
Camera.SetBrightnessContrastSaturation(_brightness, _contrast, _saturation, _autoExposureLevel, ImageGrayscale);
|
||||
Camera.SetQualitySize(ImageQuality, ImageSize, ZoomEnabled, ZoomMode, zoomOffsetX, zoomOffsetY);
|
||||
|
||||
image_width = Camera.image_width;
|
||||
image_height = Camera.image_height;
|
||||
|
||||
@@ -17,6 +17,11 @@ protected:
|
||||
float waitbeforepicture_store;
|
||||
framesize_t ImageSize;
|
||||
bool isImageSize;
|
||||
bool ZoomEnabled = false;
|
||||
int ZoomMode = 0;
|
||||
int zoomOffsetX = 0;
|
||||
int zoomOffsetY = 0;
|
||||
bool ImageGrayscale;
|
||||
int ImageQuality;
|
||||
time_t TimeImageTaken;
|
||||
string namerawimage;
|
||||
|
||||
@@ -692,39 +692,75 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
||||
if (_task.compare("test_take") == 0)
|
||||
{
|
||||
std::string _host = "";
|
||||
std::string _bri = "";
|
||||
std::string _con = "";
|
||||
std::string _sat = "";
|
||||
std::string _int = "";
|
||||
int bri = -100;
|
||||
int sat = -100;
|
||||
int con = -100;
|
||||
int intens = -100;
|
||||
int aelevel = 0;
|
||||
int zoommode = 0;
|
||||
int zoomoffsetx = 0;
|
||||
int zoomoffsety = 0;
|
||||
bool zoom = false;
|
||||
#ifdef GRAYSCALE_AS_DEFAULT
|
||||
bool grayscale = true;
|
||||
#else
|
||||
bool grayscale = false;
|
||||
#endif
|
||||
|
||||
if (httpd_query_key_value(_query, "host", _valuechar, 30) == ESP_OK) {
|
||||
_host = std::string(_valuechar);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "int", _valuechar, 30) == ESP_OK) {
|
||||
_int = std::string(_valuechar);
|
||||
std::string _int = std::string(_valuechar);
|
||||
intens = stoi(_int);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "bri", _valuechar, 30) == ESP_OK) {
|
||||
_bri = std::string(_valuechar);
|
||||
std::string _bri = std::string(_valuechar);
|
||||
bri = stoi(_bri);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "con", _valuechar, 30) == ESP_OK) {
|
||||
_con = std::string(_valuechar);
|
||||
std::string _con = std::string(_valuechar);
|
||||
con = stoi(_con);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "sat", _valuechar, 30) == ESP_OK) {
|
||||
_sat = std::string(_valuechar);
|
||||
std::string _sat = std::string(_valuechar);
|
||||
sat = stoi(_sat);
|
||||
}
|
||||
|
||||
if (httpd_query_key_value(_query, "ae", _valuechar, 30) == ESP_OK) {
|
||||
std::string _ae = std::string(_valuechar);
|
||||
aelevel = stoi(_ae);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "gs", _valuechar, 30) == ESP_OK) {
|
||||
std::string _gr = std::string(_valuechar);
|
||||
if (stoi(_gr) != 0)
|
||||
grayscale = true;
|
||||
else
|
||||
grayscale = false;
|
||||
}
|
||||
if (httpd_query_key_value(_query, "z", _valuechar, 30) == ESP_OK) {
|
||||
std::string _zoom = std::string(_valuechar);
|
||||
if (stoi(_zoom) != 0)
|
||||
zoom = true;
|
||||
else
|
||||
zoom = false;
|
||||
}
|
||||
if (httpd_query_key_value(_query, "zm", _valuechar, 30) == ESP_OK) {
|
||||
std::string _zm = std::string(_valuechar);
|
||||
zoommode = stoi(_zm);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "x", _valuechar, 30) == ESP_OK) {
|
||||
std::string _x = std::string(_valuechar);
|
||||
zoomoffsetx = stoi(_x);
|
||||
}
|
||||
if (httpd_query_key_value(_query, "y", _valuechar, 30) == ESP_OK) {
|
||||
std::string _y = std::string(_valuechar);
|
||||
zoomoffsety = stoi(_y);
|
||||
}
|
||||
|
||||
// ESP_LOGD(TAG, "Parameter host: %s", _host.c_str());
|
||||
// string zwzw = "Do " + _task + " start\n"; ESP_LOGD(TAG, zwzw.c_str());
|
||||
Camera.SetBrightnessContrastSaturation(bri, con, sat);
|
||||
Camera.SetZoom(zoom, zoommode, zoomoffsetx, zoomoffsety);
|
||||
Camera.SetBrightnessContrastSaturation(bri, con, sat, aelevel, grayscale);
|
||||
Camera.SetLEDIntensity(intens);
|
||||
ESP_LOGD(TAG, "test_take - vor TakeImage");
|
||||
std::string zw = flowctrl.doSingleStep("[TakeImage]", _host);
|
||||
|
||||
Reference in New Issue
Block a user