PDF  PubReader

Li , Sun , Ting , Yang , and Feng: Key Technology for Food-Safety Traceability Based on a Combined Two-Dimensional Code

Zhonghua Li , Xinghua Sun , Yan Ting , Dong Yang and Guiliang Feng

Key Technology for Food-Safety Traceability Based on a Combined Two-Dimensional Code

Abstract: Current food-traceability platforms suffer from problems such as inconsistent traceability standards, a lack of public credibility, and slow access to data. In this work, a combined code and identification method was designed that can achieve more secure product traceability using the dual anti-counterfeiting technology of a QR code and a hidden code. When the QR code is blurry, the hidden code can still be used to effectively identify food information. Based on this combined code, a food-safety traceability platform was developed. The platform follows unified encoding standards and provides standardized interfaces. Based on this innovation, the platform not only can serve individual food-traceability systems development, but also connect existing traceability systems. These will help to solve the problems such as non-standard traceability content, inconsistent processes, and incompatible system software. The experimental results show that the combined code has higher accuracy. The food-safety traceability platform based on the combined code improves the safety of the traceability process and the integrity of the traceability information. The innovation of this paper is invoking the combined code united the QR code‘s rapidity and the hidden code‘s reliability, developing a platform that uses a unified coding standard and provides a standardized interface to resolve the differences between multi-food-traceability systems. Among similar systems, it is the only one that has been connected to the national QR code identification platform. The project has made profits and has significant economic and social benefits.

Keywords: Combined code , Food , Security , Traceability

1. Introduction

Using document analysis, food safety is becoming a kind of strategic resource of sustainable development countries [1]. People is becoming increasingly concerned about food safety, and China is currently introducing more strict regulations into the food market [2]. To ensure the controllability of food from production to sale and to protect food safety, many traceability systems have been applied [3,4]. However, these systems suffer from three issues in particular. Firstly, the traceability systems of most enterprises can only achieve batch management of static data about food. These so-called “pseudo-traceability systems” are inefficient and costly, and the non-dynamic and non-real-time data involved cannot truly achieve the traceability goals such as: source traceability, circulation process verification, and accountability [5,6]. Secondly, there is a lack of credibility and low consumer trust. The construction of traceability systems in various industries in China is still in its early stages, and the relevant laws and regulations and supervision systems have not yet been improved. Most traceability systems are governed by individual enterprises, and there is a lack of credible institutions that can participate in supervision [7]. Finally, traceability standards are inconsistent and difficult to systematize. Different types of food have different production and processing systems, and this results in a failure to implement unified standards and leads to the use of different traceability systems by enterprises in different regions. This caused problems such as non-standard traceability content, inconsistent processes, and incompatible system software [8,9].

There is a variety of goods-traceability technologies in the market, including barcodes, radio-frequency identification (RFID), and near-field communication (NFC). Among these technologies, quick-response (QR) codes are easy to produce and inexpensive, and they have a large storage capacity and high recognition rate [10]. Therefore, approaches based on QR codes are currently among the most widely used technologies in traceability systems. However, the QR code was initially designed as a carrier for information storage, transmission, and identification, and it does not include anti-counterfeiting features so can be copied and manipulated [11,12]. As such, herein, we propose a method using a combined code and describe its application to a food-safety traceability platform.

In view of various safety problems of Chinese food, many food enterprises urgently need a traceability platform. The topic of this project comes from the national key recommended project and is a project of the Science and Technology Department of Hebei Province. We have done the following work: (1) we used the independently developed coding system as the core technology to realize "one thing, one code." (2) We combined the QR-code and the hidden code to improve the safety of the traceability process and the integrity of the traceability information. (3) We developed the traceability platform to resolve the differences between different food-traceability systems. The project has a good and broad market promotion prospect, and the project results can be widely applied to enterprises with high requirements for food quality supervision, such as processing and manufacturing agricultural goods.

This paper introduces the key technology of the combined code in Section 2, discusses the traceability development platform in Section 3, gives experimental results in Section 4, and gives conclusions in Section 5.

2. Key Technology of the Combined Code

