\section{Background and Related Works}
\label{sec:bk_related}

\subsection{Panasonic Grid-EYE Thermal Sensor}
First, we study the sensor Panasonic Grid-EYE which is a thermal camera that can output $8 \times 8$ pixels thermal data with $2.5^\circ C$ accuracy and $0.25^\circ C$ resolution at $10$ frames per second. In normal mode, the current consumption is 4.5mA. It is a low resolution camera and infrared array sensor, so we install it in our house at ease without some privacy issue that may cause by a surveillance camera. 

When someone walks under a Grid-EYE sensor, we will see some pixels with higher temperature than others. Figure~\ref{fig:GridEye} shows an example of thermal from Grid-EYE sensor. The sensor signal will form a signal cone. The pixel sampling our head temperature will have the highest reading, body is lower, and leg is the lowest except background because when the distance from camera to our body is longer, the area covered by the camera will be wider and the ratio of background temperature in the pixel will increase, also our head does not cover by cloth, so the surface temperature will higher than other place. While we are walking in an area, the temperature of air in the area will become warmer, and the shape of human will be more difficult to recognize.

\begin{figure}[htbp]
	\centering
 	\includegraphics[width=\columnwidth]{figures/GridEye.pdf}
	\caption{Walking under a Grid-EYE sensor}
	\label{fig:GridEye}
\end{figure} 

Figure~\ref{fig:GridEyeData} shows an example output of Grid-EYE sensor.

\begin{figure}[htbp]
	\centering
 	\includegraphics[width=\columnwidth]{figures/GridEYEData.pdf}
	\caption{Output Data from Grid-EYE}
	\label{fig:GridEyeData}
\end{figure} 

\subsection{FLIR ONE PRO}

FLIR ONE PRO is a thermal camera that can output $480 \times 640$ pixels thermal data with $3^\circ C$ accuracy and $0.01^\circ C$ resolution, and capture speed is about 5 frames per second. In picture taking mode, it can retrieve the precise data from the header of picture file. However, in the video taking mode, it only store a gray scale video and show the range of temperature on the monitor. Hence, we use the data from picture taking mode as our test object. The data form FLIR ONE PRO has about $5000$ times resolution compared to Grid-EYE. The shape of object is not just a cone. The temperature in a same object is similar, but an Obvious edge between different objects. Hence, we developed a method to compress the thermal data from FLIR PRO ONE. It can also treat as a normal image and be stored as jpeg, png, etc.

\subsection{Raspberry Pi 3}

We use Raspberry Pi 3 as our testing environment. It has a 1.2 GHz 64-bit quad-core ARM Cortex-A53 CPU, 1 GB memory, and 802.11n wireless network. We run a Debian-based Linux operating system on it. While it is idle and turning off WiFi, it will consume 240mA and while uploading data at 24Mbit/s, it will consume 400mA.

\subsection{Simple Data Compressing}

If we save a frame from Grid-EYE in a readable format, it will take about 380 bytes storage. However, the temperature range of indoor environment mostly from $5^\circ C$ to $40^\circ C$ and the resolution of Grid-EYE is $0.25^\circ C$, so we can easily represent each temperature by one byte. Hence, we only need $64$ bytes to store a frame. We can use different ways to compress the frame.

\subsubsection{Huffman Coding}
Huffman coding is a lossless data compressing. In average, it can reduce the frame size from $64$ bytes to $40.7$ bytes with $6$ bytes standard deviation.

\subsubsection{Z-score Threshold}
We can only send the pixels with higher temperature since thermal sensors are mostly used for detect heat source. Z-score is defined as $z = \frac{\chi - \mu}{\sigma}$ where $\chi$ is the value of the temperature, $\mu$ is the average of the temperature and $\sigma$ is the standard deviation of the temperature. In our earlier work~\cite{Shih17b}, we use Z-score instead of a static threshold to detect human because the background temperature may have a $10^\circ C$ difference between day and night, and when people walk through the sensing area the Grid-EYE, the temperature reading will only increase $2^\circ C$ to $3^\circ C$. Hence, it is impossible to use a static threshold to detect human. In~\cite{Shih17b}, the pixels with useful data only if the Z-score is higher than $2$, so we can reduce the frame size by dropping all pixels with Z-score lower than $2$. We can reduce the file size from $64$ bytes to $12.6$ bytes with $2.9$ bytes standard deviation by Z-score threshold $2$ and compress by Huffman coding.

\subsubsection{Gaussian Function Fitting}
Since the temperature readings of human body in a thermal data from Grid-EYE looks like a signal cone, we may use a Gaussian function to fit the thermal data. A Gaussian function $y = Ae^{-(x-B)^2/2C^2}$ has three parameter $A$, $B$ and $C$. The parameter $A$ is the height of the cone, $B$ is the position of the cone's peak and $C$ controls the width of the cone. We use the pixel with highest temperature to be the peak of the cone, so we only need to adjust $A$ and $C$ to fit the thermal data. Guo~\cite{guo2011simple} provides a fast way to determine the fitting Gaussian function. In our testing, it will have $0.5^\circ C$ root-mean-square error in average, and only needs $5$ bytes to store the position of peak and two parameters.

