A Novel Inverse P-M Diffusion enhanced Code spraying Robot for Express Security Inspection

Aiming at the problems of low speed and difficult quality assurance in the current security inspection and manual coding operation of express delivery companies, a new code spraying robot based on inverse P-M diffusion segmentation is designed. The designed robot is composed of a mechanical execution system, electrical control system and image processing system. The image processing system is used to obtain the location coordinates of the express, and the mechanical execution system and the electrical control system complete the operation of the express code operation. The express positioning algorithm designs an inverse P-M diffusion factor based on the gray and gradient characteristics of the express delivery boundary. Average, dust, noise and other environmental factors affect the coordinate positioning. Threshold segmentation is used to segment the target, extract the explicit center coordinates, and finally transfer the extracted coordinates to the mechanical robot for spraying operation. The experimental results show that using the code spraying robot designed in this paper to carry out the express delivery security inspection spraying experiment, the accuracy rate reaches 94%, which greatly improves the efficiency of the express delivery assembly line security inspection.


I. INTRODUCTION
With the rapid development of the express delivery industry, the market has higher and higher requirements for the efficiency and accuracy of the security check information code spraying after express delivery security checks. At present, the security inspection information code spraying work of express logistics enterprises after the security inspection of express items is still manual operation. This manual spraying method cannot meet the real-time, efficient and fast processing of express shipments for the growing number of express shipments, especially during e-commerce promotions and shopping festivals, which can easily cause a backlog of express shipments and affect logistics. industry development. Enterprises have huge demand for automatic security inspection information code spraying devices, and it is imminent to develop automatic security inspection information code spraying devices. The express sorting system and security inspection system of express delivery companies have been automated, and automatic code spraying of security inspection information has become an urgent need for enterprises. Robot has the characteristics of flexibility, high degree of automation, good flexibility and low cost [1]- [3]. It has become a big trend to apply automatic devices to express logistics companies. A multi-task deep learning sorting device is proposed, which is applied to express sorting to realize the accurate and fast sorting of express parcels [4]. In order to construct an intelligent robot grasping system with a high sensitivity tactile sensor array, Li et al. [5] developed a contact force feedback algorithm by providing contact force perception through tactile sensors. Zeng et al. [6] designed a grasping and placing robot system, using this system can realize autonomous recognition and grasping objects in complex scenes. Hofer et al. [7] introduces an inflatable robotic arm, which can realize free grabbing and placing of objects, with high safety factor, accuracy and reliability. Sughashini et al. [8]designed a pneumatic mechanical arm with a color sensor module for sorting objects. The main method is to separate the objects from the collection according to the color of the objects, which is used for objects that move through a conveyor belt. Cosenza et al. [9] proposed the development of an algorithm to measure the displacement of a mechanical system in contactless mode. However, there are very few studies on automatic code spraying devices for express items. In response to this problem, it is necessary to use modern advanced machine vision detection, artificial intelligence and pattern recognition technology to design a non-contact detection robot for security inspection and spraying. It has become an urgent need of major logistics companies.
The location of the express item is a very important component of the automatic code spraying device, which determines the accuracy of the spraying of the security information. The application of machine learning technology in Industry 4.0 has become more and more extensive. Increasing numbers of scholars and engineers have been introducing machine learning algorithms into the field of industrial application [10]- [12]. Express image denoising and segmentation is a very important part of the positioning algorithm. Among them, the image denoising method based on partial differential is widely used [13]- [15]. Its development process includes the uniform linear diffusion process to the linear nonuniform diffusion process, and then to the nonlinear diffusion process [16] and the anisotropic diffusion process of coherent enhanced diffusion. In recent years, there have also been forward and backward diffusion processes [17], complex number domain diffusion processes, high order differential equations, etc. The most typical of which is the anisotropic diffusion equation P-M diffusion equation proposed by Peron and Malik. Thamil et al. [18] Cui attempted to extract edge maps from infrared breast images using the inverse P-M model. This nonlinear filter uses inverse gradients and a new nearest-neighbor scheme to alter interference and diffusion near edges. Guo et al. [19] proposed a method for suppressing speckle noise in sonar images based on improved P-M model.
After the safety inspection of express items, safety signs need to be sprayed. According to the safety inspection requirements of express companies, the grayscale and gradient characteristics of express boundaries are analyzed, and an express security inspection code spraying robot based on inverse P-M diffusion is innovatively designed. It consists of three parts: mechanical execution system, electrical control system and image processing system. The first part introduces the overall design of the system, the second part introduces the express positioning algorithm; the third part conducts experiments; the last part summarizes our conclusions.