To solve the problems described above, a combined code is proposed and applied to the traceability platform to improve the security of the traceability process and the integrity of the traceability information. The combined code includes both a QR code and a hidden code. The composition and origin information of a product can then be effectively hidden, and the traceability of that product can be more secure through the use of this combined code. The hidden code can also still effectively reflect the product information when the QR code cannot be identified.

In the QR-code part of the combined code, based on detailed information such as the origin of the product, the data code, three positioning patterns, and one correction pattern are generated. The three positioning patterns and the correcting pattern are placed in the four top corners of the square area of the QR code. The positioning pattern is an equilateral triangle with an empty center, and the correction pattern is a square with a solid square embedded in its inner center. The right-angled edges of those are equal in length. The diagonals of the square area of the QR code are connected, and the internal positioning pattern is placed on it. Then, the data code is interleaved with its check code, and these are filled into other positions that are not occupied in the square area of the QR code according to the specification. The product QR code is then generated.

The hidden code in the combined code is generated by the QR code; it includes the QR code grayscale image and the hidden code symbol interlaced with that. The QR code grayscale image is generated through complex processes, including converting the QR code data into a two-dimensional matrix, performing a two-dimensional fast Fourier transform [13] on the two-dimensional matrix to obtain the Fourier spectrum, and coding and quantifying the Fourier spectrum.

[TeX:] $$\mathrm{F}(\alpha, \beta)=\iint_{-\infty}^{+\infty} f(x, y) e^{-j 2 \pi(\alpha x+\beta y)} d x d y.$$

In addition, the encrypted ASCII code of the product is added to the hidden code. A series of 32-bit initial ASCII code is generated according to the product information, of which 4 bits are anti-counterfeiting check codes. The remaining 28 bits are divided into five segments, representing the internet platform, country and region, product type, individual and scanning times of the product. The initial ASCII code is then partly interchanged with other bits and recoded by the asymmetric algorithm. Therefore, the security level of the ASCII code is guaranteed, avoiding decoding the code by exhaustive method and dictionary method, ensuring the code can only be decoded by the corresponding decryption program, and finally changed to the detailed product information.

Because a series of transformations is required to create the QR code grayscale image from the original QR code, the difficulty of reverse-engineering the code is greatly increased. At the same time, due to the increase in the amount of information, even if the QR code grayscale image is partially destroyed, the information it carries may not be damaged. However, compared with the original QR code, the hidden code has the disadvantages of requiring complex computation and being difficult to recover. Therefore, in this system, the QR code and the hidden code are combined. If the QR code becomes blurry, this is often accompanied by damage to the hidden code. Even though the QR code grayscale image has better information recovery than a standard QR code, there may still be a problem with incomplete information recovery. To effectively remove damage noise from the QR code grayscale image and obtain a more accurate QR code image, the following correction method for the QR code grayscale image is proposed. After the QR code grayscale image is binarized and the data are cleaned, existing image-processing technologies such as the Canny operator [14] can be used to realize edge extraction. Further, the square structure can be used to expand the morphology of the image to be processed so that all the back areas contacting the square structure are fused into it and its boundary is expanded outward. A connected operation can then be used in the expanded image to mark the separated parts of the binary image so as to distinguish the gray image of the QR code from other irrelevant information. The maximum connected region is selected, and the pixel values of all the connected regions except the maximum connected region are set to 0. Then, horizontal and vertical projections are performed on the image, the output image can be cut according to the projection result.

3. Traceability Platform based on the Combined Code

Based on the above-described safe and reliable combined coding, the SSM framework of the Java programming language was used to develop this food-safety traceability platform. The environment configuration was jdk1.8.0.121, the foreground technologies were the Vue framework and jQuery 1.11.3, and the background technologies were Spring Boot 1.5.6 release edition and the MyBatis 2.1.3 framework.

This platform uses a unified coding standard and provides a standardized interface that can be used not only to develop a unified food-traceability system but also to connect various existing traceability systems. The platform standardization therefore resolves the differences between different food-traceability systems.

The traceability platform uses 36-decimal segmented coding to form formatted traceability data through a standardized workflow that the platform accesses. The combined code is the tracing information entrance of products, which can perfect the display information of various products. Each product has a unique code, and this can be used to dynamically track the source information and reject any counterfeit goods.

