Rolling 20211230

This commit is contained in:
jomjol
2021-12-30 11:02:20 +01:00
parent 58a0297915
commit 957138960a
24 changed files with 2204 additions and 134 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -74,7 +74,7 @@ static camera_config_t camera_config = {
//XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental)
// .xclk_freq_hz = 20000000, // Orginalwert
.xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!!
.xclk_freq_hz = 5000000, // Test, um die Bildfehler los zu werden !!!!
.ledc_timer = LEDC_TIMER_0,
.ledc_channel = LEDC_CHANNEL_0,
@@ -86,6 +86,8 @@ static camera_config_t camera_config = {
.jpeg_quality = 5, //0-63 lower number means higher quality
.fb_count = 1 //if more than one, i2s runs in continuous mode. Use only with JPEG
// .grab_mode = CAMERA_GRAB_WHEN_EMPTY,
};
@@ -279,13 +281,23 @@ esp_err_t CCamera::CaptureToBasisImage(CImageBasis *_Image, int delay)
ESP_LOGE(TAGCAMERACLASS, "CaptureToBasisImage: Camera Capture Failed");
LEDOnOff(false);
LightOnOff(false);
doReboot();
LogFile.SwitchOnOff(true);
LogFile.WriteToFile("Camera is not working anymore - most propably hardware problem (instablility, ...). "
"System will reboot.");
doReboot();
return ESP_FAIL;
}
int _size = fb->len;
zwischenspeicher = (uint8_t*) malloc(_size);
if (!zwischenspeicher)
{
ESP_LOGE(TAGCAMERACLASS, "Nicht ausreichend Speicherplatz für Bild in Funktion CaptureToBasisImage()");
LogFile.SwitchOnOff(true);
LogFile.WriteToFile("Nicht ausreichend Speicherplatz für Bild in Funktion CaptureToBasisImage()");
}
for (int i = 0; i < _size; ++i)
*(zwischenspeicher + i) = *(fb->buf + i);
esp_camera_fb_return(fb);

View File

@@ -11,11 +11,48 @@
#include <stdint.h>
#include <stdbool.h>
#define OV9650_PID (0x96)
#define OV7725_PID (0x77)
#define OV2640_PID (0x26)
#define OV3660_PID (0x36)
#define OV5640_PID (0x56)
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
OV9650_PID = 0x96,
OV7725_PID = 0x77,
OV2640_PID = 0x26,
OV3660_PID = 0x3660,
OV5640_PID = 0x5640,
OV7670_PID = 0x76,
NT99141_PID = 0x1410,
GC2145_PID = 0x2145,
GC032A_PID = 0x232a,
GC0308_PID = 0x9b,
} camera_pid_t;
typedef enum {
CAMERA_OV7725,
CAMERA_OV2640,
CAMERA_OV3660,
CAMERA_OV5640,
CAMERA_OV7670,
CAMERA_NT99141,
CAMERA_GC2145,
CAMERA_GC032A,
CAMERA_GC0308,
CAMERA_MODEL_MAX,
CAMERA_NONE,
} camera_model_t;
typedef enum {
OV2640_SCCB_ADDR = 0x30,// 0x60 >> 1
OV5640_SCCB_ADDR = 0x3C,// 0x78 >> 1
OV3660_SCCB_ADDR = 0x3C,// 0x78 >> 1
OV7725_SCCB_ADDR = 0x21,// 0x42 >> 1
OV7670_SCCB_ADDR = 0x21,// 0x42 >> 1
NT99141_SCCB_ADDR = 0x2A,// 0x54 >> 1
GC2145_SCCB_ADDR = 0x3C,// 0x78 >> 1
GC032A_SCCB_ADDR = 0x21,// 0x42 >> 1
GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1
} camera_sccb_addr_t;
typedef enum {
PIXFORMAT_RGB565, // 2BPP/RGB565
@@ -56,6 +93,15 @@ typedef enum {
FRAMESIZE_INVALID
} framesize_t;
typedef struct {
const camera_model_t model;
const char *name;
const camera_sccb_addr_t sccb_addr;
const camera_pid_t pid;
const framesize_t max_size;
const bool support_jpeg;
} camera_sensor_info_t;
typedef enum {
ASPECT_RATIO_4X3,
ASPECT_RATIO_3X2,
@@ -99,11 +145,13 @@ typedef struct {
// Resolution table (in sensor.c)
extern const resolution_info_t resolution[];
// camera sensor table (in sensor.c)
extern const camera_sensor_info_t camera_sensor[];
typedef struct {
uint8_t MIDH;
uint8_t MIDL;
uint8_t PID;
uint16_t PID;
uint8_t VER;
} sensor_id_t;
@@ -188,4 +236,10 @@ typedef struct _sensor {
int (*set_xclk) (sensor_t *sensor, int timer, int xclk);
} sensor_t;
camera_sensor_info_t *esp_camera_sensor_get_info(sensor_id_t *id);
#ifdef __cplusplus
}
#endif
#endif /* __SENSOR_H__ */

View File

@@ -8,8 +8,8 @@
#include "ClassLogFile.h"
#define SCRATCH_BUFSIZE2 8192
char scratch2[SCRATCH_BUFSIZE2];
// #define SCRATCH_BUFSIZE2 8192
// char scratch2[SCRATCH_BUFSIZE2];
//#define DEBUG_DETAIL_ON
static const char *TAGPARTCAMERA = "server_camera";

View File

@@ -30,6 +30,7 @@
#include "server_file.h"
#include "server_GPIO.h"
#include "ClassLogFile.h"
#include "Helper.h"

View File

@@ -135,6 +135,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
std::string result;
std::string resulterror = "";
std::string resultraw = "";
std::string resultrate = "";
std::string resulttimestamp = "";
string zw = "";
@@ -159,6 +160,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
for (int i = 0; i < (*NUMBERS).size(); ++i)
{
result = (*NUMBERS)[i]->ReturnValueNoError;
resultraw = (*NUMBERS)[i]->ReturnRawValue;
resulterror = (*NUMBERS)[i]->ErrorMessageText;
resultrate = (*NUMBERS)[i]->ReturnRateValue;
resulttimestamp = (*NUMBERS)[i]->timeStamp;
@@ -181,12 +183,17 @@ bool ClassFlowMQTT::doFlow(string zwtime)
if (resultrate.length() > 0)
MQTTPublish(zw, resultrate);
zw = namenumber + "raw";
if (resultraw.length() > 0)
MQTTPublish(zw, resultraw);
zw = namenumber + "timestamp";
if (resulttimestamp.length() > 0)
MQTTPublish(zw, resulttimestamp);
std::string json="{\"value\":"+result;
json += ",\"raw\":\""+resultraw;
json += ",\"error\":\""+resulterror;
if (resultrate.length() > 0)
json += "\",\"rate\":"+resultrate;

View File

@@ -1,6 +1,7 @@
#include "CImageBasis.h"
#include "Helper.h"
#include "ClassLogFile.h"
#include "server_ota.h"
#include <esp_log.h>
@@ -337,6 +338,18 @@ void CImageBasis::LoadFromMemory(stbi_uc *_buffer, int len)
rgb_image = stbi_load_from_memory(_buffer, len, &width, &height, &channels, 3);
bpp = channels;
printf("Image loaded from memory: %d, %d, %d\n", width, height, channels);
if ((width * height * channels) == 0)
{
ESP_LOGE(TAG, "Image with size 0 loaded --> reboot to be done! "
"Check that your camera module is working and connected properly.");
LogFile.SwitchOnOff(true);
LogFile.WriteToFile("Image with size 0 loaded --> reboot to be done! "
"Check that your camera module is working and connected properly.");
doReboot();
}
RGBImageRelease();
}

View File

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "."
REQUIRES jomjol_helper jomjol_logfile esp_http_server)
REQUIRES jomjol_helper jomjol_logfile esp_http_server jomjol_fileserver_ota)