II. OVERALL DESIGN OF THE ROBOT
The robot is mainly composed of three parts: mechanical system, electrical control system and image processing system. The system workflow is shown in Figure 1. After the shipment is detected by the safety detection robot, it is sent to the code spraying robot through the conveyor belt. When the express train triggers the sensor, the camera acquires the express train photo for location coordinate extraction, and transmits the obtained express position coordinate to the motion control module, and the motor drives the code spraying robot to move directly above the express train. At the same time, the cylinder solenoid valve is energized, the cylinder is inflated, and the printer moves down. The printer contacts the express delivery to perform spraying operations. The photoelectric sensor action triggers the cylinder solenoid valve change phase. The cylinder recovery completes a shipment anticounterfeiting code operation, that is, the shipment security check is automatic.

A. MECHANICAL SYSTEM DESIGN
The mechanical system of the express security inspection and code spraying robot mainly includes: express conveyor belt, longitudinal motion device, horizontal motion device, and vertical spraying device. The top view of the security inspection and spraying robot is shown in Figure 2.

Horizontal movement mechanism
Vertical spraying mechanism Longitudinal movement mechanism Image acquisition system (1) Longitudinal movement mechanism: It is composed of a fixed frame, a stepping motor, a belt and gear, a sliding block and a sliding block guide column, a limit switch, etc., as shown in Figure 3: The lower part of the rectangular frame is supported by a supporting column, and the rectangular frame. The longitudinal motion mechanism is installed on the long sides of both sides, and the beam slider guide post is installed on it. The guide post is nested in the slider. The stepper motor pulls the slider below the horizontal motion mechanism through the belt to guide the horizontal motion mechanism to move back and forth. The limit switch at both ends of the slider guide column limits the movement range of the horizontal beam.
Stepper motor and drive rod Slider and slider guide post

Belts and gears
Limit switch (2) Horizontal movement mechanism: It is mainly composed of horizontal beam and guide rail, stepping motor and screw, sliding plate, photoelectric limit switch, etc. The horizontal chute is made on the beam, and the sliding plate is embedded in the chute. One end of the beam is equipped with a stepping motor. The driving screw passes through the sliding block under the sliding plate, and the middle of the sliding block is provided with a threaded hole. The rotation of the driving screw drives the sliding block to move, thereby driving the sliding plate to move horizontally. As shown in Figure 4: (3) Vertical spraying mechanism: It mainly includes air cylinder, lifting guide-bar, tray, code spraying mechanism, etc. as shown in Figure 5. After the motion control module obtains the express position coordinate information, it controls the movement of the stepping motor to make the horizontal sliding plate. When it moves directly above the express, the solenoid valve of the cylinder is energized and the cylinder is inflated. The downward movement of the cylinder drives the spraying to move downward. When the spraying touches the express, the spraying operation will be performed, and the photoelectric sensor will act to trigger the solenoid valve change phase, cylinder recovery completes a security inspection and spraying operation.