Based on the standardization of encoding and the products production and processing standards of food and agricultural that the National Standardization Management Committee made, the platform formulates the lifecycle of products, forms the unity process specification of single-type food, design convenient and practical application in different links, from commodity producer (or with traceability information) to the circulation (logistics information), to distribution (agents), to the dealer (life cycle through point), until the final consumers. The single-type food-traceability system obtains the data from the combined code from a reading interface in an acquisition terminal. It then further obtains the product-composition information carried by the combined code using the designed software, saves the food data and traceability information in real time, and passes it to the food-safety traceability platform through the standardized interface. This platform also provides a data interface for a government-supervision data platform to facilitate external oversight of the system. A diagram of the architecture of the traceability platform is shown in Fig. 1.

Fig. 1.

Diagram of the architecture of the traceability platform.

The platform provides a wealth of data collection, management and query functions for regulators, food manufacturers, agents, venders, consumers, and other related roles. It is managed hierarchically through the national level subsystem and provincial level subsystem. Taking information query as an example, the user identifies the combined code through the terminal application program. After decoding by calling the decoding module, the platform submits the code to the national level subsystem. The national level subsystem forwards the request to the provincial level subsystem according to the regional information in the code. Then the provincial level subsystem will call the corresponding food category module according to the category information in the code to perform the final data query and display.

This platform can use multiple types of terminal device, including personal digital assistants, mobile phones, sensors, etc., to carry out real-time data capture, realize dynamic information display, and solve the compatibility problems of interfaces and displays using multiple platforms. It also integrates internet and wireless technology to facilitate cross-platform reading and transmission of information.

The data sources in the platform include food-traceability data and multi-terminal collection and transmission of data. To ensure the timeliness and stability of data storage, transmission, and processing, this platform is designed to support the query of 50 billion data; the problems of data writing and query speed are solved with the help of Big Data storage and processing technology.

The platform uses the database middleware MyCat, establishing the database sharding cluster, which improves the query performance and realizes the reliable and efficient processing of massive data. It uses virtualization technology so that a physical server can run multiple sets of operating systems and perform multiple sets of tasks simultaneously, and the utilization efficiency of the server can be improved.

4. Experimental Results

A series of tests were conducted to examine the recognition accuracy of the combined code and the performance of the system. The experiments verified that the recognition accuracy for the combined code is significantly improved when compared with a standard QR code. Furthermore, the system operates smoothly, and it can achieve a maximum data processing of 10 billion, and the system can respond to up to 3 million queries per second.

It is necessary to verify the accuracy and reliability of image recognition [15]. The project team generated more than 2,000 sets of QR codes and matching combined codes for reliability testing. First, these code pairs were randomly broken, damaged, covered, and polluted to the same degree, and then the Itti visual model was used to extract data from both the QR code and the hidden code. Finally, the images were identified by extracting the color, brightness, direction, and other visual features, gray-scale processing, image filtering, binarization, and numerical matching.

As can be seen from Fig. 2, in this large number of random experiments, the recognition accuracy for the combined code was greater than 75%, while the QR-code recognition accuracy fluctuated around 40%. The overall recognition accuracy trends of the two were similar, but when the time of experiment increased to 900, the QR-code recognition accuracy declined significantly. Based on this situation, the project team reviewed and examined the experimental samples. On inspection and analysis, it was found that sample numbers 700–900 were in the damaged group. In these samples, the position images of most of the QR codes were destroyed, resulting in the blurring of information.

Fig. 2.

Comparison of recognition accuracy for the combined code and the standard QR code.

This experiment shows that the traceability system based on the combined code has higher recognition accuracy. In the future, the existing single-product traceability system in the platform should be improved according to the single-product traceability standards, which are being continuously enriched and improved. Furthermore, we should strive to increase the number of standardized data interfaces and improve the scalability of the platform to be compatible with and access more third-party traceability systems.

The data sources in this platform involve traceability data for all kinds of different food-traceability systems both within and outside the platform. Therefore, an appropriate level of data processing needs to be used to ensure high enough data-writing speed and query speed. In order to ensure the efficient usage of the platform, the project team has successively conducted the tests of response-time, throughput, transaction per second (TPS), hits per second, CPU-utilization, memory-utilization and disk-utilization.

