A vegetable safety detection QR code storage method and system

By dividing the vegetable safety detection QR code into multiple areas and converting it into a two-dimensional data matrix for partitioned storage, the problem of low security of QR code storage in the existing technology is solved, and the safe storage and traceability functions of data are realized.

CN118520897BActive Publication Date: 2024-10-29INST OF AGRI RESOURCES & ENVIRONMENT HEBEI ACADEMY OF AGRI & FORESTRY SCI
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411000676.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2024-10-29
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

The existing QR code storage method for vegetable safety detection is low in security and can easily be restored or modified, leading to information leakage or tampering.

Method used

The QR code is divided into multiple areas, converted into a two-dimensional data matrix, and partitioned and stored in the storage unit through pointers. The matrix data in each area is processed and replaced to ensure the security of the data and is latched after changes. The original data is provided to the administrator to retrieve the interface.

Benefits of technology

It effectively avoids the restoration and modification of QR codes, improves storage security, and provides a traceability function to facilitate managers to track the source of data modifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118520897B_ABST
    Figure CN118520897B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data storage, and discloses a method and system for storing a two-dimensional code for detecting vegetable safety, comprising the following steps: S1, establishing a two-dimensional coordinate system on a generated two-dimensional code; and dividing the generated two-dimensional code into a plurality of regions; S2, converting each region into a corresponding two-dimensional data matrix, and associating each region with the corresponding two-dimensional data matrix. The two-dimensional code to be stored is divided into a plurality of regions, and each region is converted into a two-dimensional data matrix by the central coordinates of a black unit block in each region, and then the two-dimensional data matrix is ​​processed, and the processed two-dimensional data matrix is ​​used to replace the original two-dimensional data matrix and associated with the corresponding region, and each processed two-dimensional data matrix is ​​stored in a partition, so as to avoid the situation that the stored two-dimensional code is easily restored or modified, thereby causing the two-dimensional code storage information to change.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data storage, and more specifically discloses a vegetable safety detection two-dimensional code storage method and system. Background Art

[0002] As consumers pay more and more attention to food safety issues, vegetables, as an important part of daily diet, have received widespread attention for their safety issues. In order to enable consumers to trace the safety detection of vegetables, a QR code is usually used on the vegetable packaging bag, and consumers can trace the safety detection of vegetables by scanning the code. Before the vegetables are shipped out, the generated traceability QR code is usually stored in the storage unit so that it can be directly printed on the vegetable packaging bag through a printing device when the vegetables are packaged. Since the storage unit stores information in a binary manner of "01" when storing information, and the QR code includes two black and white unit blocks, which just fits the binary storage method of the storage unit, the current QR code storage directly converts the black unit block in the QR code into "1" and the white unit block into "0" for storage. The current QR code storage method is relatively direct and simple. Although this storage method has high storage efficiency, it has low storage security. The QR code is easy to restore and the QR code is easy to be modified, resulting in the modification of the information stored in the QR code, which makes it easy for the QR code to become a carrier of viruses or other bad websites. Summary of the invention

[0003] The present invention mainly provides a vegetable safety detection two-dimensional code storage method and system, which can solve the problem of low storage security of the current two-dimensional code storage method.

[0004] To solve the above technical problems, according to one aspect of the present invention, more specifically, a method for storing a vegetable safety detection QR code comprises the following steps:

[0005] S1. Establishing a two-dimensional coordinate system on the generated two-dimensional code; and dividing the generated two-dimensional code into multiple areas;

[0006] S2, converting each region into a corresponding two-dimensional data matrix, and associating each region with the corresponding two-dimensional data matrix;

[0007] S3, processing the two-dimensional matrix data of each region to obtain a processed two-dimensional data matrix, and replacing the original two-dimensional data matrix associated with each region with each processed two-dimensional data matrix;

[0008] S4. Open up storage areas corresponding to multiple areas of the two-dimensional code in the storage unit, and store the processed two-dimensional data matrix corresponding to each two-dimensional code area in multiple storage areas respectively, and establish pointers to point to the two-dimensional matrix data in each storage area, and finally complete the storage of the two-dimensional code.

[0009] Furthermore, in step S1, a two-dimensional coordinate system is established with any corner point of the generated two-dimensional code as the origin, and the side length of each unit block in the two-dimensional code as the coordinate unit; then, the generated two-dimensional code is divided into a detection area, a positioning line area, a version information area, a format information area and a data storage area.

