Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 8, No. 1, 2023 149 Food Packaging Target Location and Recognition Technology Based on Machine Vision Ziyu Xiong1, a 1International school, Jinan University, Guangzhou, 510632, China atimyu2@126.com Abstract: In the 21st century, people have an increased demand for food in their lives. Packaging manufacturers product a mass of outer packaging in order to satisfy the demand of food before they access to market for sale. What’s more, food packaging needs to be identified and tested, sorted, and shipped to the food producers. Machine vision has many advantages over than human eyes: high detection efficiency, high accuracy, no controlled by fatigue and so on. So, article takes the outer packaging of food as the research object and research on target location and recognition technology of food packaging based on machine vision was carried out. This article has certain practical application value. The research content is as follows. Firstly, the function of edge detection is recommended. Then three categories of edge detection are introduced. Through the five edge detections are introduced and the experimental results are compared, Canny algorithm is the best scheme. Secondly, this section learns the function and advantages of the HOG. The food packaging image is exacted features with HOG method. Thirdly, this section also introduces the function and the advantage of SIFT. The food packaging image features are taken experiments and recognized. Fourthly, this section recommends the experimental procedure and advantages of single target image location technique. In the end, this article concludes all the experiments and points out the shortcomings of the previous mentioned experimental steps. Keywords: Machine vision, Edge detection, Feature extraction, Object identification, Single target location. 1. Introduction With the development of social economy and the improvement of people’s living consumption raise to higher level, the demand of food has risen accordingly day by day. Food is produced on a large scale in factories. At the same time, outer food packaging manufactures need to produce a large number of different types of food packaging to ensure the stability of food supply chain. In the food packaging production industry, it relates to the application of identification and detection of various outer packaging. For examples, the outer packaging of snacks for various flavors and brands needs to recognize the characters and patterns on the packaging. Most of the applications of identification and detection are carried out on high-speed production lines, which are continuous high-volume production. In 2012, Juan Li of the University of Electronic Science and Technology of China mentioned the inadequacy of manual detection in paper cup packaging detecting system research and application [1]. She pointed out the disadvantages: the detection and recognition efficiency is low, low accuracy, worker easily get tired, errors because of individual differences and so on. For those questions, this article put forward a proposal to make up for the defects of traditional eye detection based on machine vision. Machine vision has many virtues such as high detection efficiency, high recognition accuracy, the cost of maintaining machines is lower than the cost of labor, which is rising year by year, machines do not get tired, they have not individual difference and unlike workers who have problems with repetition and boredom. All in all, machine vision plays a stable, continuous and reliable role in high-speed production line. As for food packaging manufacturer, machine vision can bring more revenue. It plays an important character in this field. 2. Literature Review This article has studied and stimulated the idea of research through literature review. Shaowei Zhang of the Shanghai Jiao Tong University in the research and application of edge detection algorithm based on machine vision, he mentioned that as the cost of labor force rose, machine vision products began to replace traditional labor. In this study, current mainstream edge extraction algorithms and their functions are also mentioned. Most importantly, Canny algorithm is representative.[2] Then, Xue Li of the Shenyang University in the performance evaluation of gray edge detection algorithm, the main edge algorithms and their implementation are introduced in detail. It provides thoughts for the selection of the edge algorithm in this study.[3] In 2019, Ying Li and Qiuping Luan in the Design of food packaging inspection system based on machine vision referred to feature extraction of food packaging images and learned that machine vision is mostly used to detect defects in food packaging. Few researchers have studied the target recognition and location technology of food packaging. These two references provided the creative methods for the experiment.[4] Yongpeng Jie in the research of target positioning and localization of industrial robots based on machine vision, he identified and positioned different plastic sheets calibrated for sunroof Settings in the cab of a car. Algorithms related to image target recognition and positioning, and applicable places and functions were learned. They provide thoughts for food packaging image positioning.[5] So this research presents a method of calculating image contour and object measurement to locate a single object. And this method is different from the mainstream HOG and SVM image localization methods. In conclusion, this article is based on consulting the literature in related fields, learning and understanding and relevant technology application and implementation. 150 Nowadays, there are few literatures with the same research direction as this article. It shows that research direction is different from most researchers. The key points of this research are the edge detection, target location and recognition of food packaging. This article can add creativity to the research field of food packaging. 3. The Function and Purpose of Edge Detection Image edge technology is widely used in robot vision. The technology has stable visual features. It is able to extract image target contour information, increase irrelevant image content and additional calculated data, retain the structural properties associated with the target. The main purpose of edge detection is to find and locate the obvious changing properties in digital images. In general, image attributes have changed significantly because of attribute changes and important events. 4. Edge Detection Algorithm Category There are three kinds of edge detection algorithms such as edge algorithm of first derivative, edge algorithm of second derivate and other edge algorithms. Roberts, Prewitt, Sobel are first derivative edge algorithm. Three of them are based on first derivative. Firstly, a suitable differential algorithm is found to record the gradient threshold of the image. Then the points whose gradient magnitude is greater than the threshold value are marked as image edges. Finally, the edge of the image is got. Laplacian is second derivative edge algorithm which is common. The edge of image is the extreme point of the first derivative. It is also the zero of the second derivative. In this way, the edge point of the image can be found precisely. Other commonly and widely used edge algorithms are Canny. But Canny must satisfy certain constraints and it is a multilevel detection algorithm. So, it is the most widely used algorithm in industry because it is an optimization algorithm. 5. Roberts In 1963, Lawrence Roberts came up with Robert’s algorithm which was the first edge algorithm in the world. It is calculated by the gradient of the skew deviation fraction. So, it is also known as the cross-differential algorithm. 5.1. Roberts algorithm detects the edge of food packaging The experiment as follows. Figure 1. Original food packaging and processed by Roberts photos. 5.2. Sobel algorithm In 1968, Irwin Sobel and his friend Gary Feldman came up with the Sobel algorithm at an informal PhD student seminar at Standford University’s Artificial Intelligence Program. Sobel algorithm is mainly used to obtain a step degree of digital image and is an improved algorithm of Prewitt algorithm. 5.3. Sobel algorithm detects the edge of food packaging The experiment as follows. Figure 2. Original food packaging and pictures processed by Sobel. 5.4. Prewitt algorithm In 1970, Prewitt algorithm was put forward by J.M.S. Prewitt.[6] The Prewitt algorithm is a 3x3 template which can calculate the pixel values in the image area. Prewitt algorithm uses the gray value of adjacent points generated by pixel points in a specific region. 5.5. Prewitt algorithm detects the edge of food packaging The experiment as follows. Figure 3. Original food packaging and pictures processed by Prewitt. 6. Laplacian Algorithm Laplacian is a second-order edge algorithm. It is named after the famous French data scientist Pierre-Simon Laplace (1749-1827). Laplacian algorithm has the characteristics of linearity and invariant rotation of coordinate axes. It is mainly used for edge extraction and image enhancement. 151 6.1. Laplacian algorithm detects the edge of food packaging The experiment as follows. Figure 4. Original food packaging and pictures processed by Laplacian. 6.2. Canny algorithm In 1985, John F. Canny proposed a method to judge and extract edges, which is the Canny algorithm.[7] Then he wrote the theory of edge computing, in which he explained the Canny algorithm in detail. Canny algorithm has been invented for 37years, but it is still widely used in research and industry. 6.3. Canny algorithm detects the edge of food packaging The experiment as follows. Figure 5. Original food packaging and pictures processed by Canny. 7. Edge Algorithm Comparison and Selection In the article, based on 5 kinds of edge algorithms, the edge detection of food packaging images is carried out one by one, and the characteristics of edge algorithms are analyzed by comparing with the original image of food packaging. In the first derivative edge algorithm, Roberts algorithm is simple to achieve, but it is affected by noise and the accuracy is not high and the edges are thicker. Prewitt algorithm can suppress more noise. However, its positioning accuracy is low. Sobel algorithm is characterized by smooth noise, and it can provide accurate edge direction information, and edge positioning accuracy is high. In the second derivative edge algorithm, Laplacian algorithm not only does not have noise resistance, but also edge location information is lost. But it is simple, fast and has good performance in digital image processing. On the other edge algorithm, Canny algorithm has strong anti-noise, accurate edge positioning and non-repeatability of edge representation. Therefore, Canny algorithm has more advantages than the other four algorithms. That is to say, Canny algorithm performs well in the edge detection of food packaging image and is suitable for high-speed food packaging production line. 8. The Function and Advantages of HOG Algorithm In 2005, HOG algorithm was proposed by Nabet &Bill Triggs in CVPR [8] and applied to the field of computer vision and image processing to detect the feature information of objects. It can capture the local shape of the image, and the adverse effect on the image can be ignored in the light change 8.1. HOG algorithm extracts the features of food packaging The experimental effects are as follow. Figure 6. Original food packaging and pictures processed by HOG. 8.2. The function and advantages of SIFT algorithm In 1990, Professor David G. Lowe proposed an efficient region detection algorithm in ICCV, and five years later, Professor David G. Lowe published it again in IJCV making SIFT algorithm more perfect and more functional [9]. SIFT algorithm can not only identify objects, but also ensure high accuracy, which is widely used in object discrimination, perception, 3D model and other aspects. SIFT algorithm is not affected by image rotation, scale and brightness, and has high noise suppression. Under the requirement of computer hardware, the speed of object recognition can be close to real- time. 8.3. SIFT algorithm is used to detect the features of food packaging The experimental effects are as follow. 152 Figure 7. Original pictures processed by SIFT 8.4. Experimental steps and advantages of image positioning with a single object First of all, the image needs to be processed to suppress noise, using Gaussian filtering method. Secondly, the threshold function is used to remove image points with large or small pixel values for images converted to black and white. Thirdly, find the contour edge, and need to calculate the minimum area of the point set of the external rectangle. Finally, find the horizontal and vertical vertices of the maximum value, draw the rectangle box. This algorithm is different from the complex and mainstream HOG and SVM image positioning method, which is relatively simple, can reduce the cost of operation and make the speed faster. 8.5. An experiment of image localization by a single object The experience is as follow. Figure 8. Original pictures processed by image localization with a single object. 9. Experimental Analysis and Summary This research firstly introduces the function and purpose of edge algorithms. The first derivative edge algorithms such as Roberts, Sobel, Prewitt, second derivative edge algorithm Laplacian, other edge algorithm Canny are introduced and also one by one using the algorithm to the food packaging image experiments, through comparison and summary, the Canny algorithm is the best. The original images are based on the experiment under sufficient light, and the experiment is not carried out on the image with insufficient light, So the experiment has some requirements on lighting. Secondly, the function of HOG and SIFT algorithms are recommended. The feature of the original image is extracted by HOG algorithm, and then the feature recognition is carried out by SIFT algorithm. The task of target recognition is completed. This step extracts and recognizes all the information of the image, but in the real industry, it is necessary to accurately extract and recognize the specified information, such as the text on the package, the color on the package, the production date and address on the package, etc., indicating that the experiment still has shortcomings. Thirdly, in the high-speed production line, the food packaging box is positioned with a single target image. The selected method is simpler than the mainstream positioning technology HOG and SVM, and has low requirements on computer hardware and high real-time performance, so it has certain use value in the actual production line. References [1] Li, J. (2013) Research and application of paper cup outer packaging inspection system based on machine vision. Thesis of University of Electronic Science and Technology of China, 72. [2] Zhang, S. (2013). Research and application of edge detection algorithm based on machine vision. Thesis of Shanghai Jiaotong University, 68. [3] Li, X. (2007). Performance evaluation of edge detection algorithm for gray image. Thesis of Shenyang University of Technology, 80. [4] Li, Y., Luan, Q. (2019) Design of food packaging detection system based on machine vision. packaging engineering, 41(9):210-214. [5] Jie, Y. (2023). Research on target recognition and localization of industrial robots based on machine vision. Thesis of Shenyang University of Technology, 89. [6] Prewitt, J.M.S. (1970) Object enhancement and extraction picture processing and psychopictorics In: Picture processing and Psychopictorics. New York. 75-149. [7] Canny J. (1986) A computational approach to edge detection. IEEE Transactions on pattern analysis and machine intelligence, 6: 679-698. [8] Dalal, N., Triggs, B. (2005). Histograms of oriented gradients for human detection. IEEE Computer Society Conference on Computer Vision & Pattern Recognition, 1: 886-893. [9] Lowe, D. (2003). Distinctive image features from scale- invariant key points. International Journal of Computer Vision, 20: 91-110.