System performance tests of this platform included its maximum data processing, concurrency per second, and average response time. The project team used LoadRunner to carry out stress tests on the main function pages, and the results of the concurrent load and real-time performance tests on the homepage of the platform with 500 concurrent accesses were obtained as follows. When the total number of hits in the test reached 877,176, the average number of hits per second was as shown in Fig. 3; there was a maximum of 1,115 hits per second and an average of 734 hits per second. When the total throughput of the test reached 258,463 hits of 153 bytes, the throughput per second was as shown in Fig. 4; there was a maximum throughput of 310,298 bytes/second and an average throughput of 216,287 bytes/second.

Fig. 3.

Plot of number of hits per second for the system during the test period.

Fig. 4.

Plot of the data throughput of the system during the test period.

Since the platform was launched in 2021, it has been applied by more than 300 food productions, processing and sells enterprise from eight provinces in China, including Hebei, Guangdong, and Sichuan. It has generated and decoded for more than 10 million combined codes. The project is running stably, with significant economic and social benefits. The price increase and profit increase of some enterprises' pilot online products are shown in Fig. 4. Among them, an enterprise in Shenzhen obtained the highest price increase 26% of a single product reaching and the highest accumulated sales profit increase the most, reaching 550 thousand Renminbi (RMB).

5. Conclusion

Nowadays, a large number of traceability systems are using QR-code. However, most of the QR-code is not encrypted which is very easy to be forged and consequently failed to meet the demand of data transmission safety which would be a crucial problem in relevant fields and research [11,16]. The encryption of combined codes can solve the security problems in data transmission. We apply them to the traceability platform to ensure the effectiveness and security of traceability data. In this paper, we provide a safety traceability platform for the process of food production, circulation, and sales. It is designed to safely digitize and transmit important data in the process of food production, circulation, and sales. With minor modification, the system can be deployed to the retail or wholesale industry of other types of products, showing that this system has extremely high adaptability for practical applications. We sincerely hope that the system can make better contributions in the field of food in the future. In addition, in order to test the effectiveness of our design and development, we also replaced the combined code in the system with QR code for comparison. The advantages of the combined code and the security and reliability of the platform are verified by experiments, showing their practical significance and application value.


Zhonghua Li

She received a bachelor’s degree in computer science from Dalian university of technology in 1989 and a master’s degree in computer science from Tianjin University in 2007. She is currently a professor in the Department of Computer Science, Hebei North University, Hebei, China. Her primary research interests are data mining and big data computing and algorithms, along with their applications in several domains.


Xinghua Sun

He is a Ph.D. student at Shanghai Normal University. He is working as a professor in School of Information Science and Engineering at Hebei North University, Zhangjiakou, China. He received a master’s degree from the School of Mathematical Information in Shanghai Normal University in 2007. His current research interests include mobile communication and lighting control networks.


Ting Yan

She received a bachelor’s degree in Engineering from the School of Software and Microelectronics at Northwestern Polytechnical University in 2012 and received a master’s degree in Engineering from the School of Software and Microelectronics at Peking University in 2016. Since 2018, she has been teaching in Hebei North University. Her current research interests include software applications and block-chain.


Dong Yang

He received a bachelor’s degree in Engineering from the School of Computer Science and Technology at Lanzhou Jiaotong University in 2011, and he received a master’s degree in Engineering from the School of Computer Science and Technology at Beijing Jiaotong University. His current research direction is natural language processing.


Guiliang Feng