[0010] Furthermore, in step S2, according to the established two-dimensional coordinate system, the center point coordinates of each black unit block in each area are recorded, and the center point coordinates of each black unit block are arranged according to position to form a two-dimensional data matrix, each element in the matrix contains an x ​​value and a y value, and then the two-dimensional data matrix is ​​associated with the corresponding area.

[0011] Furthermore, in step S3, when processing the two-dimensional data matrix of each region, the number of rows and columns of each two-dimensional data matrix is ​​first obtained, and the x value and y value of each element in each two-dimensional data matrix are obtained, and then the x value and y value of each element are processed as follows: in, , For each element, the processed x and y values ​​are: is the x value of each element i in the lth row, is the y value of each element i in the cth column, l is the row value of the current element, and c is the column value of the current element. , are the maximum row value and the maximum column value, respectively. is the x value of each element i in the two-dimensional data matrix, is the y value of each element i in the two-dimensional data matrix, and N is the position label of the current element in the two-dimensional data matrix; finally, each processed element is overwritten with each corresponding element in the original two-dimensional data matrix, so that the processed two-dimensional data matrix can be obtained.

[0012] Furthermore, when the two-dimensional code is extracted and used, each storage area is found according to the storage area address, and the two-dimensional data matrix corresponding to each area of ​​the stored two-dimensional code is extracted from each storage area through the pointer, and the original two-dimensional data matrix associated with each area can be obtained by reversing step S3, and then according to the elements in each original two-dimensional data matrix, the corresponding position in the two-dimensional coordinate system is filled with black blocks to obtain the corresponding two-dimensional code.

[0013] Furthermore, when the QR code changes, it is stored according to steps S1-S4. In step S4, the two-dimensional matrix data corresponding to each area of ​​the changed QR code is compared with the two-dimensional matrix data of each area of ​​the QR code before the change, and the pointer is changed to the two-dimensional matrix data after the change. The two-dimensional data matrix before the change is locked in the storage area, and an access interface with administrator authority is granted so that the source of data modification can be traced back by directly scanning the code later.

[0014] Furthermore, in step S4, when storage areas corresponding to multiple regions of the two-dimensional code are opened in the storage unit, the size of each opened storage area is: Among them, M is the size of each storage area opened, is the number of changes to each area a of the QR code during each vegetable safety inspection i in history, , are the maximum and minimum number of changes in each area a during the historical vegetable safety detection process, is the modified size of each area a of the QR code during each historical vegetable safety inspection i, Z is the total number of historical vegetable safety inspections, and i represents the order of each historical vegetable safety inspection.

[0015] According to another aspect of the present invention, there is provided a vegetable safety detection two-dimensional code storage system, comprising: a two-dimensional code processing unit, a two-dimensional code conversion unit and a two-dimensional code storage unit;

[0016] The two-dimensional code processing unit is used to divide the generated two-dimensional code into multiple areas and record the coordinates of the center point of the black unit block in each area; the unit includes: a coordinate system establishment module, a two-dimensional code segmentation module and a data acquisition module; the coordinate system establishment module is used to establish a two-dimensional coordinate system with any corner point of the two-dimensional code as the origin and the side length of the unit block as the coordinate system unit; the two-dimensional code segmentation module is used to divide the two-dimensional code into several areas according to the structure of the two-dimensional code; the data acquisition module is used to obtain the coordinate data of the center point of each black unit block in each area;

[0017] Two-dimensional code conversion unit: This unit is composed of an integration module, a two-dimensional data matrix processing module and an association replacement module; the integration module is used to integrate the coordinates of the center points of each black unit block in each area of ​​the two-dimensional code to form a two-dimensional data matrix; the two-dimensional data matrix processing module is used to process the original two-dimensional data to obtain a processed two-dimensional data matrix; the association replacement module is used to first associate the original two-dimensional data matrix with the corresponding two-dimensional code area, and then associate the processed two-dimensional data matrix with the corresponding two-dimensional code area instead of the original two-dimensional data matrix;

[0018] Two-dimensional code storage unit: used to store each processed two-dimensional data matrix separately, and establish a pointer to point to the processed two-dimensional data matrix; the unit includes: a storage area opening module, a pointer establishment module and a latch module; the storage area opening module: used to open multiple storage areas according to the number of processed two-dimensional data matrices, and store each processed two-dimensional data matrix in several storage areas respectively; the pointer establishment module: used to establish a pointer to point to each processed two-dimensional data matrix; the latch module: used to point the pointer to the changed two-dimensional data matrix after the two-dimensional code changes, the corresponding area changes, and the corresponding processed two-dimensional data matrix changes, and latch the previously processed two-dimensional data matrix, and grant the administrator access authority at the same time.

