Article Information
Corresponding Author: Yan Ting , yanting@hebeinu.edu.cn
Zhonghua Li, School of Information Science and Engineering, Hebei North University, Zhangjiakou, China, 943690536@qq.com
Xinghua Sun, School of Information Science and Engineering, Hebei North University, Zhangjiakou, China, 1030704295@qq.com
Yan Ting, School of Information Science and Engineering, Hebei North University, Zhangjiakou, China, yanting@hebeinu.edu.cn
Dong Yang, School of Information Science and Engineering, Hebei North University, Zhangjiakou, China, 543662869@qq.com
Guiliang Feng, School of Information Science and Engineering, Hebei North University, Zhangjiakou, China, 6838710@qq.com
Received: June 30 2021
Revision received: June 16 2022
Revision received: September 27 2022
Revision received: November 7 2022
Accepted: November 27 2022
Published (Print): April 30 2023
Published (Electronic): April 30 2023
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.
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.
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.
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.
Plot of number of hits per second for the system during the test period.
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.