EMBER 0.1
EMBER is a fire suppression system with a thermal IR camera for hot blob detection on a pan/tilt mechanism with a solenoid for commanded water flow.
Loading...
Searching...
No Matches
task_read_camera.cpp File Reference

Thermal camera reading and hot blob detection task. More...

#include "PrintStream.h"
#include "task_read_camera.h"
#include <Arduino.h>
#include <Wire.h>
#include "shares.h"
#include "task_webserver.h"
#include "adafruit_mlx90640.h"

Macros

#define HOTBLOB_DETECT_THRESHOLD   50.0f
#define HOTBLOB_INCLUSION_THRESHOLD   49.0f
#define FIRE_ALERT_THRESHOLD   70.0f
#define FIRE_COOLDOWN_THRESHOLD   60.0f
#define NUM_PIXELS   768

Functions

void findHotBlob (const float *frame, uint16_t seedIdx, float tempThreshold, uint16_t &outCentroidIdx, float &outMaxTemp, float &outAvgTemp, uint16_t &outSize, float &outCentroidX, float &outCentroidY)
 function which finds the centroid of a hot blob in a thermal frame
void task_read_camera (void *p_params)
 task which reads the MLX90640 thermal camera and detects hotspots

Variables

Adafruit_MLX90640 mlx

Detailed Description

Thermal camera reading and hot blob detection task.

Author
Jackson Cordova, GPT5-mini
Date
November 2025

Function Documentation

◆ findHotBlob()

void findHotBlob ( const float * frame,
uint16_t seedIdx,
float tempThreshold,
uint16_t & outCentroidIdx,
float & outMaxTemp,
float & outAvgTemp,
uint16_t & outSize,
float & outCentroidX,
float & outCentroidY )

function which finds the centroid of a hot blob in a thermal frame

this functions performs a breadth-first search (BFS) starting from a seed pixel to find all connected pixels above a temperature threshold, effectively identifying a "blob" of hot pixels. It computes the weighted centroid of the blob based on pixel temperatures, as well as the maximum temperature, average temperature, and size of the blob.

Parameters
framepointer to the thermal frame array (size 768)
seedIdxindex of the seed pixel to start the search from
tempThresholdtemperature threshold for including pixels in the blob
outCentroidIdxreference to store the index of the computed centroid pixel
outMaxTempreference to store the maximum temperature found in the blob
outAvgTempreference to store the average temperature of the blob
outSizereference to store the size (number of pixels) of the blob
outCentroidXreference to store the X coordinate of the centroid
outCentroidYreference to store the Y coordinate of the centroid

◆ task_read_camera()

void task_read_camera ( void * p_params)

task which reads the MLX90640 thermal camera and detects hotspots

This task continuously reads frames from the MLX90640 thermal camera at a set refresh rate. It processes each frame to find the hottest pixel and then identifies a connected "hot blob" of pixels around it that exceed a defined temperature threshold. The task computes the centroid of the hot blob and applies temporal smoothing to reduce jitter in the detected position. If the maximum temperature of the blob exceeds a fire alert threshold, it sets a shared boolean "fire" to true. The task runs indefinitely with no delay, relying on the camera's refresh rate for timing.

Parameters
p_paramsnot used and should be set to void in the xTaskCreate call