# TwSense: Highly Robust Through-the-Wall Human Detection Method Based on COTS Wi-Fi Device
## 4 System Architecture
### G-Svm  
Completing person presence detection requires the use of support vector machines (SVM) to classify the presence and absence of persons. SVM is a very typical binary classification algorithm. However, to avoid the occurrence of overlearning and under learning in classification, this paper used the G-SVM algorithm to optimize the penalty factor \(C\) and the kernel parameter \(g\) by using the grid search algorithm [21]. The penalty factor \(C\) and the kernel parameter \(g\) in the SVM algorithm were divided into a grid in a given range, and the values of all grid nodes were traversed. Then, the point with the highest classification accuracy was selected. The penalty factor \(C\) and the kernel parameter \(g\) corresponding to that point were optimal, thus improving the classification accuracy. There are two main types of personnel status: no presence and occupied. Actions with occupants were divided into four groups, and people with no presence were divided into one group. When people exist, 150 data groups were collected for each action, and 600 groups of four kinds of action exist. We collected 600 datasets without the presence of anyone. The process of G-SVM training for classification was as shown in Figure 7:  
We sequentially acquired RGB images from the Step 1 dataset to extract features at Step 2 (using the HOG algorithm). We divided the data into two categories, training set and test set, from which 80% of the data samples were selected as training samples and 20% as test samples. The final feature vector was formed by combining the HOG descriptors of all the blocks in the detection window, and then fed to the G-SVM classifier as input features. Based on the characteristics of the input images, labels continued to be assigned to each corresponding image at step 3 (a label of 1 corresponds to an image where a person is present; a label of 0 corresponds to an image where no person is present). Then, at step 4, based on the G-SVM algorithm, these were used to train on the Matlab tool, thereby obtaining hyperplanes for classification. The training sample set was \((A_{i},B_{i})(i=1,2,\cdot\cdot\cdot,k)\), where \(A_{i}\) is the input variable, \(B_{i}\) is the corresponding expected value, and \(k\) is the number of samples. In this paper, the Gaussian kernel function was used to map the linear inseparable data in the low-dimensional input space to the high-dimensional feature space to make it linearly separable. The optimal separation hyperplane was constructed in the high-dimensional feature space to distinguish the state of the human, and then determine whether there was a person in the room. In order to find the optimal separating hyperplane that separate the two states, occupied and unoccupied, we needed to solve the following constrained minimization problem to find the optimal parameter for classification to distinguish these two types of data:  
\[\text{min}P=\frac{1}{2}\|\omega\|^{2}+C\sum_{i}^{n}\left(\xi_{i}+\xi_{i}{}^{*}\right) \tag{16}\]  
where \(\omega\) is the direction vector separating the hyperplane, \(P\) is the optimization objective, \(C\) is the penalty factor, and \(\xi_{i}\) and \(\xi_{i}{}^{*}\) are the relaxation coefficients. The linear regression function was obtained using the Lalangrangian function and then computed using the Gaussian kernel function for the solution:  
\[f(x)=\sum_{i}^{n}\left(\alpha_{i}+\alpha_{i}{}^{*}\right)G(A_{i},B_{i})+b \tag{17}\]  
Figure 7: Diagram of searching hyperplane for classification on MATLAB tool. \[G(A_{i},B_{i})=\exp\Bigl{\{}-g\|A_{i}-B_{i}\|^{2}\Bigr{\}} \tag{18}\]  
where \(\alpha_{i}\) and \({\alpha_{i}}^{*}\) are the Lagrange factor, \(G(A_{i},B_{i})\) is the kernel function, and \(g\) is the kernel parameter, if \(f(x)>0\), then \(A_{i}\) corresponds to the person action data. The whole process of using the grid search algorithm to improve the SVM classifier is shown in Algorithm 1.