Industrial Internet of Things for Mobile Phone Shell Intelligent Detection in Smart Cities

Industrial Internet of Things is the core ﬁ eld of smart city. And intelligent detection is an important application ﬁ eld of industrial Internet of Things. Demand of the industrial is particularly urgent. In particular, the defect detection of mobile phone shells (MPS) has always been a common problem for famous mobile phone companies. A compression-free defect detection method (CFDDM) for MPS based on machine vision is proposed in this paper. Firstly, a ﬃ ne transformation is utilized to solve the angle deviation of MPS in di ﬀ erent images. Then, edge detection, binarization, and open operation are combined to highlight the edge region based on the results of angle adjustment. It is convenient for region of interest (ROI) extraction and clipping. Finally, the method of gray histogram contrasting is utilized for defect detection according to the results of ROI clipping. And the detection results are obtained. In this paper, MPS data set is utilized for many tests. The results show that the proposed method can e ﬀ ectively detect whether there are defects in MPS data set without image compression. The recognition accuracy is 100%. The recognition time of a single image is about 4.56s, which is better than other defect detection methods.


Introduction
The core goal of the construction of industrial Internet of Things is to build an industry wide economic operation monitoring system for the smart cities [1]. It can be monitored, quantified, predictable, and intelligent decisionmaking. Intelligent detection is the core application field of industrial Internet of Things. It is not only the core content of intelligent transformation of industrial production line, but also the related detection algorithm is widely utilized in many aspects of smart city, such as logistics management and commercial application.
As an indispensable component of smart phones, the mobile phone shell (MPS) plays a role in protecting the internal components of mobile phones, such as circuit boards and batteries. In addition, the functions of beautifying mobile phones and highlighting features are more popular with consumers. Therefore, the detection of MPS in industrial field is becoming more important. Most of the traditional detection methods of MPS are manual defect detection. The average time of defect detection manually is 15 s [2]. At the same time, the accuracy of manual detection depends on the detection experience and proficiency. It increases the risk of false detection. A method that is standardized, time-saving, and accurate detection is pursued by researchers based on such problems.
A compression-free defect detection method (CFDDM) is proposed in this paper for saving above problems. Firstly, the angle of MPS in the image is adjusted by affine transformation, so that MPS of each sample image is perpendicular to horizontal line. Then, the sample image is grayed. And the gradient image is obtained by Sobel operator. A low-pass filter [3] for filtering denoising is utilized in this paper to eliminate the influence of noise. Then, the image is binarized and processed by the open operation [4]. The purpose of this step is to highlight the outline of the MPS as much as possible. Then, the detect ROI of MPS is processed by OpenCV. Finally, ROI is cut to get MPS image without background. The gray histogram of each region of interest (ROI) image is extracted as features in the feature extraction part [5]. Firstly, a gray histogram is extracted that belongs to ROI of defect-free sample and ROI of the sample to be tested. Then, the system obtains the detection results by comparing the two gray histograms in the decision-making part.
The rest of this paper is structured as follows. In Section 2, the related work of industrial inspection method and system based on machine vision is reviewed. Section 3 describes the defect detection method of MPS image without compression. Section 4 gives the results of experiment and inspection. In addition, the results of various defect detection methods are compared in Section 4. Finally, the conclusion of the detection system is given in Section 5.

Related Work
The detection method of MPS began to receive more attention by researchers as an indispensable key part of smart phones. Defect detection systems have been widely utilized in the field of manufacturing with breakthrough and innovation in the field of industrial machine vision [6]. It was based on machine vision for industrial products.
2.1. Feature-Based Defect Detection System. Wang et al. [7] proposed a product defect detection system to extract ROI and an inverted residual cascade network to extract features. It was based on Hough Transform (HT). In this system, HT is utilized to extract ROI of the product under the cooperation of a fixed-point rectangular light source. It greatly reduces the problem of too long detection time caused by calculating unrelated background by computer. Aminzadeh and Kurfess [8] proposed a new feature extraction method. The histogram of background and defect regions are compared to find an optimal threshold. Then, the optimal threshold is utilized for threshold segmentation. After that, feature points or regions are extracted from the binary images after threshold segmentation. Finally, a machine learning or deep learning model is established according to the extracted features to obtain the detection results.

