From d960e1e0feb75ca796f09dc625d6b28237e23160 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Fri, 18 Aug 2023 17:52:11 +0800 Subject: [PATCH] add edge finding process for testing --- mlx90640/mlx90640_lcd_display.c | 53 +++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/mlx90640/mlx90640_lcd_display.c b/mlx90640/mlx90640_lcd_display.c index 6abf345..38479f3 100644 --- a/mlx90640/mlx90640_lcd_display.c +++ b/mlx90640/mlx90640_lcd_display.c @@ -19,7 +19,7 @@ paramsMLX90640 mlx90640; static uint16_t eeMLX90640[832]; 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 float minTemp = 1.0f; float maxTemp = 60.0f; @@ -37,7 +37,7 @@ int x, y, i, j; // array for the 32 x 24 measured tempValues 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); static uint16_t TempToColor(float val); @@ -192,8 +192,9 @@ static void drawPicture(void) // start from 2, ignore edge of FOV for (y=2; y<23; y++) { + 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) { @@ -201,7 +202,9 @@ static void drawPicture(void) BSP_LCD_FillRect(x*8, y*11+16, 4, 4, LCD_COLOR_GREEN); h_cnt[x] =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 @@ -258,38 +261,56 @@ static void readTempValues(void) } void blackOutFilter(void) { - float temp1=0.0; + float temp1=0.0, temph1=0.0, tempv1=0.0; if (maxTemp < normalPeopleTemp) { blackOutTag =0; + } else + { + blackOutTag =1; + } + // ignore edge of FOV waterSpillCount =0; for (y=2; y<22; y++) { for (x=2; x<30; x++) { - temp1 = (float)tempValues[(x) + (y*32)]; - if ((temp1 + (float)(waterTempThreshold/10.0)) < averageTemp ) + temp1 = (float)tempValues[(x) + (y*32)]; + 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)) { - zoneMask[y*32+x] ++; - waterSpillCount ++; + if (blackOutTag == 0) { + + zoneMask[y*32+x] ++; + waterSpillCount ++; + } } } } - blackOutTag =0; - - } else - { - blackOutTag =1; - } - if (detectCycle ++ > 20) { detectCycle = 0; memset((void *)zoneMask,0,sizeof(zoneMask)); + memset((void *)edgeMask, 0, sizeof(edgeMask)); } }