[0019] The beneficial effects of the vegetable safety detection two-dimensional code storage method and system of the present invention are as follows: the two-dimensional code to be stored is divided into multiple areas, and each area is converted into a two-dimensional data matrix by the central coordinates of the black unit block in each area, and then the two-dimensional data matrix is ​​processed, and the original two-dimensional data matrix is ​​replaced with the processed two-dimensional data matrix to be associated with the corresponding area, and each processed two-dimensional data matrix is ​​partitioned and stored, so that the stored two-dimensional code can be avoided from being easily restored or modified, thereby causing the two-dimensional code storage information to change. And when the original two-dimensional data matrix is ​​processed, the x value and y value of each element in the original two-dimensional data matrix are changed, which can not only change the relative position of each unit block, but also change the value of each element, realize double changes, thereby avoiding the situation that the two-dimensional code is easily restored and thus modified. In addition, after the two-dimensional code changes, its corresponding pointing changes, the pointer points to the changed processed two-dimensional data matrix, the original processed two-dimensional data matrix is ​​locked, and an administrator authority call interface is provided, which is convenient for managers to directly extract the two-dimensional code and trace the modification. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0021] Figure 1 A flow chart of a QR code storage method for vegetable safety detection;

[0022] Figure 2 Stores schematic diagrams for storage units. DETAILED DESCRIPTION

[0023] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.

[0024] like Figure 1As shown, the present invention provides a vegetable safety detection QR code storage method, comprising the following steps:

[0025] (1) Taking any corner point of the generated two-dimensional code as the origin and taking the side length of each unit block in the two-dimensional code as the coordinate unit to establish a two-dimensional coordinate system; then, dividing the generated two-dimensional code into a detection area, a positioning line area, a version information area, a format information area and a data storage area.

[0026] (2) According to the established two-dimensional coordinate system, the center point coordinates of each black unit block in each area are recorded, and the center point coordinates of each black unit block are arranged according to the position to form a two-dimensional data matrix. Each element in the matrix contains an x ​​value and a y value, and then the two-dimensional data matrix is ​​associated with the corresponding area.

[0027] (3) Process the two-dimensional matrix data of each region: first obtain the number of rows and columns of each two-dimensional data matrix, and at the same time obtain the x value and y value of each element in each two-dimensional data matrix, and then perform the following processing on the x value and y value of each element: in, , For each element, the processed x and y values ​​are: is the x value of each element i in l, is the y value of each element i in the cth column, l is the row value of the current element, and c is the column value of the current element. , are the maximum row value and the maximum column value, respectively. is the x value of each element i in the two-dimensional data matrix, is the y value of each element i in the two-dimensional data matrix, N is the position number of the current element in the two-dimensional data matrix, the position number starts from 1, starting from the upper left corner of the two-dimensional data matrix, from left to right, the first element is assigned the position number 1, and so on. Each processed element is overwritten with each corresponding element in the original two-dimensional data matrix, so that the processed two-dimensional data matrix can be obtained. And each processed two-dimensional data matrix is ​​used to replace the original associated two-dimensional data matrix of each region.

[0028] (4) In the storage unit, storage areas corresponding to multiple areas of the QR code are opened, and the storage space size of each storage area is given as follows: Among them, M is the size of each storage area opened, is the number of changes to each area a of the QR code during each safety inspection i of vegetables in history, , are the maximum and minimum number of changes in each area a during the historical vegetable safety detection process, is the modified size of each area a of the QR code during each vegetable safety inspection i in history, and Z is the total number of vegetable safety inspections in history. Then, the processed two-dimensional data matrix corresponding to each QR code area is stored in multiple storage areas respectively, and a pointer is established to point to the two-dimensional matrix data in each storage area, and finally the storage of the QR code is completed.

[0029] (5) When extracting and using the two-dimensional code, each storage area is found according to the storage area address, and the two-dimensional data matrix corresponding to each area of ​​the two-dimensional code stored in each storage area is extracted through the pointer, and the original two-dimensional data matrix associated with each area is obtained by reversely operating step S3, and then the corresponding position in the two-dimensional coordinate system is filled with black blocks according to the elements in each original two-dimensional data matrix to obtain the corresponding two-dimensional code.