B. KINEMATICS AND DYNAMIC ANALYSIS
Link-driven transmission, widely used in mechanical structures [20]- [23]. In order to express the position and posture of the VOLUME XX, 2017 4 end of the vertical spraying mechanism relative to the coordinate system of the robot frame, the motion relationship between the joints is required. For two arbitrary coordinate systems. The homogeneous transformation matrix T with can be expressed as: According to the actual motion conditions of the code spraying robot, the establishment of the joint motion coordinate system of the robot is the basis for the robot kinematics analysis. As shown in Figure 6 below, the joint coordinate system is fixed to the lower joint in the post mode, the coordinate system is the robot base coordinate system, and the coordinate systems {1} {2} {3} respectively represent 3 moving joints. The joint parameters are used to indicate the position and posture of the end of the marking robot. Table 1 is the structural  parameter table of The homogeneous transformation matrix of the robot rod coordinate system relative to the coordinate system {i-1} as shown in equation (2). According to the D-H coordinate transformation equation, the homogeneous transformation matrix of the coordinate system of the two rods as shown in equation (3): According to the manipulator of the express security inspection spraying robot in this article, combined with the structural parameters of the motion platform, the homogeneous transformation matrix of two adjacent coordinate systems can be written in sequence, as shown in the following equation (4-6): Therefore, the pose matrix of the vertical spraying printer can be obtained as: The above equation represents the coordinated mapping relationship between the end of the marked robot and the robot base, which is the positive kinematics equation of the robot. In actual operation, the motion range of each moving joint of the robot and the variable value of the moving joint are given. Gets the position of the end.

C. ELECTRICAL CONTROL SYSTEM
The electrical control system mainly controls the actions of the electrical equipment in the code spraying robot. The electrical control system can control the speed of the conveyor belt so that the speed of the conveyor belt meets the frequency of the camera's collection of express images, controls the power supply of the camera, and controls the mechanical robot. The movement process and the cylinder solenoid valve change phases to realize the up and down movement of the spraying printer. It can also control the response of the photoelectric sensor in real time.

III. EXPRESS LOCATION ALGORITHM DESIGN A. EXPRESS IMAGE FEATURE ANALYSIS
Due to the influence of the working environment of express logistics enterprises, express images taken by cameras are susceptible to changes in light, uneven reflection, and noise. The clear goals are different. Perform grayscale feature and edge gradient feature extraction. The analysis shows that the gray value characteristics of the VOLUME XX, 2017 5 conveyor belt have not changed much, but the gray value of the boundary where the conveyor belt intersects with the express destination has changed significantly. At the same time, the gradient value of the conveyor belt changes very little, and the initial gradient value changes drastically at the intersection of the conveyor belt and the express destination. Therefore, it can be concluded that the gray value and gradient value of the conveyor belt background are relatively small, but the boundary gray value and gradient value at the intersection of the conveyor belt and the express destination change drastically. Use this function to split quick targets.

B. EXPRESS LOCATION ALGORITHM
The design of fast target positioning algorithm is a very important part of the entire security inspection spraying system. The quality of the positioning algorithm directly affects the performance of the code spraying robot and the accuracy of spraying. The background of the conveyor belt is dark blue, which is characterized by the express destination and the background color of the conveyor belt. The difference is obvious. Use this function to use inverse P-M diffusion for processing. The main steps of the fast target coordinate detection algorithm include: fast image preprocessing, inverse P-M diffusion, image difference, threshold segmentation, morphological processing, minimum boundary rectangle drawing, coordinate positioning, and other operations. The flow chart of the express location coordinate detection algorithm is shown in Figure 7: 0 I x y t c x y t I t 0 t I x y 0 I x y t 0 Among them, (x,y)∈R 2 , I(x,y,t) is the image at time t, I0 is the original image, ∇I is the image gradient operator, c(x,y,t) is the nonlinear diffusion factor, c satisfies 3 principles.
(1) c is a decreasing function with ∇I as the independent variable, and c>0; (2) When ∇I→, c=0; (3) When ∇I→0, c=1; Diffusion factor c expression： In order to establish the internal coordinate form of the diffusion equation, define the internal coordinate system (, ). Among them,  is the image gradient direction, that is, the direction perpendicular to the image feature edge;  is the vertical image gradient direction, that is, the direction along the image feature edge. The corresponding (, ) in the image space coordinate system (x. y) can be expressed as: Then, calculate the second derivative of I with respect to  and  respectively, and we can get the following: Where: c and c are the diffusion coefficients along the  and  directions, respectively.
The diffusion coefficient of the P-M diffusion equation can be selected as up: From equation (14), it can be seen that the diffusion coefficient changes with the gradient mode. When I→0, c→1, the image is smoothed; when I→, c→0, the image is maintained. P-M diffusion discretized form is equation (15): This article has been accepted for publication in a future issue of this journal, but has not been fully edited. Content may change prior to final publication.

