add edge finding process for testing

This commit is contained in:
Yunhorn 2023-08-18 17:52:11 +08:00
parent 67a78520c6
commit d960e1e0fe
1 changed files with 37 additions and 16 deletions

View File

@ -19,7 +19,7 @@
paramsMLX90640 mlx90640; paramsMLX90640 mlx90640;
static uint16_t eeMLX90640[832]; static uint16_t eeMLX90640[832];
int status; int status;
volatile uint8_t draw_legend_once=0, normalPeopleTemp=30, blackOutTag=0, waterTempThreshold=8, detectCycle=0, v_water_cnt=0,h_water_cnt=0; volatile uint8_t draw_legend_once=0, normalPeopleTemp=32, blackOutTag=0, waterTempThreshold=8, normalWaterTemp=25, detectCycle=0, v_water_cnt=0,h_water_cnt=0;
// start with some initial colors // start with some initial colors
float minTemp = 1.0f; float minTemp = 1.0f;
float maxTemp = 60.0f; float maxTemp = 60.0f;
@ -37,7 +37,7 @@ int x, y, i, j;
// array for the 32 x 24 measured tempValues // array for the 32 x 24 measured tempValues
static float tempValues[32*24]; static float tempValues[32*24];
volatile uint8_t zoneMask[32*24]={0x0}; volatile uint8_t zoneMask[32*24]={0x0}, edgeMask[32*24]={0x0};
void blackOutFilter(void); void blackOutFilter(void);
static uint16_t TempToColor(float val); static uint16_t TempToColor(float val);
@ -192,8 +192,9 @@ static void drawPicture(void)
// start from 2, ignore edge of FOV // start from 2, ignore edge of FOV
for (y=2; y<23; y++) for (y=2; y<23; y++)
{ {
BSP_LCD_FillRect(0, y*11+16, ST7789V_LCD_PIXEL_WIDTH, 4, LCD_COLOR_BLACK); BSP_LCD_FillRect(0, y*11+16, ST7789V_LCD_PIXEL_WIDTH, 4, LCD_COLOR_BLACK);
for (x=2; x<31; x++) // Start from 2, ignore edge of FOV for (x=1; x<31; x++) // Start from 2, ignore edge of FOV
{ {
if (zoneMask[y*32+x] > 3) { if (zoneMask[y*32+x] > 3) {
@ -201,7 +202,9 @@ static void drawPicture(void)
BSP_LCD_FillRect(x*8, y*11+16, 4, 4, LCD_COLOR_GREEN); BSP_LCD_FillRect(x*8, y*11+16, 4, 4, LCD_COLOR_GREEN);
h_cnt[x] =1; h_cnt[x] =1;
v_cnt[y] =1; v_cnt[y] =1;
} } else if (edgeMask[y*32+x] > 3) {
BSP_LCD_FillRect(x*8, y*11+16, 2, 2, LCD_COLOR_GRAY);
} else BSP_LCD_FillRect(x*8, y*11+16, 2, 2, LCD_COLOR_BLACK);
} }
} }
// simple count of water spill point cloud // simple count of water spill point cloud
@ -258,11 +261,16 @@ static void readTempValues(void)
} }
void blackOutFilter(void) void blackOutFilter(void)
{ {
float temp1=0.0; float temp1=0.0, temph1=0.0, tempv1=0.0;
if (maxTemp < normalPeopleTemp) if (maxTemp < normalPeopleTemp)
{ {
blackOutTag =0; blackOutTag =0;
} else
{
blackOutTag =1;
}
// ignore edge of FOV // ignore edge of FOV
waterSpillCount =0; waterSpillCount =0;
for (y=2; y<22; y++) for (y=2; y<22; y++)
@ -270,19 +278,31 @@ void blackOutFilter(void)
for (x=2; x<30; x++) for (x=2; x<30; x++)
{ {
temp1 = (float)tempValues[(x) + (y*32)]; temp1 = (float)tempValues[(x) + (y*32)];
if ((temp1 + (float)(waterTempThreshold/10.0)) < averageTemp ) temph1 = (float)tempValues[(x) + (y-1)*32];
tempv1 = (float)tempValues[(x) + (y+1)*32];
//simple edge finding --begin
//if (((fabs(temp1 - temph1)> 0.3)) && (fabs(temp1 - tempv1)> 0.3))
if (((temp1 - temph1)> 0.2) && ((temp1 - tempv1)> 0.2))
//if (((temp1 > temph1)) && ((temp1 > tempv1)))
{ // vertical find and horizontal find
edgeMask[x+y*32]++;
} else {
//edgeMask[x+y*32] = 0;
}
//simple edge finding --end
if ((temp1 + (float)(waterTempThreshold / 10.0)) < max(averageTemp, normalWaterTemp))
{ {
if (blackOutTag == 0) {
zoneMask[y*32+x] ++; zoneMask[y*32+x] ++;
waterSpillCount ++; waterSpillCount ++;
} }
} }
} }
blackOutTag =0;
} else
{
blackOutTag =1;
} }
if (detectCycle ++ > 20) if (detectCycle ++ > 20)
@ -290,6 +310,7 @@ void blackOutFilter(void)
detectCycle = 0; detectCycle = 0;
memset((void *)zoneMask,0,sizeof(zoneMask)); memset((void *)zoneMask,0,sizeof(zoneMask));
memset((void *)edgeMask, 0, sizeof(edgeMask));
} }
} }