[0030] (6) When the QR code changes, it is stored according to steps (1) to (4). In step (4), the two-dimensional matrix data corresponding to each area of ​​the QR code after the change is compared with the two-dimensional matrix data of each area of ​​the QR code before the change, and the pointer is changed to the two-dimensional matrix data after the change. The two-dimensional data matrix before the change is locked in the storage area, and the administrator's authority is given a call interface so that the source of the data modification can be directly scanned in the future. When scanning the code to trace the source of the data modification, first go through step (5) to obtain the modified QR code. Then, through the administrator's authority, call the two-dimensional data matrix latched in each storage area. If there is no latched two-dimensional data matrix in the storage area, directly call the two-dimensional data matrix in the storage area to obtain the QR code before the modification. By scanning different QR codes, different information can be obtained. The obtained information is compared to complete the traceability operation of the information modification.

[0031] In addition, the present invention also provides a system for applying the above method, characterized in that it comprises: a two-dimensional code processing unit, a two-dimensional code conversion unit and a two-dimensional code storage unit;

[0032] The two-dimensional code processing unit is used to divide the generated two-dimensional code into multiple areas and record the coordinates of the center point of the black unit block in each area; the unit includes: a coordinate system establishment module, a two-dimensional code segmentation module and a data acquisition module; the coordinate system establishment module is used to establish a two-dimensional coordinate system with any corner point of the two-dimensional code as the origin and the side length of the unit block as the coordinate system unit; the two-dimensional code segmentation module is used to divide the two-dimensional code into several areas according to the structure of the two-dimensional code; the data acquisition module is used to obtain the coordinate data of the center point of each black unit block in each area;

[0033] Two-dimensional code conversion unit: This unit is composed of an integration module, a two-dimensional data matrix processing module and an association replacement module; the integration module is used to integrate the coordinates of the center points of each black unit block in each area of ​​the two-dimensional code to form a two-dimensional data matrix; the two-dimensional data matrix processing module is used to process the original two-dimensional data to obtain a processed two-dimensional data matrix; the association replacement module is used to first associate the original two-dimensional data matrix with the corresponding two-dimensional code area, and then associate the processed two-dimensional data matrix with the corresponding two-dimensional code area instead of the original two-dimensional data matrix;

[0034] Two-dimensional code storage unit: used to store each processed two-dimensional data matrix separately, and establish a pointer to point to the processed two-dimensional data matrix; the unit includes: a storage area development module, a pointer establishment module and a latch module; the storage area development module: used to open multiple storage areas according to the number of processed two-dimensional data matrices, and store each processed two-dimensional data matrix in several storage areas respectively; the pointer establishment module: used to establish a pointer to point to each processed two-dimensional data matrix; the latch module: used to point the pointer to the changed two-dimensional data matrix after the two-dimensional code changes, the corresponding area changes, and the corresponding processed two-dimensional data matrix changes, and latch the previously processed two-dimensional data matrix, and grant the administrator access authority. The storage process is as follows. Figure 2 shown.

[0035] Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Changes, modifications, additions or substitutions made by ordinary technicians in this technical field within the essential scope of the present invention also fall within the protection scope of the present invention.

Claims

1. A method for storing a two-dimensional code for vegetable safety detection, characterized in that: The following steps are involved: S1. Establishing a two-dimensional coordinate system on the generated two-dimensional code; and dividing the generated two-dimensional code into multiple areas; S2, converting each region into a corresponding two-dimensional data matrix, and associating each region with the corresponding two-dimensional data matrix, specifically: according to the established two-dimensional coordinate system, recording the center point coordinates of each black unit block in each region, and arranging the center point coordinates of each black unit block according to the position to form a two-dimensional data matrix, each element in the matrix contains an x ​​value and a y value, and then associating the two-dimensional data matrix with the corresponding region; S3, processing the two-dimensional matrix data of each region to obtain a processed two-dimensional data matrix, and replacing the original two-dimensional data matrix associated with each region with each processed two-dimensional data matrix; When processing the two-dimensional data matrix of each region, first obtain the number of rows and columns of each two-dimensional data matrix, and at the same time obtain the x value and y value of each element in each two-dimensional data matrix, and then perform the following processing on the x value and y value of each element: in, , For each element, the processed x and y values ​​are: is the x value of each element i in the lth row, is the y value of each element i in the cth column, l is the row value of the current element, and c is the column value of the current element. , are the maximum row value and the maximum column value, respectively. is the x value of each element i in the two-dimensional data matrix, is the y value of each element i in the two-dimensional data matrix, and N is the position number of the current element in the two-dimensional data matrix; finally, each processed element is overwritten with each corresponding element in the original two-dimensional data matrix, so that the processed two-dimensional data matrix can be obtained; S4. Opening storage areas corresponding to the multiple regions of the two-dimensional code in the storage unit, and storing the processed two-dimensional data matrix corresponding to each two-dimensional code region in the multiple storage areas respectively, and establishing pointers to point to the two-dimensional matrix data in each storage area, and finally completing the storage of the two-dimensional code; when opening storage areas corresponding to the multiple regions of the two-dimensional code in the storage unit, the size of each storage area opened is: Among them, M is the size of each storage area opened, is the number of changes to each area a of the QR code during each vegetable safety inspection i in history, , are the maximum and minimum number of changes in each area a during the historical vegetable safety detection process, is the modified size of each area a of the QR code during each historical vegetable safety inspection i, Z is the total number of historical vegetable safety inspections, and i represents the order of each historical vegetable safety inspection.