I x y t I x 1 y t I x y t I x y t I x 1 y t I x y t I x y t I x y 1 t I x y t I x y t I x y 1 t I x y t
In order to segment the image express target area as much as possible, the image express target area should be maintained, and only the conveyor belt area should be smoothed. This process is inverse to the P-M diffusion, so it is called the inverse P-M diffusion process. The traditional P-M diffusion model only uses a single gradient information. In order to accurately segment the contour of the express target, the method proposed in this paper designs the inverse P-M diffusion factor based on the gray value and gradient value of the express target, Such as equation (17).
In order to prevent the gray value from determining the diffusion factor alone, f is normalized, that is, f=I0/255. In, ∇I(x, y) is the gradient at (x, y), and K is Regularization factor. When ∇I→0, g→0, the image is maintained; when ∇I→∞, g→1 image is smoothed. The inverse diffusion process is the same as equation (18), only the diffusion factor c Replace with the inverse diffusion factor g. The designed nearest neighbor difference is shown in Equation (19). The structure of the discrete calculation scheme to simulate the diffusion equation is shown in Figure 8.

FIGURE 8. Structure of Discrete Computational Schemes for Simulating Diffusion Equations
The designed new nearest-neighbor difference structure is able to enhance the edges of express targets, and other noise-disturbed regions remain unchanged. The principle is as follows, and only the diffusion in the y direction is explained. As shown in Figure 9, Edge areas and other noise-disturbed areas.
According to the analysis of equations (17) and (21) and (22), it can be known that the size of the inverse diffusion factor is proportional to ∇I and inversely proportional to f. Therefore, when ∇I increased or f decreases, the inverse diffusion factor will increase. Because of the intersection of the express target and the conveyor belt, has the characteristics of low gray value and high gradient value at the same time, so the obtained inverse diffusion factor is larger. When ∇I increased and f decreases, g increases rapidly. Therefore, the edge area is quickly smoothed. And low gray compared with pixels in the boundary area, pixels in the conveyor belt area with a low gradient value and a low gradient value have a smaller inverse diffusion factor and a weaker smoothing effect. Therefore, the boundary VOLUME XX, 2017 7 area between the conveyor belt and the express destination can be segmented. As shown in Figure 10. (c) Image difference and threshold segmentation: Let I0 be the express preprocessed image, and It is the image obtained by inverse P-M diffusion. The difference between the preprocessed image and the inverse diffusion image is defined as the difference image, namely. The result of the difference processing is shown in Figure 11 below. Threshold segmentation of the image after the difference. The Otsu segmentation algorithm selects a threshold T to divide the difference image into two categories. Set the difference image array as I(x,y), the output image array as dst, and the judgment equation is as follows (24). The image after the difference in this experiment only contains the boundary area of the express target, and the gray distribution of the boundary target and the background pixel is obvious. The express target can be separated using the Otsu segmentation algorithm. The threshold segmentation process is shown in Figure 12: (d) Morphological processing and coordinate acquisition Threshold segmentation is completed followed by morphological processing. Morphological treatment fills in black gaps or areas, ensuring that the edges of the express delivery contour are closed. The main process is to first perform a morphological dilation operation on the image of the express target after threshold segmentation to ensure that the contour of the express target is completely closed, and then perform an erode operation on the dilated express to restore it to its original shape and size.
Determine the coordinate information of the express according to the outer boundary of the express target area, and obtain the four vertices of the smallest enclosing rectangle of the contour of the express image [(x0,y0), (x1,y1), (x2,y2), (x3,y3)]. Calculate the center (x, y) of the smallest circumscribed rectangle, and transmit the express coordinate information to the motion control module of the mechanical execution device, and the spraying device will execute the corresponding spraying operation.

