mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 20:16:55 +03:00
Update
This commit is contained in:
@@ -136,18 +136,34 @@ static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
bool CCamera::SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation)
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
sensor_t * s = esp_camera_sensor_get();
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
_brightness = min(2, max(-2, _brightness));
|
_brightness = min(2, max(-2, _brightness));
|
||||||
// _contrast = min(2, max(-2, _contrast));
|
_contrast = min(2, max(-2, _contrast));
|
||||||
// _saturation = min(2, max(-2, _saturation));
|
// _saturation = min(2, max(-2, _saturation));
|
||||||
|
|
||||||
// s->set_saturation(s, _saturation);
|
// s->set_saturation(s, _saturation);
|
||||||
// s->set_contrast(s, _contrast);
|
s->set_contrast(s, _contrast);
|
||||||
s->set_brightness(s, _brightness);
|
s->set_brightness(s, _brightness);
|
||||||
}
|
|
||||||
|
|
||||||
|
if (_brightness != brightness)
|
||||||
|
result = true;
|
||||||
|
if (_contrast != contrast)
|
||||||
|
result = true;
|
||||||
|
if (_saturation != saturation)
|
||||||
|
result = true;
|
||||||
|
|
||||||
|
brightness = _brightness;
|
||||||
|
contrast = _contrast;
|
||||||
|
saturation = _saturation;
|
||||||
|
|
||||||
|
if (result && isFixedExposure)
|
||||||
|
EnableAutoExposure(waitbeforepicture_org);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CCamera::SetQualitySize(int qual, framesize_t resol)
|
void CCamera::SetQualitySize(int qual, framesize_t resol)
|
||||||
@@ -194,6 +210,31 @@ void CCamera::SetQualitySize(int qual, framesize_t resol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CCamera::EnableAutoExposure(int flashdauer)
|
||||||
|
{
|
||||||
|
LEDOnOff(true);
|
||||||
|
LightOnOff(true);
|
||||||
|
const TickType_t xDelay = flashdauer / portTICK_PERIOD_MS;
|
||||||
|
vTaskDelay( xDelay );
|
||||||
|
|
||||||
|
camera_fb_t * fb = esp_camera_fb_get();
|
||||||
|
if (!fb) {
|
||||||
|
ESP_LOGE(TAGCAMERACLASS, "Camera Capture Failed");
|
||||||
|
}
|
||||||
|
esp_camera_fb_return(fb);
|
||||||
|
|
||||||
|
sensor_t * s = esp_camera_sensor_get();
|
||||||
|
s->set_gain_ctrl(s, 0);
|
||||||
|
s->set_exposure_ctrl(s, 0);
|
||||||
|
|
||||||
|
|
||||||
|
LEDOnOff(false);
|
||||||
|
LightOnOff(false);
|
||||||
|
isFixedExposure = true;
|
||||||
|
waitbeforepicture_org = flashdauer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
||||||
{
|
{
|
||||||
@@ -236,7 +277,7 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
|
|||||||
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get");
|
LogFile.WriteHeapInfo("CCamera::CaptureToBasisImage - After fb_get");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
LEDOnOff(false);
|
LEDOnOff(false);
|
||||||
|
|
||||||
if (delay > 0)
|
if (delay > 0)
|
||||||
LightOnOff(false);
|
LightOnOff(false);
|
||||||
@@ -526,6 +567,10 @@ CCamera::CCamera()
|
|||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
printf("CreateClassCamera\n");
|
printf("CreateClassCamera\n");
|
||||||
#endif
|
#endif
|
||||||
|
brightness = -5;
|
||||||
|
contrast = -5;
|
||||||
|
saturation = -5;
|
||||||
|
isFixedExposure = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t CCamera::InitCam()
|
esp_err_t CCamera::InitCam()
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ class CCamera {
|
|||||||
protected:
|
protected:
|
||||||
int ActualQuality;
|
int ActualQuality;
|
||||||
framesize_t ActualResolution;
|
framesize_t ActualResolution;
|
||||||
|
int brightness, contrast, saturation;
|
||||||
|
bool isFixedExposure;
|
||||||
|
int waitbeforepicture_org;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int image_height, image_width;
|
int image_height, image_width;
|
||||||
@@ -34,9 +37,12 @@ class CCamera {
|
|||||||
void LEDOnOff(bool status);
|
void LEDOnOff(bool status);
|
||||||
esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
|
esp_err_t CaptureToHTTP(httpd_req_t *req, int delay = 0);
|
||||||
void SetQualitySize(int qual, framesize_t resol);
|
void SetQualitySize(int qual, framesize_t resol);
|
||||||
void SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation);
|
bool SetBrightnessContrastSaturation(int _brightness, int _contrast, int _saturation);
|
||||||
void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol);
|
void GetCameraParameter(httpd_req_t *req, int &qual, framesize_t &resol);
|
||||||
|
|
||||||
|
void EnableAutoExposure(int flashdauer);
|
||||||
|
|
||||||
|
|
||||||
framesize_t TextToFramesize(const char * text);
|
framesize_t TextToFramesize(const char * text);
|
||||||
|
|
||||||
esp_err_t CaptureToFile(std::string nm, int delay = 0);
|
esp_err_t CaptureToFile(std::string nm, int delay = 0);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ void ClassFlowMakeImage::SetInitialParameter(void)
|
|||||||
ImageSize = FRAMESIZE_VGA;
|
ImageSize = FRAMESIZE_VGA;
|
||||||
SaveAllFiles = false;
|
SaveAllFiles = false;
|
||||||
disabled = false;
|
disabled = false;
|
||||||
|
FixedExposure = false;
|
||||||
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
namerawimage = "/sdcard/img_tmp/raw.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +98,11 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
_saturation = stoi(zerlegt[1]);
|
_saturation = stoi(zerlegt[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((toUpper(zerlegt[0]) == "FIXEDEXPOSURE") && (zerlegt.size() > 1))
|
||||||
|
{
|
||||||
|
if (toUpper(zerlegt[1]) == "TRUE")
|
||||||
|
FixedExposure = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera.SetBrightnessContrastSaturation(_brightness, _contrast, _saturation);
|
Camera.SetBrightnessContrastSaturation(_brightness, _contrast, _saturation);
|
||||||
@@ -107,6 +113,18 @@ bool ClassFlowMakeImage::ReadParameter(FILE* pfile, string& aktparamgraph)
|
|||||||
rawImage = new CImageBasis();
|
rawImage = new CImageBasis();
|
||||||
rawImage->CreateEmptyImage(image_width, image_height, 3);
|
rawImage->CreateEmptyImage(image_width, image_height, 3);
|
||||||
|
|
||||||
|
waitbeforepicture_store = waitbeforepicture;
|
||||||
|
if (FixedExposure)
|
||||||
|
{
|
||||||
|
printf("Fixed Exposure enabled!\n");
|
||||||
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
Camera.EnableAutoExposure(flashdauer);
|
||||||
|
waitbeforepicture = 0.2;
|
||||||
|
// flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
// takePictureWithFlash(flashdauer);
|
||||||
|
// rawImage->SaveToFile("/sdcard/init2.jpg");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +139,7 @@ bool ClassFlowMakeImage::doFlow(string zwtime)
|
|||||||
{
|
{
|
||||||
string logPath = CreateLogFolder(zwtime);
|
string logPath = CreateLogFolder(zwtime);
|
||||||
|
|
||||||
int flashdauer = (int) waitbeforepicture * 1000;
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash");
|
LogFile.WriteHeapInfo("ClassFlowMakeImage::doFlow - Before takePictureWithFlash");
|
||||||
@@ -146,7 +164,7 @@ bool ClassFlowMakeImage::doFlow(string zwtime)
|
|||||||
|
|
||||||
esp_err_t ClassFlowMakeImage::SendRawJPG(httpd_req_t *req)
|
esp_err_t ClassFlowMakeImage::SendRawJPG(httpd_req_t *req)
|
||||||
{
|
{
|
||||||
int flashdauer = (int) waitbeforepicture * 1000;
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
return Camera.CaptureToHTTP(req, flashdauer);
|
return Camera.CaptureToHTTP(req, flashdauer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +173,7 @@ ImageData* ClassFlowMakeImage::SendRawImage()
|
|||||||
{
|
{
|
||||||
CImageBasis *zw = new CImageBasis(rawImage);
|
CImageBasis *zw = new CImageBasis(rawImage);
|
||||||
ImageData *id;
|
ImageData *id;
|
||||||
int flashdauer = (int) waitbeforepicture * 1000;
|
int flashdauer = (int) (waitbeforepicture * 1000);
|
||||||
Camera.CaptureToBasisImage(zw, flashdauer);
|
Camera.CaptureToBasisImage(zw, flashdauer);
|
||||||
id = zw->writeToMemoryAsJPG();
|
id = zw->writeToMemoryAsJPG();
|
||||||
delete zw;
|
delete zw;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class ClassFlowMakeImage :
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float waitbeforepicture;
|
float waitbeforepicture;
|
||||||
|
float waitbeforepicture_store;
|
||||||
framesize_t ImageSize;
|
framesize_t ImageSize;
|
||||||
bool isImageSize;
|
bool isImageSize;
|
||||||
int ImageQuality;
|
int ImageQuality;
|
||||||
@@ -22,6 +23,8 @@ protected:
|
|||||||
string namerawimage;
|
string namerawimage;
|
||||||
int image_height, image_width;
|
int image_height, image_width;
|
||||||
bool SaveAllFiles;
|
bool SaveAllFiles;
|
||||||
|
bool FixedExposure;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CopyFile(string input, string output);
|
void CopyFile(string input, string output);
|
||||||
@@ -29,6 +32,7 @@ protected:
|
|||||||
esp_err_t camera_capture();
|
esp_err_t camera_capture();
|
||||||
void takePictureWithFlash(int flashdauer);
|
void takePictureWithFlash(int flashdauer);
|
||||||
|
|
||||||
|
|
||||||
void SetInitialParameter(void);
|
void SetInitialParameter(void);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ esp_err_t handler_editflow(httpd_req_t *req)
|
|||||||
|
|
||||||
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
// printf("Parameter host: "); printf(_host.c_str()); printf("\n");
|
||||||
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
// string zwzw = "Do " + _task + " start\n"; printf(zwzw.c_str());
|
||||||
Camera.SetBrightnessContrastSaturation(bri, con, sat);
|
bool changed = Camera.SetBrightnessContrastSaturation(bri, con, sat);
|
||||||
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
std::string zw = tfliteflow.doSingleStep("[MakeImage]", _host);
|
||||||
httpd_resp_sendstr_chunk(req, zw.c_str());
|
httpd_resp_sendstr_chunk(req, zw.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ esp_err_t hello_main_handler(httpd_req_t *req)
|
|||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* Respond with an empty chunk to signal HTTP response completion */
|
/* Respond with an empty chunk to signal HTTP response completion */
|
||||||
|
// httpd_resp_sendstr(req, "");
|
||||||
httpd_resp_send_chunk(req, NULL, 0);
|
httpd_resp_send_chunk(req, NULL, 0);
|
||||||
|
|
||||||
#ifdef DEBUG_DETAIL_ON
|
#ifdef DEBUG_DETAIL_ON
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const char* GIT_REV="8720211";
|
const char* GIT_REV="9dbad05";
|
||||||
const char* GIT_TAG="";
|
const char* GIT_TAG="";
|
||||||
const char* GIT_BRANCH="rolling";
|
const char* GIT_BRANCH="rolling-camera-speedup";
|
||||||
const char* BUILD_TIME="2021-02-03 21:16";
|
const char* BUILD_TIME="2021-02-21 21:40";
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
const char* GIT_REV="8720211";
|
const char* GIT_REV="9dbad05";
|
||||||
const char* GIT_TAG="";
|
const char* GIT_TAG="";
|
||||||
const char* GIT_BRANCH="rolling";
|
const char* GIT_BRANCH="rolling-camera-speedup";
|
||||||
const char* BUILD_TIME="2021-02-03 21:16";
|
const char* BUILD_TIME="2021-02-21 21:40";
|
||||||
Binary file not shown.
Binary file not shown.
@@ -16,7 +16,7 @@ AlignmentAlgo = Default
|
|||||||
|
|
||||||
|
|
||||||
[Digits]
|
[Digits]
|
||||||
Model = /config/dig0721s1.tflite
|
Model = /config/dig0811s1.tflite
|
||||||
;LogImageLocation = /log/digit
|
;LogImageLocation = /log/digit
|
||||||
;LogfileRetentionInDays = 3
|
;LogfileRetentionInDays = 3
|
||||||
ModelInputSize = 20 32
|
ModelInputSize = 20 32
|
||||||
|
|||||||
BIN
sd-card/config/dig0810s3.tflite
Normal file
BIN
sd-card/config/dig0810s3.tflite
Normal file
Binary file not shown.
BIN
sd-card/config/dig0811s1.tflite
Normal file
BIN
sd-card/config/dig0811s1.tflite
Normal file
Binary file not shown.
Reference in New Issue
Block a user