View File

@@ -236,14 +236,13 @@ bool CTfLiteClass::LoadModel(std::string _fn){
this->error_reporter = new tflite::MicroErrorReporter;
#endif
unsigned char *rd;
rd = ReadFileToCharArray(_fn.c_str());
modelload = ReadFileToCharArray(_fn.c_str());
if (rd == NULL)
if (modelload == NULL)
return false;
this->model = tflite::GetModel(rd);
free(rd);
model = tflite::GetModel(modelload);
// free(rd);
TFLITE_MINIMAL_CHECK(model != nullptr);
return true;
@@ -266,6 +265,8 @@ CTfLiteClass::~CTfLiteClass()
delete this->tensor_arena;
delete this->interpreter;
delete this->error_reporter;
if (modelload)
free(modelload);
}

View File

@@ -46,6 +46,9 @@ class CTfLiteClass
int kTensorArenaSize;
uint8_t *tensor_arena;
unsigned char *modelload = NULL;
float* input;
int input_i;
int im_height, im_width, im_channel;

View File

@@ -694,7 +694,23 @@ void task_autodoFlow(void *pvParameter)
void TFliteDoAutoStart()
{
xTaskCreate(&task_autodoFlow, "task_autodoFlow", configMINIMAL_STACK_SIZE * 64, NULL, tskIDLE_PRIORITY+1, &xHandletask_autodoFlow);
BaseType_t xReturned;
int _i = configMINIMAL_STACK_SIZE;
printf("task_autodoFlow configMINIMAL_STACK_SIZE: %d\n", _i);
printf("getESPHeapInfo: %s\n", getESPHeapInfo().c_str());
xReturned = xTaskCreate(&task_autodoFlow, "task_autodoFlow", configMINIMAL_STACK_SIZE * 60, NULL, tskIDLE_PRIORITY+1, &xHandletask_autodoFlow);
if( xReturned != pdPASS )
{
//Memory: 64 --> 48 --> 35 --> 25
printf("ERROR task_autodoFlow konnte nicht erzeugt werden !!\r\n");
}
printf("getESPHeapInfo: %s\n", getESPHeapInfo().c_str());
}
std::string GetMQTTMainTopic()