2. The vegetable safety detection two-dimensional code storage method according to claim 1, characterized in that: In step S1, any corner point of the generated two-dimensional code is used as the origin, and a two-dimensional coordinate system is established with the side length of each unit block in the two-dimensional code as the coordinate unit; then, the generated two-dimensional code is divided into a detection area, a positioning line area, a version information area, a format information area and a data storage area.

3. The vegetable safety detection two-dimensional code storage method according to claim 1, characterized in that: When the two-dimensional code is extracted and used, each storage area is found according to the storage area address, and the two-dimensional data matrix corresponding to each area of ​​the stored two-dimensional code is extracted from each storage area through the pointer, and the original two-dimensional data matrix associated with each area can be obtained by reversing step S3, and then the corresponding positions in the two-dimensional coordinate system are filled with black blocks according to the elements in each original two-dimensional data matrix to obtain the corresponding two-dimensional code.

4. The vegetable safety detection two-dimensional code storage method according to claim 1, characterized in that: When the QR code changes, it is stored according to steps S1-S4. In step S4, the two-dimensional matrix data corresponding to each area of ​​the changed QR code is compared with the two-dimensional matrix data of each area of ​​the QR code before the change, and the pointer is changed to the two-dimensional matrix data after the change. The two-dimensional data matrix before the change is locked in the storage area, and an access interface with administrator authority is granted so that the source of data modification can be traced back by scanning the code directly later.

5. A system using the vegetable safety detection two-dimensional code storage method according to any one of claims 1 to 4, characterized in that: include: A two-dimensional code processing unit, a two-dimensional code conversion unit and a two-dimensional code storage unit; The two-dimensional code processing unit is used to divide the generated two-dimensional code into multiple areas and record the coordinates of the center point of the black unit block in each area; the unit includes: a coordinate system establishment module, a two-dimensional code segmentation module and a data acquisition module; the coordinate system establishment module is used to establish a two-dimensional coordinate system with any corner point of the two-dimensional code as the origin and the side length of the unit block as the coordinate system unit; the two-dimensional code segmentation module is used to divide the two-dimensional code into several areas according to the structure of the two-dimensional code; the data acquisition module is used to obtain the coordinate data of the center point of each black unit block in each area; Two-dimensional code conversion unit: This unit is composed of an integration module, a two-dimensional data matrix processing module and an association replacement module; the integration module is used to integrate the coordinates of the center points of each black unit block in each area of ​​the two-dimensional code to form a two-dimensional data matrix; the two-dimensional data matrix processing module is used to process the original two-dimensional data to obtain a processed two-dimensional data matrix; the association replacement module is used to first associate the original two-dimensional data matrix with the corresponding two-dimensional code area, and then associate the processed two-dimensional data matrix with the corresponding two-dimensional code area instead of the original two-dimensional data matrix; Two-dimensional code storage unit: used to store each processed two-dimensional data matrix separately, and establish a pointer to point to the processed two-dimensional data matrix; the unit includes: a storage area opening module, a pointer establishment module and a latch module; the storage area opening module: used to open multiple storage areas according to the number of processed two-dimensional data matrices, and store each processed two-dimensional data matrix in several storage areas respectively; the pointer establishment module: used to establish a pointer to point to each processed two-dimensional data matrix; the latch module: used to point the pointer to the changed two-dimensional data matrix after the two-dimensional code changes, the corresponding area changes, and the corresponding processed two-dimensional data matrix changes, and latch the previously processed two-dimensional data matrix, and grant the administrator access authority at the same time.

Citation Information

Patent Citations

  • Safe two-dimensional code manufacture method and decoding method, and safe two-dimensional code identifier

    CN105550730A

  • Dot matrix two-dimensional code coding and reading method

    CN105894067A

  • Method for reconstructing two-dimensional code based on Otsu method

    CN107545259A

  • Two-dimensional code coding method and device

    CN107563475A

  • Color code encoding and decoding method, system and device

    CN108629391A