Defect Detection System
Based on Template Matching. The defect detection system based on template matching can usually get the difference between the template image and the image to be tested [9]. Then, the system makes a judgment whether there are defects in the image to be tested [10]. This method has many advantages, such as high efficiency and low error. It played an important role in the field of industrial detection and industrial identification [11]. Jian et al. [12] proposed a mobile phone screen defect detection method. It combines contour-based image registration, image subtraction, and gradient projection. At the same time, an improved fuzzy c-means clustering (IFCM) was proposed for defect classification. Tsai and Hsieh [13] proposed a new template registration method. Firstly, the expected maximum algorithm is utilized to assign weight values to each edge point of the image and the template to be tested. Then, the edge points corresponding to the weight are found in the image to be mea-sured and template. Finally, the alignment between the image to be tested and the template is realized.

Defect Detection System Based on Deep Learning Neural
Network. The defect detection system based on deep learning neural network is quite different from that based on machine learning. The defect detection system based on deep learning needs to be inputted a large number of data sets to improve recognition accuracy. Improvement of accuracy is by self-learning of neural network. Zhang et al. [14] proposed a classifier for defect image detection based on CNN. Ho et al. [15] proposed an automatic optical inspection system based on CNN. It is utilized to detect five kinds of defects in mold manufacturing process. Jisu et al. [16] proposed a weighted multi-DLNN neural network for glass defect detection and classification. It is based on DLNN neural network. The new neural network proposed can utilize multichannel data to achieve high accuracy effectively.
However, the defect detection method based on deep learning has serious shortcomings. The accuracy and practicability of network depend on the quantity and quality of training samples heavily [17]. Moreover, the acquisition of data sets is one of the problems for researchers. In this paper, CFDDM for MPS image based on machine vision is proposed. It can achieve 100% recognition accuracy without a large number of data training and image compression.

Detect Defection Method for MPS
CFDDM proposed in this paper consists of five parts: image acquisition, image preprocessing, ROI extraction, image feature extraction, and defect recognition.
3.1. Image Acquisition. Core of CFDDM proposed in this paper includes image acquisition and image processing.
The light source of this experiment is a strip light source that is composed of a high-density LED array. It is suitable for surface size detection and edge defect detection [18]. Therefore, this experiment utilizes a strip light source.
In this experiment, an 8 K industrial camera is utilized in this experiment. The resolution of MPS captured by the 8 K industrial camera is 8192 * 8000. The experimental platform of image acquisition is shown in Figure 1. It needs to place the samples on the platform before image acquisition. Then, strip light source is turned on to reduce the interference of ambient light. It can capture clearer MPS images. The pulley under the platform can be regarded as the y-axis of the platform. Moving the pulley back and forth until MPS appears in the field of vision of the 8 K industrial camera. The camera also moves with the frame in z-axis direction to ensure focus correctly. The captured image is a gray image with a resolution of 8192 * 8000 and BMP format.
The specific models of the camera, lens, and light source are shown in Tables where δ denotes the standard deviation. x and y denote the coordinates of pixels in image. Gaussian low-pass filter is utilized for digital image processing in this paper. Therefore, two-dimensional information should be processed by computer. Two-dimensional transfer function is utilized in the paper.

Image
Graying. Data set in this experiment contains three channel images. Graying is utilized to reduce the number of channels in order to reduce the amount of image computation [19]. The optional graying methods are as follows: maximum value method, average value method, and weighted average method. The principles of the three methods are different. The calculation equations are as follows: where Rði, jÞ denotes the pixel value of the R channel at the position of the pixel ði, jÞ. Gði, jÞ denotes the pixel value of the G channel at the image ði, jÞ position. Bði, jÞ denotes the pixel value of channel B at the image ði, jÞ position.

ROI Extraction.
There are not only ROIs but also a large area of useless background area in the images that taken by industrial cameras [20]. These regions not only increase the detection time of the defect detection system but also interfere with the recognition results. The following image processing method is utilized in this paper to get ROI to reduce interference.

Affine Transformation.
Affine transformation is utilized to adjust ROI angle of MPS [21]. Therefore, ROI is perpendicular to horizontal line. MPS before affine transformation is shown in Figure 3(a), and the processed image is shown in Figure 3(b). Affine transformation is suitable for image translation, rotation, scaling, and mirror operation. The rotation operation of affine transformation is utilized mainly in this paper. The matrix form of the operation is as follows: where x, y denotes coordinates of the pixel before transformation. x′, y′ denotes coordinates of the pixel after affine transformation. θ denotes the angle of image rotation. t x , t y denotes the translation amount of pixels.
3.3.2. Calculate Gradient of the Image. ROI was extracted in this experiment. Features of the image in ROI can be reflected well by gradient of the image.
Sobel operator is a first derivative discrete differential operator. Convolution equations in x direction and y direction are as follows: where I denotes the image to be acted on. Convolution results of sample image direction in this experiment are shown in Figures 4(a) and 4(b).
Firstly, the gradient values in the x and y directions of each pixel of image I are calculated. Then, the approximate gradient value of pixel ði, jÞ is calculated by equation (5). It is shown as follows:

