\section{Method name}
\label{sec:design}

\subsection{System Architecture}
We designed a thermal-box to collect the data. It has four Grideye sensors on the
corners of a 10 cm square and a Lepton 3 at the central. Our method is made by
three parts. The first part is to train the SRCNN model with fused Grideye image
as low-resolution and downscaled Lepton 3 image. The second part, we use the
Super-resolution image to train a neural network model to recognize current pose
is lay on back or lay on side. The third part, because of noise and the residual
heat on bed after turn over, it is difficult to figure out the current pose. We
remove the noise by median filter, and determine the current pose according to
the trend of the possibility from recognition network.

\subsection{Grideye Data Fusion}

On the thermal-box, there are four Grideye sensors. At the beginning, we let
the thermal-box faces to an empty bed and records the background temperature.
All the following frames will subtract this background temperature. After that,
we resize four $8 \times 8$ Grideye images to $64 \times 64$ by bilinear
interpolation and than merge them dependence on the distance between thermal-box and
bed, width of sensor square and the FOV of Grideye sensor.

\begin{enumerate}
\item $D_b$ is the distance between bed and thermal-box.
\item $D_s$ is the width of sensor square also the distance between adjacent sensors.
\item $F$ is the FOV of Grideye sensor which is about 60 degree.
\item $Overlap = 64 - 64 \times (\frac{D_s}{2 \times D_b \times tan(\frac{F}{2})})$
\end{enumerate}

\subsection{Pose determination}

We train a SRCNN model by the fused Grideye data and downscaled Lepton 3 image,
and use it to upscale all following frames to SR frames. We labeled some SR frames
to two categories. One is lay on back and the other is lay on side. Since the input
data is very small, we use a neural network consist one 2D convolution layer, one
2D max pooling, one flatten and one densely-connected layer. The possibility of
output has a very large various just after turning over because the model cannot
distinguish the residual heat on bed and the person as Figure~\ref{fig:residual_heat} shown. This
situation will slowly disappear after one or two minutes.

To determination the pose, first we use a median filter with a window size of five
to filter out the noise. Than, find the curve hull line of the upper bound and
lower bound of the data. Finally calculate the middle line of upper bound and lower bound.
Figure~\ref{fig:trend} shows the data and these lines.

We divide every data into 10 second time windows. If the middle line of the time window
is at the top one fifth, it is a lay on back. If it is at the bottom one fifth,
it is a lay on side. If the trend of line is going up, it is lay on back. Otherwise, it
is lay on side. To guarantee the confidence of result, we will only trust the pose if
there are three continuously same output.

\begin{figure}[ht]
  \centering
  \minipage{0.3\columnwidth}
    \includegraphics[width=\linewidth]{figures/Lepton_residual_heat.png}
    \caption{Residual heat on bed.}
    \label{fig:residual_heat}
  \endminipage
  \minipage{0.65\columnwidth}
    \includegraphics[width=\linewidth]{figures/MinMax.pdf}
    \caption{Trend of pose.}
    \label{fig:trend}
  \endminipage
\end{figure}