He received a bachelor’s degree in Computer Applications from Hebei University 2004 and a master’s degree in Software Engineering from Tianjin University in 2007. He is an associate professor of the Department of Information Science and Engineering of Hebei North University, and his current research interests are software engineering and food-safety traceability platforms.


  • 1 M. Alimohammadirokni, A. Emadlou, and J. J. Yuan, "The strategic resources of a gastronomy creative city: the case of San Antonio, Texas," Journal of Gastronomy and Tourism, vol. 5, no. 4, pp. 237-252, 2021.doi:[[[10.3727/216929721x16105303036599]]]
  • 2 H. Huang, Y . Zheng, X. Liu, and J. Li, "The prospects and suggestions on the quality and safety traceability for agricultural products," Science and Technology Management Research, vol. 37, no. 1, pp. 215-220, 2017.custom:[[[-]]]
  • 3 Y . Y uan, S. Li, Q. Wang, J. Tao, L. Kong, X. Tao, M. Gui, and R. Bao, "The vegetable product quality and safety traceability system based on cloud computing," China V egetables, vol. 1, no. 2, pp. 11-16, 2019.custom:[[[-]]]
  • 4 D. He and Z. Shi, "Review on research and application of food safety traceability system," Journal of Agricultural Science and Technology, vol. 21, no. 4, pp. 123-132, 2019.doi:[[[10.13304/j.nykjdb.2018.0326]]]
  • 5 R. Zhao, C. Tang, H. Yang, and F. Yao, "The application of agricultural Internet of Things technology at home and abroad and its enlightenment to planting industry in Guangdong: taking the application in food traceability as an example," Agricultural Science Technology and Information, vol. 11, pp. 67-69, 2020.custom:[[[-]]]
  • 6 T. Ma, H. Wang, M. Wei, T. Lan, J. Wang, B. Bao, Q. Ge, Y . Fang, and X. Sun, "Application of smart-phone use in rapid food detection, food traceability systems, and personalized diet guidance, making our diet more health," Food Research International, vol. 152, article no. 110918, 2022. https://doi.org/10.1016/j.foodres. 2021.110918doi:[[[10.1016/j.foodres.2021.110918]]]
  • 7 Y . Cao, Q. Li, and H. Hu, "Research on the food traceability information supervision strategy based on consumer behavior," Operations Research and Management Science, vol. 29, no. 8, pp. 137-147, 2020.doi:[[[10.12005/orms.2020.0210]]]
  • 8 S. Jiang, G. Han, Z. Si, J. Tian, L. Wang, and G. Qi, "Design and implementation of third-party traceability platform for rice," Transactions of the Chinese Society of Agricultural Engineering, vol. 33, no. 24, pp. 215221, 2017.doi:[[[10.11975/j.issn.1002-6819.2017.24.028]]]
  • 9 A. Ahmad and K. Bailey, "Blockchain in food traceability: a systematic literature review," in Proceedings of 2021 32nd Irish Signals and Systems Conference (ISSC), Athlone, Ireland, 2021, pp. 1-6.doi:[[[10.1109/issc52156.2021.9467848]]]
  • 10 G. P . Agnusdei, B. Coluccia, V . Elia, and P . P . Miglietta, "IoT technologies for wine supply chain traceability: potential application in the Southern Apulia Region (Italy)," Procedia Computer Science, vol. 200, pp. 11251134, 2022.doi:[[[10.1016/j.procs.2022.01.312]]]
  • 11 Y . Lu, P . Li, and H. Xu, "A food anti-counterfeiting traceability system based on blockchain and Internet of Things," Procedia Computer Science, vol. 199, pp. 629-636, 2022.doi:[[[10.1016/j.procs.2022.01.077]]]
  • 12 Y . Dong, Z. Fu, S. Stankovski, S. Wang, and X. Li, "Nutritional quality and safety traceability system for China’s leafy vegetable supply chain based on fault tree analysis and QR code," IEEE Access, vol. 8, pp. 161261-161275, 2020.doi:[[[10.1109/access.2020.3019593]]]
  • 13 Q. Li and Y . Liu, "An image weak edge detection algorithm based on improved Canny operator," Computer Application Research, vol. 37, no. 9, pp. 361-363, 2020.custom:[[[-]]]
  • 14 L. Wang, Y . He, and Z. Wu, "Design of a blockchain-enabled traceability system framework for food supply chains," Foods, vol. 11, no. 5, article no. 744, 2022. https://doi.org/10.3390/foods11050744doi:[[[10.3390/foods11050744]]]
  • 15 K. Nazari, M. J. Ebadi, and K. Berahmand, "Diagnosis of alternaria disease and leafminer pest on tomato leaves using image processing techniques," Journal of the Science of Food and Agriculture, vol. 102, no. 15, pp. 6907-6920, 2022.doi:[[[10.1002/jsfa.12052]]]
  • 16 M. Zheng, S. Zhang, Y . Zhang, and B. Hu, "Construct food safety traceability system for people’s health under the Internet of Things and big data," IEEE Access, vol. 9, pp. 70571-70583, 2021.doi:[[[10.1109/access.2021.3078536]]]