Wireless Communications and Mobile Computing
Sobel operator is utilized to process the sample image in this experiment. The gradient result is shown in Figure 4(c).
Prewitt operator is a first derivative discrete differential operator like Sobel operator. Prewitt operator calculates the image gradient by averaging firstly and then calculating the difference. Equations for calculating the gradient in x direction and y direction are as follows: where I denotes the image to be acted on. The x and y directions of the gradients obtained by Prewitt operator are shown in Figures 5(a) and 5(b) in this experiment.
Prewitt operator is utilized to process the sample image in this experiment. The gradient result is shown in Figure 5(c). Laplace operator is a second order differential linear operator. It is defined as follows: The second derivative can detect the change of image gradient by calculating the change of pixel intensity in the direction of image pixel. The difference partial derivative equation of Laplace operator in x and y directions is shown as follows: Laplace operator is utilized to process the sample image in this experiment. The gradient result is shown in Figure 6.
It can be seen that MPS contours of the sample image can be detected by each operator from the results of the three gradient operators. However, the detection features of the three  Figure 6. They show that Sobel operator has the best detection effect. It can detect the contour of the pixel area of the MPS. The contrast is higher than other operators. It makes subsequent binarization methods better.

Binarization.
ROI is extracted by this experiment. The feature of the image in ROI can be reflected well by the gradient of image. The contrast of MPS edge image pixel obtained by Sobel operator is far from enough. It leads to the complex gray value in the image. It also brings difficulties to the subsequent edge contour recognition process. Therefore, binarization is utilized to enhance the contrast of MPS edge contour. It is helpful for morphological operation to filter fine pixels and expand the image edges. The result of binarization is shown in Figure 7 Figure 7(b). It can be seen from the result figure that the open operation can reduce the black area in MPS appropriately. It has a certain noise reduction effect and improves integrity of MPS images. It is conducive to ROI extraction.

Edge Tracking Algorithm Based on Topology.
Edge tracking algorithm based on topology structure [25] is utilized to recognize ROI from the image in this experiment. The recognition result is shown in Figure 7(c).
This algorithm traverses the pixel of an image to determine whether the pixel is in the edge region. The judgment conditions are as follows: where ði, jÞ denotes the position of the pixel in the image. f ði, jÞ denotes the pixel value of the pixel in the ði, jÞ position. The contour obtained by the edge tracking algorithm based on topology is not a rectangular region of ROI. It is an irregular outer contour region. This makes it impossible to cut edges. Therefore, the minimum circumscribed rectangle is marked in this experiment according to the irregular external contour. ROI is cut by the software according to the minimum circumscribed rectangle. The calculation process of the circumscribed rectangle is as follows: The minimum circumscribed rectangular area is shown in Figure 7(c). The red line mark is utilized in this experiment to observe the detection results conveniently.
It can be seen from Figure 7(c) that the result of ROI annotation is satisfactory. It shows that the irregular edge of

Wireless Communications and Mobile Computing
ROI is detected successfully by the method. It also obtains a relatively complete minimum circumscribed rectangle of ROI. In addition, it shows that the image processing method utilized in this paper is effective. Finally, ROI is cut according to the position information of the four corners of the minimum circumscribed rectangle. The clipping result is shown in Figure 8.
It can be seen from Figure 8 that cutting effect is satisfactory. The unrelated regions are cut to the maximum extent on the basis of retaining ROI.

