Image consistency detection method, device, storage device and readable storage medium
By comparing the summary of the image information to be written sent by the monitoring device and the hash value of the image to be detected in the storage device, the picture consistency is directly judged, and the problem of low detection efficiency in the prior art is solved, and efficient picture consistency detection is achieved .
Patent Information
- Application Number
- CN202210248264.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-14
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2042-03-14
AI Technical Summary
The existing image consistency detection technology is inefficient and requires downloading and computing a large number of image information summary, resulting in a long detection time.
By obtaining the information summary of multiple images to be written by the monitoring device, calculate the first hash value and compare it with the second hash value of the image to be detected to judge the image consistency and avoid downloading and calculation Information summary of the original image.
Shorten the detection time, improve the detection efficiency, and reduce the load on the storage device.
Smart Images

Figure CN114581808B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of security monitoring, and in particular to a method, device, storage device and readable storage medium for detecting image consistency. Background Art
[0002] In the current security monitoring field, the image data collected by the monitoring equipment needs to be saved to the storage device, so the storage device is required to have the ability to record a large number of different types of images, high-speed reading and writing, and high reliability. Among them, high reliability is mainly reflected in the fact that the image after writing to the storage device is consistent with the image before writing, without omissions, that is, the image is not damaged in the process of writing to the storage device, so detecting the consistency of the image written to the storage device, that is, detecting whether the image is damaged in the process of writing to the storage device, plays an important role in improving the reliability of storage devices used in the security monitoring field.
[0003] The existing image consistency detection technology usually downloads the image written in the storage device first, calculates the message digest, then downloads the corresponding original image from the original image library and calculates the message digest. Finally, by comparing the message digests of the two, it is determined whether the image is damaged during the process of writing to the storage device. Due to the large amount of images written to the storage device, this detection method requires a lot of time to download the images and calculate the message digest, and there is a problem of low detection efficiency. Summary of the invention
[0004] In order to overcome the shortcomings of the prior art, the embodiments of the present invention provide a method, apparatus, storage device and readable storage medium for detecting image consistency, so as to improve the efficiency of image consistency detection. The specific technical solutions are as follows:
[0005] In a first aspect, an embodiment of the present invention provides a method for detecting image consistency, which is applied to a storage device, wherein the storage device is communicatively connected to a monitoring device, and the method includes:
[0006] Obtaining a first root hash value of the original picture, wherein the first root hash value is determined according to information summaries of multiple pictures to be written in the first picture group sent by the monitoring device, and the original picture is any one of the multiple pictures to be written;
[0007] Reading a second root hash value of a to-be-detected picture, wherein the to-be-detected picture includes a first data area and a second data area, the first data area is used to store the original picture, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area;
[0008] According to the second root hash value and the first root hash value, it is determined whether the image to be detected is consistent with the original image.
[0009] Optionally, before the step of obtaining the first root hash value of the original image, the method further includes:
[0010] Calculate the information summary of each picture to be written;
[0011] Determining a root hash value of the first picture group according to information summaries of all the pictures to be written;
[0012] The root hash value of the first picture group is used as the first root hash value of the original picture.
[0013] Optionally, the multiple pictures to be written are pre-sorted in chronological order of reception time, each picture to be written is taken as a node, and the information summary of each picture to be written is taken as the node value of each node, and the step of determining the root hash value of the first picture group according to the information summary of all the pictures to be written includes:
[0014] Divide all the nodes in pairs in sequence to obtain at least one hash group, and each of the nodes belongs to only one hash group;
[0015] Calculate the hash value of each hash group according to the node value of each node in each hash group;
[0016] If the number of the hash groups is one, taking the hash value of the hash group as the root hash value of the first picture group;
[0017] If there are multiple hash groups, each hash group is taken as a node, and the hash value of each hash group is taken as the node value of each node, and the above steps are repeated until the root hash value of the first picture group is obtained.
[0018] Optionally, the step of dividing all the nodes in pairs in sequence to obtain at least one hash group includes:
[0019] Get the number of all the nodes;
[0020] If the number of the nodes is an odd number, the last node of all the nodes is divided into one of the hash groups.
[0021] Optionally, the multiple pictures to be written are pre-sorted according to the receiving time and written in sequence, the picture to be detected is any one of the multiple pictures written in the second picture group, and the method further includes:
[0022] Obtaining the information summary of the first picture written into the second picture group and the information summary of the last picture written into the second picture group;
[0023] If the information summary of the first written picture is different from the information summary of the first picture to be written in the first picture group, and / or the information summary of the last written picture is different from the information summary of the last picture to be written in the first picture group, then stop judging whether the picture to be detected is consistent with the original picture.
[0024] Optionally, the multiple pictures to be written are pre-sorted according to the order of receiving time and written in sequence, and the method further includes:
[0025] When an interruption event occurs when writing the first picture group, the order of the last written picture to be written in the first picture group is determined so that after the interruption event ends, the pictures to be written after the order in the first picture group continue to be written according to the order.
[0026] Optionally, the step of determining whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value includes:
[0027] Determine whether the second root Hash value is the same as the first root Hash value;
[0028] If they are the same, it is determined that the image to be detected is consistent with the original image.
[0029] In a second aspect, an embodiment of the present invention provides a picture consistency detection device, which is applied to a storage device, wherein the storage device is communicatively connected to a monitoring device, and the device includes:
[0030] an acquisition module, configured to acquire a first root hash value of the original image, wherein the first root hash value is determined according to information summaries of a plurality of images to be written in a first image group sent by the monitoring device, and the original image is any one of the plurality of images to be written;
[0031] A reading module, configured to read a second root hash value of a to-be-detected picture, wherein the to-be-detected picture includes a first data area and a second data area, the first data area is used to store the original picture, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area;
[0032] A judging module is used to judge whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value.
[0033] In a third aspect, an embodiment of the present invention provides a storage device comprising: a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the method described in the first aspect when calling the computer program.
[0034] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the method described in the first aspect.
[0035] Compared with the prior art, the embodiment of the present invention provides a method, device, storage device and readable storage medium for detecting consistency of an image. First, the first root hash value of the original image is obtained, wherein the first root hash value is determined according to the information summary of multiple images to be written in the first image group sent by the monitoring device, and the original image is any one of the multiple images to be written. Then, the second root hash value of the image to be detected is read, wherein the image to be detected includes a first data area and a second data area, the first data area is used to store the original image, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area; finally, according to the second root hash value and the first root hash value, it is judged whether the image to be detected is consistent with the original image. Since the embodiment of the present invention writes the original image and the first root hash value determined based on the information summary of multiple images to be written in the first image group where the original image is located into the storage device at the same time, the image to be detected is obtained. When judging the consistency between the image to be detected and the original image, only the second root hash value read from the image to be detected is needed, and compared with the first root hash value, so as to avoid spending a lot of time to download the original image and calculate the information summary, thereby shortening the detection time and improving the detection efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0037] Figure 1 A specific example diagram of an application scenario provided by an embodiment of the present invention;
[0038] Figure 2 A schematic block diagram of the structure of a storage device provided by an embodiment of the present invention;
[0039] Figure 3 A schematic diagram of a flow chart of a method for detecting image consistency provided by an embodiment of the present invention;
[0040] Figure 4A flowchart of a method for determining a first root hash value provided by an embodiment of the present invention;
[0041] Figure 5 A schematic flow chart of a method for determining a root hash value of a first picture group provided by an embodiment of the present invention;
[0042] Figure 6 A specific example diagram of determining a root hash value of a first picture group provided by an embodiment of the present invention;
[0043] Figure 7 A schematic flow chart of a method for determining whether to stop detecting the consistency between a to-be-detected image and an original image provided by an embodiment of the present invention;
[0044] Figure 8 A schematic diagram of a flow chart of another method for determining image consistency provided by an embodiment of the present invention;
[0045] Fig. 9 A block diagram of a device for detecting image consistency according to an embodiment of the present invention.
[0046] Icons: 100 - storage device; 110 - memory; 120 - processor; 200 - monitoring device; 300 - image consistency detection device; 301 - acquisition module; 302 - reading module; 303 - judgment module; 304 - determination module. DETAILED DESCRIPTION
[0047] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0048] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0050] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0051] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0052] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0053] In order to improve the detection efficiency of image consistency, the common practice is to adopt a random sampling inspection method, but this method cannot guarantee the comprehensiveness and accuracy of the detection results. In view of this, the embodiments of the present invention provide an image consistency inspection method, apparatus, storage device and readable storage medium to improve the detection efficiency while ensuring the comprehensiveness and accuracy of the detection results, which will be described in detail below.
[0054] Please refer to Figure 1 , Figure 1 A specific example diagram of an application scenario provided for an embodiment of the present invention, wherein a storage device 100 is communicatively connected with a monitoring device 200, the storage device 100 may be an independent computer device, or a cluster of multiple computer devices, or a storage array, etc., the monitoring device 200 may be a network camera, and the monitoring device 200 sends the collected image data to the storage device 100 for storage.
[0055] exist Figure 1 Based on this, the embodiment of the present invention also provides a Figure 1 For a schematic block diagram of the structure of the storage device 100, please refer to Figure 2 , Figure 2 The present invention provides a schematic block diagram of a storage device 100 . The storage device 100 may include a memory 110 and a processor 120 .
[0056] The processor 120 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the image consistency detection method provided in the following method embodiment.
[0057] The memory 110 may be a ROM or other types of static storage devices that can store static information and instructions, a RAM or other types of dynamic storage devices that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 110 may exist independently and be connected to the processor 120 via a communication bus. The memory 110 may also be integrated with the processor 120. Among them, the memory 110 is used to store machine executable instructions for executing the scheme of the present application. The processor 120 is used to execute the machine executable instructions stored in the memory 110 to implement the following method embodiments.
[0058] Since the storage device 100 provided in the embodiment of the present invention is another implementation form of the image consistency detection method provided in the following method embodiment, the technical effects that can be obtained can refer to the following method embodiment and will not be repeated here.
[0059] Please refer to Figure 3 , Figure 3 A schematic flow chart of a method for detecting image consistency according to an embodiment of the present invention is provided. The method includes steps S101, S102 and S103.
[0060] S101, obtaining the first hash value of the original image.
[0061] The first root hash value is determined based on information summaries of multiple pictures to be written in the first picture group sent by the monitoring device, and the original picture is any one of the multiple pictures to be written.
[0062] In an embodiment of the present invention, the step of storing pictures from the monitoring device includes "receiving" and "writing". The pictures to be written are obtained by the monitoring device completing the "receiving" operation. As a specific implementation method, the storage device can divide the received pictures to be written into at least one picture group according to a preset number according to the order of reception time. Each picture group corresponds to a root hash value. The root hash value of each picture group is obtained by performing a hash operation based on the information summary of all pictures to be written in the picture group. The root hash value of each picture to be written in each picture group is the root hash value corresponding to the picture group.
[0063] The first picture group can be any one of the divided picture groups. A hash operation is performed according to the information summary of all pictures to be written in the first picture group to obtain the first root hash value corresponding to the first picture group. The root hash values of all pictures to be written in the first picture group are the first root hash value. When the "write" operation is subsequently performed, the first root hash value of the first picture group is synchronously recorded in the database table. In addition, a document can be used to record the storage path of the write result corresponding to each picture to be written, and the document name and storage address of the document are also synchronously recorded in the database table.
[0064] Since there are multiple picture groups, each picture group can be numbered. When recording the root hash value of each picture group in the database table, the number of each picture group is also recorded. At the same time, each picture group corresponds to a document, and its document name is set to the number of the picture group, which records the storage path of the write result corresponding to each picture to be written in the picture group. For example, a picture group is numbered 03, and the document name of its corresponding document is also 03. In addition, after all the pictures to be written in each picture group are sorted in chronological order according to the reception time, the information summaries of the first and last pictures to be written are also recorded in the database table. Specifically, for any picture group, when the storage device performs the "write" operation, the information recorded synchronously in the database table is shown in the following table.
[0065] Group_id Picture group number Root_hash Root Hash File_name Image path file name File_loc Image path document storage address First_pic_MD5 Information summary of the first image to be written Last_pic_MD5 Information summary of the last picture to be written
[0066] The original picture is any one of the multiple pictures to be written in the first picture group. It can be understood that the first root hash value of the original picture can be obtained from the database table according to the number of the first picture group to which the original picture belongs.
[0067] S102, reading the second hash value of the image to be detected.
[0068] The image to be detected includes a first data area and a second data area, the first data area is used to store the original image, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area;
[0069] In an embodiment of the present invention, the storage device performs a "write" operation on the picture to be written and its first root hash value, and obtains the written picture. In the data area of the written picture, the space occupied by the picture to be written is used as the first data area, and the space occupied by the first root hash value is used as the second data area.
[0070] Get the written picture. Generally, the data format of the written picture includes a summary area and a data area, wherein the data area is used to store the picture to be written and the first root hash value, that is, the picture to be written and the first root hash value are both written into the data area, wherein the space occupied by the picture to be written is used as the first data area, and the space occupied by the first root hash value is used as the second data area.
[0071] Since the original picture is any one of the multiple pictures to be written, it can be understood that the picture to be detected is a written picture corresponding to the original picture. According to the storage path recorded in the document corresponding to the first picture group, the picture to be detected can be read, and then the information in the second data area of the picture to be detected, that is, the second root hash value, can be read.
[0072] S103: judging whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value.
[0073] In an embodiment of the present invention, the storage path of the write result corresponding to each picture to be written recorded in the document can be obtained according to the document name and storage address of the document corresponding to the first picture group obtained from the database table, the picture to be detected is extracted, and the second root hash value is read from the second data area of the picture to be detected. At the same time, the first root hash value of the original picture corresponding to the picture to be detected is obtained from the database table, and then according to the second root hash value and the first root hash value, it is determined whether an error occurs when the storage device performs the "write" operation, resulting in the inconsistency between the obtained picture to be detected and the corresponding original picture.
[0074] The above method provided by the embodiment of the present invention has the beneficial effect that, by simultaneously writing the original image and the first root hash value determined based on the information digest of multiple images to be written in the first image group where the original image is located into the storage device, a picture to be detected is obtained. When judging the consistency between the picture to be detected and the original image, only the second root hash value needs to be read from the picture to be detected and compared with the first root hash value, thereby avoiding wasting a lot of time to download the original image and calculate the information digest, thereby shortening the detection time and improving the detection efficiency.
[0075] based on Figure 3 The embodiment of the present invention also provides a specific implementation method for determining the first root hash value, please refer to Figure 4 , Figure 4 A flowchart of a method for determining a first root hash value provided by an embodiment of the present invention is provided. The method includes steps S201, S202 and step S203.
[0076] S201, calculating the information summary of each picture to be written.
[0077] In the embodiment of the present invention, the information digest of the image to be written refers to the data of the image to be written, obtained by applying the MD5 information digest algorithm (Message Digest Algorithm MD5). For example, for the image to be written with a data length of L bits, it is first padded bit by bit so that its final bit number can be grouped with 512 bits, and each group is divided into sixteen 32-bit sub-groups. After four rounds of loop operation, four 32-bit groups are output. After the four 32-bit groups are cascaded, a 128-bit hash value will be generated. The 128-bit hash value is then converted into hexadecimal to obtain a character string with a length of 32 bytes, which is the information digest of the image to be written.
[0078] S202: Determine a root hash value of a first picture group according to information summaries of all pictures to be written.
[0079] In the embodiment of the present invention, the information summary of each picture to be written is a string with a length of 32 bytes. Based on the information summaries of all pictures to be written, one or more hash operations are performed to obtain the root hash value of the first picture group.
[0080] S203: Use the root hash value of the first picture group as the first root hash value of the original picture.
[0081] In the embodiment of the present invention, since the original picture is any one of the multiple pictures to be written in the first picture group, the hash value of the first picture group can be used as the first root hash value of the original picture.
[0082] based on Figure 4 The embodiment of the present invention also provides a specific implementation method for determining the root hash value of the first picture group, please refer to Figure 5 , Figure 5 A schematic flow chart of a method for determining a root hash value of a first picture group provided by an embodiment of the present invention, step S202 includes sub-steps S202-1 to S202-4.
[0083] S202-1, divide all nodes into pairs in turn to obtain at least one hash group, and each node belongs to only one hash group.
[0084] In an embodiment of the present invention, multiple pictures to be written in the first picture group are pre-sorted in chronological order of reception time, each sorted picture to be written is used as a node, and its information summary is used as the node value, and then the nodes are divided into a hash group in pairs in turn. In particular, each node can only be divided into one hash group, that is, there is no intersection of nodes in any two hash groups. For example, the sorted nodes are: node 01, node 02, node 03 and node 04. Node 01 and node 02 are divided into hash group 1, and node 03 and node 04 are divided into hash group 2.
[0085] Specifically, the implementation process of sub-step S202-1 is as follows:
[0086] First, get the number of all nodes;
[0087] If the number of nodes is odd, the last node of all nodes is divided into a hash group.
[0088] In an embodiment of the present invention, since all nodes are divided into a hash group in pairs, and there is no intersection between any two hash groups, the division of the hash groups can be successfully completed when the number of nodes is an even number, but when the number of nodes is an odd number, the last node will be divided into a hash group alone. For example, the sorted nodes are: node 01, node 02, node 03, node 04 and node 05. Node 01 and node 02 are divided into hash group 1, node 03 and node 04 are divided into hash group 2, and node 05 is divided into hash group 3.
[0089] S202-2, calculating the hash value of each hash group according to the node value of each node in each hash group.
[0090] In the embodiment of the present invention, each hash group includes two nodes, and the node values of the two nodes are merged into a string. The hash value of each hash group refers to the result of hashing the above string.
[0091] S202-3: If the number of hash groups is one, use the hash value of the hash group as the root hash value of the first picture group.
[0092] In the embodiment of the present invention, if there is only one hash group divided by two nodes, a hash value obtained based on the node value of the hash group may be used as the root hash value of the first picture group.
[0093] S202-4, if there are multiple hash groups, take each hash group as a node, and use the hash value of each hash group as the node value of each node, and repeat the above steps until the root hash value of the first picture group is obtained.
[0094] In an embodiment of the present invention, if there are multiple hash groups divided by nodes in pairs, each hash group is regarded as a node, and its hash value is used as the node value, and the above steps S202-1, S202-2 and S203 are repeated until only one hash group is divided, and the hash value of the hash group is used as the root hash value of the first picture group.
[0095] For example, the number of pictures to be written in the first picture group is 5. After the 5 pictures to be written are sorted in order of reception time, each picture to be written is taken as a node to obtain nodes 01, 02, 03, 04 and 05, such as Figure 6 As shown, first, node 01 and node 02 are divided into hash group 1, node 03 and node 04 are divided into hash group 2, and node 05 is divided into hash group 3, and the hash values of hash group 1, hash group 2 and hash group 3 are calculated respectively; then, hash group 1, hash group 2 and hash group 3 are respectively regarded as a node to obtain node 11, node 12 and node 13, node 11 and node 12 are divided into hash group 4, node 13 is divided into hash group 5, and the hash values of hash group 4 and hash group 5 are respectively calculated; finally, hash group 4 and hash group 5 are respectively regarded as a node to obtain node 21 and node 22, node 21 and node 22 are divided into hash group 6, the hash value of hash group 6 is calculated, and hash group 6 is used as the root hash value of the first picture group. In the above process, the node value of each node satisfies the following formula:
[0096] Node[0][i]=MD5(data[i]),i=1,2,…,5
[0097]
[0098]
[0099]
[0100]
[0101] Root=hash(Node[2][1]+Node[2][2])
[0102] Among them, Node[j][i] refers to the node value of node ij, for example, Node[0][1] represents the node value of node 01, data[i] refers to the data of the i-th picture to be written, and Root is the root hash value of the first picture group.
[0103] Considering that abnormal events in the process of reading the image to be detected by the storage device, such as misalignment, will affect the accuracy of the subsequent consistency test results between the image to be detected and the original image, before executing step S103, it is necessary to determine whether the image to be detected is read normally to decide whether to continue to detect the consistency between the image to be detected and the original image. Figure 7 , Figure 7 A flowchart of a method for determining whether to stop detecting the consistency between a to-be-detected image and an original image is provided in an embodiment of the present invention. The method includes steps S301 and S302.
[0104] Step S301, obtaining the information summary of the first written picture in the second picture group and the information summary of the last written picture.
[0105] In an embodiment of the present invention, the second picture group includes multiple written pictures, and each written picture is obtained by the storage device performing a "write" operation on each picture to be written in the first picture group in sequence according to the receiving time, and each written picture is named as the information summary of its corresponding picture to be written, and all written pictures are also sorted in the order of writing time. According to the naming of the first written picture and the last written picture in the second picture group, the information summary of the first written picture and the information summary of the last written picture are obtained.
[0106] Step S302: If the information summary of the first written picture is different from the information summary of the first picture to be written in the first picture group, and / or the information summary of the last written picture is different from the information summary of the last picture to be written in the first picture group, then stop judging whether the picture to be detected is consistent with the original picture.
[0107] In the embodiment of the present invention, according to the serial number of the first picture group, the information summary of the first picture to be written and the information summary of the last picture to be written can be obtained from the database table.
[0108] The picture to be detected is any one of the multiple pictures that have been written in the second picture group. If the information summary of the first written picture in the second picture group is the same as the information summary of the first picture to be written in the first picture group, and at the same time, the information summary of the last written picture in the second picture group is the same as the information summary of the last picture to be written in the first picture group, then it is characterized that the picture to be detected is read normally, and the judgment of whether the picture to be detected is consistent with the original picture can be continued.
[0109] It can be understood that if the information summary of the first picture written in the second picture group is different from the information summary of the first picture to be written in the first picture group, and / or the information summary of the last picture written in the second picture group is different from the information summary of the last picture to be written in the first picture group, it indicates that there is an abnormality in the process of reading the picture to be detected by the storage device. At this time, it is necessary to stop judging whether the picture to be detected is consistent with the original picture.
[0110] In addition, when the storage device is performing a "write" operation on multiple pictures to be written in the first picture group, if a restart, service stoppage, or the number of normal nodes does not meet the erasure requirement occurs, the "write" operation will be interrupted. To prevent the subsequent inability to determine the consistency between the picture to be detected and the original picture due to the interruption of "write", the storage device needs to perform the following operations when an interruption event caused by the above reasons occurs:
[0111] When an interruption event occurs when writing the first picture group, the order of the last written picture to be written in the first picture group is determined so that after the interruption event ends, the pictures to be written after the order in the first picture group continue to be written according to the order.
[0112] In the embodiment of the present invention, the order of the picture to be written refers to the position in the first picture group. For example, the order of the picture to be written is 5, which means it is the 5th picture in the first picture group. The storage device records the position of the last picture to be written in the first picture group written before the interruption occurs in the database table, so that when the interruption ends, all the remaining pictures to be written in the first picture group can continue to be written.
[0113] As a specific implementation method, the storage device can create a new database table as shown in the following table for the "write" interruption situation, which is used to record the order of the last written picture to be written in the first picture group, as well as the number of the first picture group, the interruption event status and other information when an interruption event occurs.
[0114] Interrupt_Group_id The number of the picture group where the interruption occurred Last_pic_Loc The order of the last pictures written Status Interrupt event status
[0115] It should be noted that before the interruption event ends, the value of the interruption event status Status in the database table is 0. After the interruption event ends and the "write" operation of the remaining pictures to be written in the picture group is completed, the value of the interruption event status Status is modified to 1.
[0116] based on Figure 3 The embodiment of the present invention also provides a specific implementation method for determining whether the image to be detected is consistent with the original image. Please refer to Figure 8 , Figure 8 This is a flow chart of another method for determining image consistency provided by an embodiment of the present invention, wherein step S103 includes sub-steps S103 - 1 , S103 - 2 and S103 - 3 .
[0117] S103-1, determine whether the second root hash value is the same as the first root hash value.
[0118] In the embodiment of the present invention, it can be determined whether an error occurs when the storage device performs a "write" operation, resulting in damage to the original image, by judging whether the second root hash value is the same as the first root hash value.
[0119] S103-2: If they are the same, it is determined that the image to be detected is consistent with the original image.
[0120] In an embodiment of the present invention, if the second root hash value is the same as the first root hash value, it means that the original image is not damaged during the process of being written to the storage device, and the image to be detected obtained by the storage device performing a "write" operation on the original image is consistent with the original image.
[0121] S103-3, if they are not the same, it is determined that the image to be detected is inconsistent with the original image.
[0122] In an embodiment of the present invention, if the second root hash value is different from the first root hash value, it means that the original image is damaged in the process of being written to the storage device, and the image to be detected obtained by the storage device performing a "write" operation on the original image is inconsistent with the original image.
[0123] In order to execute the corresponding steps in the above embodiment and various possible implementations, an implementation method of the image consistency detection device 300 is given below. Fig. 9 , Fig. 9 It is a block diagram of a picture consistency detection device 300 provided in an embodiment of the present invention. It should be noted that the basic principle and technical effects of the picture consistency detection device 300 provided in an embodiment of the present invention are the same as those in the above embodiment, and for the sake of brief description, the embodiment of the present invention is not mentioned.
[0124] The image consistency detection device 300 includes an acquisition module 301 , a reading module 302 , a judgment module 303 and a determination module 304 .
[0125] The acquisition module 301 is used to obtain a first root hash value of the original picture, wherein the first root hash value is determined according to information summaries of multiple pictures to be written in a first picture group sent by the monitoring device, and the original picture is any one of the multiple pictures to be written.
[0126] A reading module 302 is used to read a second root hash value of the image to be detected, wherein the image to be detected includes a first data area and a second data area, the first data area is used to store the original image, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area;
[0127] The judgment module 303 is used to judge whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value.
[0128] The determination module 304 is configured to calculate the information digest of each picture to be written; determine the root hash value of the first picture group according to the information digests of all pictures to be written; and use the root hash value of the first picture group as the first root hash value of the original picture.
[0129] As an implementation method, multiple pictures to be written are pre-sorted in chronological order according to the reception time, and each picture to be written is regarded as a node, and the information summary of each picture to be written is used as the node value of each node. When the determination module 304 is used to determine the root hash value of the first picture group according to the information summary of all pictures to be written, it is specifically used to divide all the nodes in pairs in turn to obtain at least one hash group, and each node belongs to only one hash group; according to the node value of each node in each hash group, the hash value of each hash group is calculated; if the number of hash groups is one, the hash value of the hash group is used as the root hash value of the first picture group; if the number of hash groups is multiple, each hash group is regarded as a node, and the hash value of each hash group is used as the node value of each node, and the above steps are repeated until the root hash value of the first picture group is obtained.
[0130] As an implementation manner, when the determination module 304 is used to divide all nodes in pairs in sequence to obtain at least one hash group, it is also specifically used to obtain the number of all nodes; if the number of nodes is an odd number, the last node of all nodes is divided into a hash group.
[0131] As an implementation method, multiple pictures to be written are pre-sorted according to the chronology of reception and written in sequence. The determination module 304 is also used to determine the order of the last picture to be written in the first picture group when an interruption event occurs when writing the first picture group, so that after the interruption event ends, the pictures to be written after the order in the first picture group continue to be written according to the order.
[0132] As an implementation method, multiple pictures to be written are pre-sorted according to the chronological order of reception and written in sequence, the picture to be detected is any one of the multiple pictures already written in the second picture group, and the judgment module 303 is also used to obtain the information summary of the first picture already written in the second picture group, and the information summary of the last picture already written; if the information summary of the first picture already written is different from the information summary of the first picture to be written in the first picture group, and / or the information summary of the last picture already written is different from the information summary of the last picture to be written in the first picture group, then stop judging whether the picture to be detected is consistent with the original picture.
[0133] As an implementation method, when the judgment module 303 is used to judge whether the image to be detected is consistent with the original image based on the second root hash value and the first root hash value, it is specifically used to judge whether the second root hash value is the same as the first root hash value; if they are the same, it is determined that the image to be detected is consistent with the original image.
[0134] The embodiment of the present invention further provides a readable storage medium containing computer executable instructions, and when the computer executable instructions are executed, they can be used to perform the relevant operations in the image consistency detection method provided by the above method embodiment.
[0135] In summary, an image consistency detection method, device, storage device and readable storage medium provided by an embodiment of the present invention, first, obtain the first root hash value of the original image, wherein the first root hash value is determined according to the information summary of multiple images to be written in the first image group sent by the monitoring device, and the original image is any one of the multiple images to be written. Then, read the second root hash value of the image to be detected, wherein the image to be detected includes a first data area and a second data area, the first data area is used to store the original image, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area; finally, according to the second root hash value and the first root hash value, determine whether the image to be detected is consistent with the original image. Since the embodiment of the present invention writes the original image and the first root hash value determined based on the information summary of multiple images to be written in the first image group where the original image is located into the storage device at the same time, the image to be detected is obtained. When judging the consistency between the image to be detected and the original image, only the second root hash value read from the image to be detected is needed, and compared with the first root hash value, so as to avoid spending a lot of time to download the original image and calculate the information summary, thereby shortening the detection time and improving the detection efficiency.
[0136] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A method for detecting image consistency. It is characterized in that Applied to a storage device, the storage device is communicatively connected with a monitoring device, the method comprises: Obtaining a first root hash value of the original picture, wherein the first root hash value is determined according to information summaries of multiple pictures to be written in the first picture group sent by the monitoring device, and the original picture is any one of the multiple pictures to be written; Reading a second root hash value of a to-be-detected picture, wherein the to-be-detected picture includes a first data area and a second data area, the first data area is used to store the original picture, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area; Determining whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value; The multiple pictures to be written are pre-sorted according to the receiving time and written in sequence, the picture to be detected is any one of the multiple pictures that have been written in the second picture group, and the method further includes: Obtaining the information summary of the first picture written into the second picture group and the information summary of the last picture written into the second picture group; If the information summary of the first written picture is different from the information summary of the first picture to be written in the first picture group, and / or the information summary of the last written picture is different from the information summary of the last picture to be written in the first picture group, then stop judging whether the picture to be detected is consistent with the original picture.
2. The method according to claim 1, It is characterized in that Before the step of obtaining the first root hash value of the original image, the method further includes: Calculate the information summary of each picture to be written; Determining a root hash value of the first picture group according to information summaries of all the pictures to be written; The root hash value of the first picture group is used as the first root hash value of the original picture.
3. The method according to claim 2, It is characterized in that The multiple pictures to be written are pre-sorted in order of reception time, each picture to be written is used as a node, and the information summary of each picture to be written is used as the node value of each node, and the step of determining the root hash value of the first picture group according to the information summary of all the pictures to be written includes: Divide all the nodes in pairs in sequence to obtain at least one hash group, and each of the nodes belongs to only one hash group; Calculate the hash value of each hash group according to the node value of each node in each hash group; If the number of the hash groups is one, taking the hash value of the hash group as the root hash value of the first picture group; If there are multiple hash groups, each hash group is taken as a node, and the hash value of each hash group is taken as the node value of each node, and the above steps are repeated until the root hash value of the first picture group is obtained.
4. The method according to claim 3, It is characterized in that The step of dividing all the nodes in pairs in sequence to obtain at least one hash group comprises: Get the number of all the nodes; If the number of the nodes is an odd number, the last node of all the nodes is divided into one of the hash groups.
5. The method according to claim 1, It is characterized in that The plurality of pictures to be written are pre-sorted according to the order of receiving time and written in sequence, and the method further includes: When an interruption event occurs when writing the first picture group, the order of the last written picture to be written in the first picture group is determined so that after the interruption event ends, the pictures to be written after the order in the first picture group continue to be written according to the order.
6. The method according to claim 1, It is characterized in that The step of determining whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value comprises: Determine whether the second root Hash value is the same as the first root Hash value; If they are the same, it is determined that the image to be detected is consistent with the original image.
7. A device for detecting image consistency, It is characterized in that Applied to a storage device, the storage device is communicatively connected with a monitoring device, and the device comprises: an acquisition module, configured to acquire a first root hash value of the original image, wherein the first root hash value is determined according to information summaries of a plurality of images to be written in a first image group sent by the monitoring device, and the original image is any one of the plurality of images to be written; A reading module, configured to read a second root hash value of a to-be-detected picture, wherein the to-be-detected picture includes a first data area and a second data area, the first data area is used to store the original picture, the second data area is used to store the first root hash value, and the second root hash value is read from the second data area; A judging module, configured to judge whether the image to be detected is consistent with the original image according to the second root hash value and the first root hash value; The multiple pictures to be written are pre-sorted in chronological order according to the reception time and written in sequence, the picture to be detected is any one of the multiple pictures that have been written in the second picture group, and the judgment module is also used to obtain the information summary of the first picture that has been written in the second picture group, and the information summary of the last picture that has been written; if the information summary of the first picture that has been written is different from the information summary of the first picture to be written in the first picture group, and / or the information summary of the last picture that has been written is different from the information summary of the last picture to be written in the first picture group, then stop judging whether the picture to be detected is consistent with the original picture.
8. A storage device, It is characterized in that include: A memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the method according to any one of claims 1 to 6 when calling the computer program.
9. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Data storage state detecting method and device and computer readable storage medium
CN107391298A
Object storage data consistency test method and system, terminal and storage medium
CN111143347A
Evidence storage method and device, computer equipment and storage medium
CN111767579A
Data backup device, method and system
WO2017088192A1
