# Edge Computing Based on Federated Learning for Machine Monitoring
## 3 System Design for Edge Computing in IoT
### Scene Change Detection in End Devices  
In traditional vision technology, feature extraction and matching methods are used for object recognition. By using deep learning computing technology, the accuracy of image analysis is greatly improved. Relatively, large storage space and computing time are required in the end device such that it is almost impossible for real applications. Sending raw data back to the cloud server for processing can provide powerful computing power but introduce privacy issues. The various components in the IoT work separately and cooperatively to solve real problems. The end device in the proposed IoT was designed by using the common products on the market. The Terasic DE2-115 platform is equipped with an array camera as the end device of the IoT. Each camera is responsible for capturing images of a part of the PLC screen. Figure 6 shows the array camera of the end device and its corresponding captured image region of the PLC screen.  
\[MSE\mathbf{=\frac{1}{mm}\sum_{i=0}^{m-1n-1}\sum_{j=0}^{1}[I(i,j)-K(i,j)]^{2}} \tag{1}\]  
where \(m\) and \(n\) represent the width and height of the image, respectively, and \(I\) and \(K\) are the corresponding images. MSE calculates the average of difference between two corresponding pixels. The calculated value indicates the similarity between two images, the smaller the value, the more similar the two images are. It is simple and fast, but has a serious problem that a large difference in pixel values does not necessarily mean a large difference in image content. For example, the images of exactly the same scene under different lighting conditions may result in large MSE values instead of 0. Therefore, the region of interest (ROI) for calculating MSE is a small sliding window with a size of sxs, and threshold T1 is used as the first test. If MSE is smaller than T1, the end device does nothing and keeps watching. Otherwise, it follows the second test by Equation (2), the Structural Similarity Index Measurement (SSIM) [28]. SSIM is an indicator that can be used to measure the similarity between two digital images. There are strong correlations between adjacent pixels in natural images, and such correlations reveal the structural information of objects in the scene. It is more suitable to judge the image quality and detect scene changes such asthe human eye in the monitoring process\"  
\[SSIM(x,y)\mathbf{=\frac{(2\mu_{x}\mu_{y}+c_{1})(2\sigma_{xy}+c_{2})}{(\mu_{x}^{ 2}+\mu_{y}^{2}+c_{1})(\sigma_{x}^{2}+\sigma_{y}^{2}+c_{2})}} \tag{2}\]  
where \(x\) and \(y\) are two testing images; \(\mu_{x}\) and \(\mu_{y}\) are their means; \(\sigma_{x}\) and \(\sigma_{y}\) are their variances; \(\sigma_{xy}\) is the covariance. \(c_{1}\) and \(c_{2}\) are constants. \(SSIM\) ranges from 0 to 1. The larger the value of the \(SSIM\), the higher the similarity between the two images. When the two images being measured are exactly the same, the value of the SSIM is 1. The limitation of SSIM is that it cannot work effectively in the case of image displacement, scaling, and rotation, which are non-structural distortions. These are not the situations we are going to study in this paper, because each end device will be fixed in right position in the factory.