Features of Image Extraction.
Gray histogram of images is extracted as a feature in this paper. The gradient histogram of MPS sample image is shown in Figure 9.
Gray histogram denotes the number of gray levels in an image. x-axis denotes the value of the pixel range from 0 to 255. y-axis denotes the statistics of the number of a certain gray level in the image. The longer blue line in the image, the more times gray pixels appear in the image. The calculation equation of gray histogram is as follows: Among them, r g denotes the gray level of a pixel in image. Pðr g Þ denotes the probability of the occurrence of a pixel with a pixel level of r g in whole image. n g denotes the number of pixels with a pixel level of r g in the whole image. N denotes the total number of pixels in the image.
3.4.1. Image Defect Detection. Difference of content between images can be reflected as the difference of the pixel value of each pixel in image. In this paper, it is proposed to judge whether the sample to be tested is defective. It is by comparing the gray histograms of MPS nondefective and MPS to be tested. A difference threshold is set before comparison. MPS of the current image is defined as a defective product, if the difference between two gray histograms is greater than the difference threshold. MPS is defined as defect free product, if the difference between two gray histograms is less than the difference threshold. The difference threshold in this paper is set at 0.98.  The definition of accuracy of CFDDM proposed in this paper is shown as follows:

Model Evaluation
where T denotes the number of correct test results. F denotes the number of wrong test results. TP denotes the number of defective images identified as defective correctly. TN denotes the number of nondefective images identified as nondefective correctly. FPdenotes the number of nondefective images identified as defective wrongly. FN denotes the number of defective images identified as nondefective wrongly.

Experiment
Results. Firstly, the data set is processed by the method proposed in this paper. Then, 200 MPS images to be tested and 1 nondefective sample image were detected by gray histogram comparison. 50 samples of nondefects were identified as nondefective successfully. 150 samples with defects were identified as defective successfully. The accuracy was 100%, and time consuming was 4.56 s.
Excellent accuracy due to the following aspects is as follows: (1) Affine transformation is utilized to adjust the angle of MPS. It is beneficial to cut the unrelated background region in the stage of ROI extraction (2) The influence of noise from the background region is reduced by ROI extraction  Time consumption of ROI extraction by utilizing different sizes of Sobel operator is shown in Figure 11. The result of ROI extraction by utilizing different sizes of Sobel operator is shown in Figure 11.
Three different colored lines in Figure 12 denote Sobel operators with different convolution kernel sizes. 3 × 3 convolution kernel utilized in this paper is denoted by a black line. Red line denotes 5 × 5 convolution kernel. Blue line denotes 7 × 7 convolution kernel. y-axis denotes the time consumption of three kinds of Sobel operators to extract ROI. Time consumption of Sobel edge extraction was recorded 5 times in this experiment. The number of experiments is shown in x-axis. The time of each work is shown in y-axis. It can be seen from Figure 12 that ROI extraction process by utilizing 3 × 3 convolution kernel takes the least time. It is 1.92 s at most. The convolution kernel of 7 × 7 takes the most time. It is 2.74 s at most.
It can be seen from Figure 11 that ROI can be detected completely by 3 × 3 Sobel operator. 5 × 5 Sobel operator misjudges a small region of MPS as ROI in the process of ROI

10
Wireless Communications and Mobile Computing recognition. Wrong recognition result leads to the failure of ROI clipping directly. A small region of MPS is misjudged as ROI by 5 × 5 Sobel operator in the process of ROI identification. Wrong recognition result leads to the failure of ROI clipping directly. ROI does not to be recognized in the correct region by 7 × 7 Sobel operator. However, the rectangular image contour is recognized as ROI in the process of ROI identification. It makes impossible to cut ROI. To sum up, the 3 × 3 Sobel operator utilized in this paper is the best. More deep learning networks are utilized to detect product defects in the field of industrial product inspection. In this part, CFDDM proposed in this paper is compared with Alexnet, LSTM, and CNN. It is worth noting that the data sets utilized by all detection methods are MPS images after preprocessing. The accuracy of the comparison experiment is shown in Figure 13.
x-axis denotes the type of defect detection method. y-axis denotes accuracy. It can be seen from the Figure 13 that the accuracy of CFDDM proposed in this paper is 100%. It is higher than other neural networks.

Conclusion
It is inevitable to produce defective products due to improper operation of work in the processing of MPS. At present, most factories adopt manual observation to identify defects. The method is inefficient. CFDDM based on machine vision is proposed in this paper. It is utilized for the defect detection of MPS. CFDDM does not need a large number of data sets of training model. It also does not need to compress image after comparing with the conventional deep learning methods. It only needs to process image several times to get the defect recognition results. The test results show that the detection time is about 4.56 s. Accuracy can reach 100%. In the future work, we will explore the implementation of MPS defect classification on the basis of this study.

Data Availability
The data used to support the findings of this study are available from the corresponding author upon request.

Conflicts of Interest
The authors declare that they have no conflicts of interest.