IV. EXPERIMENT
According to the actual situation of express parcel delivery by express logistics enterprises, the express delivery spraying experiment platform is designed as shown in Figure 14. This project chooses VS2015 compilation environment and OpenCV4 vision library to complete the realization of express position coordinate positioning algorithm based on image processing. Mechanical system code spraying operation. In order to verify the performance of the segmentation algorithm based on inverse P-M diffusion proposed in this paper, the collected 300 express images are segmented by background difference, K-means segmentation, Otus segmentation, and the method proposed in this paper. Some express image processing results are shown in Figure  15: The background difference is suitable for image segmentation with obvious differences between the foreground and the background, but the background of the conveyor belt is easily affected by illumination changes as shown in (a), (b), (c) in Figure 15, and the difference between the foreground and the background is not obvious with different illuminations. The Otsu algorithm is suitable for image segmentation in which the histogram is in a bimodal state. When the express target in the image is close to the conveyor belt background, as shown in (a) and (b), the Otsu segmentation effect is not good. The K-means algorithm is suitable for image segmentation with complex colors, but when the color of the express item and the conveyor belt are close, it is easy to be classified into one VOLUME XX, 2017 9 category, and the segmentation accuracy is poor. The express segmentation algorithm proposed in this paper has strong inhibition against illumination changes. The differential operation of processing and inverse P-M diffusion can eliminate the background of the conveyor belt, and then perform threshold segmentation on the differential image, which can accurately segment the express target boundary. In order to accurately verify the effectiveness of the segmentation algorithm in this paper, the above four methods are compared from the three performance indicators of accuracy rate, false detection rate, and segmentation time, as shown in Table 2: It can be seen from Figure 16 that the accuracy of background difference, Otsu algorithm and K-means segmentation is less than 80%, and the segmentation accuracy of the proposed algorithm can reach 94%, and it can be seen from Figure 17 that the false detection rate of this algorithm is also four methods. The lowest and the shortest execution time can meet the accuracy and realtime performance of the security inspection code spraying robot.  The process of selecting 5 express images is shown in Figure 18. Lines 1-6 are original images, preprocessed images, inverse P-M diffusion images, differential images, threshold segmentation images and minimum bounding rectangle images. After the above processing, the smallest bounding rectangle expressing the target in the image can be accurately found for coordinate extraction. The extracted express train position coordinates are shown in Table 3, and then the detected center coordinates are converted and sent to the mechanical execution robot for spraying operation. The statistical results of the experiment are shown in Table 4. The spraying speed of the robot can reach 1000~1200 pieces/hour, and the spraying accuracy rate is 94%. The code spraying robot meets the real-time online code spraying requirements of the logistics enterprise's assembly line express mail security inspection, and improves the logistics level.

V. CONCLUSIONS
In view of the slow manual code spraying speed of express companies and the difficulty of ensuring the quality of code spraying, according to the requirements of security inspection, by analyzing the gray and gradient characteristics of express images, an express delivery spraying robot based on inverse PM diffusion was designed. Check. First introduced the overall design of the system, and then introduced the composition of the mechanical system and electrical system. Finally, the fast target location coordinate positioning algorithm based on inverse P-M diffusion is introduced in detail. Using the designed express security inspection spraying test platform, the spraying experiment was carried out. experiment. The results show that the designed express security inspection spraying robot performs security inspection and spraying, and the spraying efficiency can reach 1000 pieces per hour, and the accuracy rate is 94%. Effectively solve the problems of low manual spraying efficiency and inaccurate spraying, and improve the logistics efficiency of express delivery lines.