# Application of Deep Convolutional Neural Networks and Smartphone Sensors for Indoor Localization
## 3 Materials and Methods
### Data Collection  
The data collection phase involves image capturing as well as magnetic field samples collection. Figure 3 shows the points where the camera images are captured. In addition, the scenes at different collection points are also shown. The images are captured using Samsung Galaxy S8 rear camera for this purpose. It is a 12 mega pixel Dual Pixel, F-1.7 aperture, 1.4-micron pixels optical image stabilization (OSI). Since Smartphone camera utilizes a potential amount of battery, hence camera images are used rather than the video. The images are labeled programmatically. A subroutine is defined wherein we feed the images of a collection point and its label. All images are labeled according to the given label. Since we have used our own model for training and CNN networks require a large amount of data for training purposes, 500 images at each collection point are captured. We use a total of 7500 images for all collection points. Owing to the fact that the user can hold the phone in different directions arbitrarily, the images are captured from slightly different angles. It is important to point out that the images are captured with slightly varying light conditions so that the trained network can predict in different light conditions. Each collection point index along with the floor number is used as its class to make labels, e.g., the first point to the left on floor 3 map will be labeled as \(P310\) for the training purpose. It will serve two purposes: The predicted label is first used to identify the floor the user is currently at, in order to load the respective magnetic fingerprint database. Secondly, it will be used to narrow the search space for the magnetic field based localization. The training requires a large amount of time depending on the volume of data used. We performed the training using Nvidia Titan X on an Intel i7 machine running with 16.0 GB random access memory. It takes approximately 3 to 4 h to finish the training process with the collected images.  
The magnetic fingerprint database is also built during the data collection phase. Magnetic data is collected at specific points separated by a distance of 1 m. Magnetic samples are collected using Samsung Galaxy S8 and 100 samples are collected at each point. Later the collected data is normalized and spline interpolation is used to generate the intermediate values. We make the magnetic fingerprint database of the patterns formed by the magnetic values. As already pointed out that the magnetic value can be very different for different devices, so it is not possible to make one magnetic fingerprint database which can be used for various devices. However, research [8; 37] pointed out as well as our experiments reveal that the patterns formed from magnetic values are very similar, so we use magnetic patterns instead of magnetic values. Figure 4 shows the magnetic data collection process to prepare the fingerprint database. The magnetic values are transformed into magnetic patterns using the algorithm proposed in [38]. For more details, readers are referred to [38].  
Figure 2: Convolutional neural network for scene recognition.