CN114581808A - Picture consistency detection method and device, storage equipment and readable storage medium - Google Patents

Picture consistency detection method and device, storage equipment and readable storage medium Download PDF

Info

Publication number
CN114581808A
CN114581808A CN202210248264.3A CN202210248264A CN114581808A CN 114581808 A CN114581808 A CN 114581808A CN 202210248264 A CN202210248264 A CN 202210248264A CN 114581808 A CN114581808 A CN 114581808A
Authority
CN
China
Prior art keywords
picture
written
hash value
group
root hash
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210248264.3A
Other languages
Chinese (zh)
Inventor
林泽澍
任翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Unisinsight Technology Co Ltd
Original Assignee
Chongqing Unisinsight Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Unisinsight Technology Co Ltd filed Critical Chongqing Unisinsight Technology Co Ltd
Priority to CN202210248264.3A priority Critical patent/CN114581808A/en
Publication of CN114581808A publication Critical patent/CN114581808A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a picture consistency detection method and device, a storage device and a readable storage medium, and relates to the field of security monitoring. First, a first root hash value of an original picture is obtained, wherein the first root hash value is determined according to information digests of a plurality of pictures to be written in a first picture group sent by a monitoring device, and the original picture is any one of the plurality of pictures to be written in. Then, reading a second root hash value of the picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area; and finally, judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value, and avoiding consuming a large amount of time to download the original picture and calculate the information abstract, thereby shortening the detection time and improving the detection efficiency.

Description

Picture consistency detection method and device, storage equipment and readable storage medium
Technical Field
The invention relates to the field of security monitoring, in particular to a picture consistency detection method and device, a storage device and a readable storage medium.
Background
In the current security monitoring field, image data acquired by monitoring equipment needs to be stored in storage equipment, so that the storage equipment is required to have the capabilities of recording massive different types of images, reading and writing at high speed and the like and high reliability. The high reliability is mainly embodied in that a picture written into the storage device is consistent with a picture before writing, and is not missed, namely the picture is not damaged in the process of writing into the storage device, so that the consistency of the picture written into the storage device is detected, namely whether the picture is damaged in the process of writing into the storage device is detected, and the method plays an important role in improving the reliability of the storage device applied to the security monitoring field.
The conventional picture consistency detection technology generally downloads a picture written in a storage device, calculates an information summary (Message-Digest), downloads a corresponding original picture from an original picture library, calculates the information summary, and finally compares the information summaries of the two pictures to judge whether the picture is damaged or not in the process of writing in the storage device. Because the number of pictures written into the storage device is large, the detection method needs to consume a large amount of time to download the pictures and calculate the information abstract, and the detection efficiency is low.
Disclosure of Invention
In order to overcome the defects of the prior art, embodiments of the present invention provide a method and an apparatus for detecting picture consistency, a storage device, and a readable storage medium, so as to improve the efficiency of detecting picture consistency, and the specific technical solution is as follows:
in a first aspect, an embodiment of the present invention provides a picture consistency detection method, which is applied to a storage device, where the storage device is in communication connection with a monitoring device, and the method includes:
acquiring a first root hash value of an original picture, wherein the first root hash value is determined according to information digests of a plurality of pictures to be written in a first picture group sent by the monitoring equipment, and the original picture is any one of the plurality of pictures to be written in;
reading a second root hash value of a picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area;
and judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value.
Optionally, before the step of obtaining the first root hash value of the original picture, the method further includes:
calculating the information abstract of each picture to be written;
determining a root hash value of the first picture group according to the information digests of all the pictures to be written;
and taking the root hash value of the first picture group as the first root hash value of the original picture.
Optionally, the multiple pictures to be written are sorted in advance according to the receiving time, each picture to be written is used as a node, the information digest 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 digests of all the pictures to be written includes:
dividing all the nodes pairwise in sequence to obtain at least one hash group, wherein each node only belongs to one hash group;
calculating 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 the number of the hash groups is multiple, taking each hash group as a node, taking the hash value of each hash group as the node value of each node, and repeating the steps until the root hash value of the first picture group is obtained.
Optionally, the step of sequentially dividing every two nodes to obtain at least one hash group includes:
acquiring the number of all the nodes;
and if the number of the nodes is an odd number, dividing the last node in all the nodes into one hash group.
Optionally, the multiple pictures to be written are sorted in advance according to the receiving time and written in sequence, the picture to be detected is any one of the multiple written pictures in the second picture group, and the method further includes:
acquiring the information abstract of the first written picture and the information abstract of the last written picture in the second picture group;
and if the information abstract of the first written picture is different from the information abstract of the first picture to be written in the first picture group and/or the information abstract of the last written picture is different from the information abstract of the last picture to be written in the first picture group, stopping judging whether the picture to be detected is consistent with the original picture.
Optionally, the multiple pictures to be written are sorted in advance according to the receiving time and written in sequence, and the method further includes:
when an interruption event occurs during the writing of the first picture group, determining the sequence of the picture to be written which is written last in the first picture group, so that after the interruption event is ended, the picture to be written which is subsequent to the sequence in the first picture group is continuously written according to the sequence.
Optionally, the step of determining whether the picture to be detected is consistent with the original picture according to the second root hash value and the first root hash value includes:
judging whether the second root hash value is the same as the first root hash value;
and if the images are the same, judging that the image to be detected is consistent with the original image.
In a second aspect, an embodiment of the present invention provides an apparatus for detecting picture consistency, which is applied to a storage device, where the storage device is in communication connection with a monitoring device, and the apparatus includes:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first root hash value of an original picture, the first root hash value is determined according to information summaries of a plurality of pictures to be written in a first picture group sent by the monitoring equipment, and the original picture is any one of the plurality of pictures to be written;
the reading module is used for reading a second root hash value of a picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area;
and the judging module is used for judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value.
In a third aspect, an embodiment of the present invention provides a storage device, including: a memory for storing a computer program and a processor; the processor is adapted to perform the method according to the first aspect when the computer program is invoked.
In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the method according to the first aspect.
Compared with the prior art, in the method, the apparatus, the storage device and the readable storage medium for detecting picture consistency provided by the embodiments of the present invention, first, a first root hash value of an original picture is obtained, where the first root hash value is determined according to information digests of a plurality of pictures to be written in a first picture group sent by a monitoring device, and the original picture is any one of the plurality of pictures to be written in. Then, reading a second root hash value of the picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area; and finally, judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value. According to the embodiment of the invention, the original picture and the first hash value determined based on the information digests of a plurality of pictures to be written in the first picture group in which the original picture is positioned are simultaneously written into the storage device to obtain the picture to be detected, and when the consistency between the picture to be detected and the original picture is judged, only the second hash value read from the picture to be detected is needed to be compared with the first hash value, so that the consumption of a large amount of time for downloading the original picture and calculating the information digests is avoided, the detection time is shortened, and the detection efficiency is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a diagram illustrating an application scenario according to an embodiment of the present invention;
fig. 2 is a schematic block diagram of a structure of a storage device according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a method for detecting picture consistency according to an embodiment of the present invention;
fig. 4 is a flowchart illustrating a method for determining a first root hash value according to an embodiment of the present invention;
fig. 5 is a flowchart illustrating a method for determining a root hash value of a first group of pictures according to an embodiment of the present invention;
fig. 6 is a diagram illustrating an embodiment of determining a root hash value of a first group of pictures;
fig. 7 is a flowchart illustrating a method for determining whether to stop detecting consistency between a picture to be detected and an original picture according to an embodiment of the present invention;
fig. 8 is a schematic flowchart of another method for determining picture consistency according to an embodiment of the present invention;
fig. 9 is a block diagram illustrating an apparatus for detecting picture consistency according to an embodiment of the present invention.
Icon: 100-a storage device; 110-a memory; 120-a processor; 200-a monitoring device; 300-picture consistency detection means; 301-an obtaining module; 302-a reading module; 303-a judgment module; 304-determination module.
Detailed Description
In order to make the objects, 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 with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the present invention, it should be noted that, if the terms "upper", "lower", "inner", "outer", etc. are used to indicate the orientation or positional relationship based on the orientation or positional relationship shown in the drawings or the orientation or positional relationship which the product of the present invention is used to usually place, it is only for convenience of description and simplification of the description, but it is not intended to indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus, should not be construed as limiting the present invention.
Furthermore, the appearances of the terms "first," "second," and the like, if any, are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
In order to improve the detection efficiency of the consistency of the pictures, a random sampling inspection method is generally adopted, but the method cannot ensure the comprehensiveness and the accuracy of the detection result. In view of this, embodiments of the present invention provide a method and an apparatus for checking picture consistency, a storage device, and a readable storage medium, so as to improve detection efficiency and ensure comprehensiveness and accuracy of a detection result, which will be described in detail below.
Referring to fig. 1, fig. 1 is a specific example of an application scenario provided by an embodiment of the present invention, a storage device 100 is in communication connection with a monitoring device 200, where the storage device 100 may be an independent computer device, or a cluster formed by a plurality of computer devices, or a storage array, and the monitoring device 200 may be a network camera, and the monitoring device 200 sends acquired picture data to the storage device 100 for storage.
On the basis of fig. 1, an embodiment of the present invention further provides a schematic block diagram of a structure of the storage device 100 in fig. 1, referring to fig. 2, fig. 2 is a schematic block diagram of a structure of the storage device 100 according to an embodiment of the present invention, and the storage device 100 may include a memory 110 and a processor 120.
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 picture consistency detection method provided in the following method embodiments.
The MEMory 110 may be, but is not limited to, a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, an Electrically Erasable programmable Read-Only MEMory (EEPROM), a compact disc Read-Only MEMory (CD-ROM) or other optical disk storage, optical disk storage (including compact 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 desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory 110 may be self-contained and coupled to the processor 120 via a communication bus. The memory 110 may also be integrated with the processor 120. Memory 110 is used to store, among other things, machine-executable instructions for performing aspects of the present application. Processor 120 is operative to execute machine executable instructions stored in memory 110 to implement method embodiments described below.
Since the storage device 100 provided in the embodiment of the present invention is another implementation form of the picture consistency detection method provided in the following method embodiment, the following method embodiment can be referred to for the technical effect that can be obtained, and details are not described herein again.
Referring to fig. 3, fig. 3 is a flowchart illustrating a method for detecting picture consistency according to an embodiment of the present invention, where the method includes steps S101, S102, and S103.
S101, a first root hash value of the original picture is obtained.
The first root hash value is determined according to the information digests of the multiple pictures to be written in the first picture group sent by the monitoring equipment, and the original picture is any one of the multiple pictures to be written in.
In the embodiment of the present invention, the step of the monitoring device storing the picture from the monitoring device includes "receiving" and "writing", the picture to be written is obtained by the monitoring device completing the "receiving" operation, as a specific implementation manner, the storage device may divide the received picture to be written into at least one group of pictures according to a preset number according to the receiving time, each group of pictures corresponds to one root hash value, the root hash value of each group of pictures is obtained by performing hash operation according to the information digests of all the pictures to be written in the group of pictures, and the root hash value of each picture to be written in each group of pictures is the root hash value corresponding to the group of pictures.
The first picture group may be any one of the divided picture groups, hash operation is performed according to the information digests of all pictures to be written in the first picture group to obtain a first root hash value corresponding to the first picture group, the root hash values of all the pictures to be written in the first picture group are the first root hash values, and subsequently, when a write operation is executed, the first root hash value of the first picture group is synchronously recorded in a database table.
Because the number of the picture groups is multiple, each picture group can be numbered, when the root hash value of each picture group is recorded in the database table, the number of each picture group is also recorded, meanwhile, each picture group corresponds to a document, the document name of the picture group is set as the number of the picture group, and the storage path of the writing result corresponding to each picture to be written in the picture group is recorded, for example, the number of one picture group is 03, the document name of the corresponding document is 03, in addition, after all pictures to be written in each picture group are sequenced according to the receiving time, the information abstracts of the first picture and the last picture to be written are also recorded in the database table, specifically, for any picture group, when the storage device performs the writing operation, the information synchronously recorded in the database table is shown as the following table.
Group_id Picture group number
Root_hash Root hash value
File_name Picture path document name
File_loc Picture path document storage address
First_pic_MD5 Information abstract of first picture to be written
Last_pic_MD5 Information abstract of last picture to be written
The original picture is any one of a plurality of pictures to be written in the first picture group, and 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.
And S102, reading a second root hash value of the picture to be detected.
The picture to be detected comprises a first data area and a second data area, the first data area is used for storing an original picture, the second data area is used for storing a first root hash value, and the second root hash value is read from the second data area;
in the embodiment of the present invention, the storage device executes a "write" operation on the picture to be written and the first hash value thereof, so as to obtain the written picture, in the data area of the written picture, a space occupied by the picture to be written is used as the first data area, and a space occupied by the first hash value is used as the second data area.
The written picture is obtained, and generally, the data format of the written picture includes an abstract area and a data area, where 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 in the data area, where a space occupied by the picture to be written is used as the first data area, and a space occupied by the first root hash value is used as the second data area.
Since the original picture is any one of the plurality of pictures to be written, it can be understood that the picture to be detected is a written picture corresponding to the original picture, and the picture to be detected can be read according to the storage path recorded in the document corresponding to the first picture group, and then the information in the second data area of the picture to be detected, that is, the second root hash value, is read.
And S103, judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value.
In the embodiment of the present invention, according to a document name and a storage address of a document corresponding to a first group of pictures acquired from a database table, a storage path of a write result corresponding to each picture to be written recorded in the document is acquired, a picture to be detected is extracted, a second root hash value is read from a second data area of the picture to be detected, meanwhile, a first root hash value of an original picture corresponding to the picture to be detected is acquired 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 a "write" operation is performed by a storage device, so that the acquired picture to be detected is inconsistent with the corresponding original picture.
The method provided by the embodiment of the invention has the advantages that the original picture and the first hash value determined based on the information digests of a plurality of pictures to be written in the first picture group in which the original picture is positioned are simultaneously written into the storage device to obtain the picture to be detected, and when the consistency of the picture to be detected and the original picture is judged, only the second hash value read from the picture to be detected is needed to be compared with the first hash value, so that the consumption of a large amount of time for downloading the original picture and calculating the information digests is avoided, the detection time is shortened, and the detection efficiency is improved.
Based on fig. 3, an embodiment of the present invention further provides a specific implementation manner of determining the first root hash value, please refer to fig. 4, and fig. 4 is a flowchart illustrating a method for determining the first root hash value according to the embodiment of the present invention, where the method includes steps S201 and S202 and step S203.
S201, calculating the information abstract of each picture to be written.
In the embodiment of the present invention, the information Digest of the picture to be written is obtained by applying an MD5 information Digest Algorithm (Message Digest MD5) to the data of the picture to be written, for example, the picture to be written with a data length of L bits (bit) is first bit-filled, so that the final bit number of the picture can be grouped by 512 bits, each group is further divided into sixteen 32-bit sub-groups, four 32-bit groups are output through four-round cyclic operation, a 128-bit hash value is generated after the four 32-bit groups are concatenated, and a character string with a length of 32 bytes is obtained by hexadecimal conversion of the 128-bit hash value, that is, the information Digest of the picture to be written is obtained.
S202, according to the information digests of all the pictures to be written, determining a root hash value of the first picture group.
In the embodiment of the invention, the information summary of each picture to be written is a character string with the length of 32 bytes, and one or more times of hash operation is carried out based on the information summaries of all the pictures to be written to obtain the root hash value of the first picture group.
S203, using the root hash value of the first picture group as the first root hash value of the original picture.
In the embodiment of the present invention, since the original picture is any one of the plurality of pictures to be written in the first picture group, the hash value of the first picture group may be used as the first root hash value of the original picture.
Referring to fig. 5, fig. 5 is a flowchart illustrating a method for determining a root hash value of a first picture group according to an embodiment of the present invention, where step S202 includes sub-steps S202-1 to S202-4.
S202-1, all nodes are divided into two in sequence to obtain at least one hash group, and each node only belongs to one hash group.
In the embodiment of the present invention, the multiple pictures to be written in the first group of pictures are ordered in advance according to the receiving time, each ordered picture to be written is used as a node, the information summary of the ordered picture is used as a node value, and then every two nodes are sequentially divided into a hash group, in particular, each node can only be divided into one hash group, that is, there is no intersection between nodes in any two hash groups, for example, the ordered nodes are: nodes 01, 02, 03, and 04, nodes 01 and 02 are divided into hash group 1, and nodes 03 and 04 are divided into hash group 2.
Specifically, the sub-step S202-1 is realized as follows:
firstly, acquiring the number of all nodes;
and if the number of the nodes is an odd number, dividing the last node in all the nodes into a hash group.
In the embodiment of the present invention, since all nodes are divided into two hash groups, and any two hash groups do not have an intersection, for the case that the number of nodes is even, the division of the hash groups can be successfully completed, but for the case that the number of nodes is odd, the last node is independently divided into one hash group, for example, the nodes after sorting are: nodes 01, 02, 03, 04, and 05, the nodes 01 and 02 are divided into a hash group 1, the nodes 03 and 04 are divided into a hash group 2, and the node 05 is divided into a hash group 3.
S202-2, calculating the hash value of each hash group according to the node value of each node in each hash group.
In the embodiment of the present invention, each hash group includes two nodes, the node values of the two nodes are merged into one character string, and the hash value of each hash group refers to a result of performing a hash operation on the character string.
And S202-3, 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.
In the embodiment of the present invention, if there is only one hash group divided by two nodes, a hash value obtained based on a node value of the hash group may be used as a root hash value of the first picture group.
S202-4, if the number of the hash groups is multiple, taking each hash group as a node, taking the hash value of each hash group as the node value of each node, and repeating the steps until the root hash value of the first picture group is obtained.
In the embodiment of the present invention, if there are a plurality of hash groups divided by two nodes, each hash group is used as a node, and the hash value of the node is used as a node value, and the above steps S202-1, S202-2, and S203 are repeated until the divided hash groups are one, and the hash value of the hash group is used as the root hash value of the first group of pictures.
For example, the number of the pictures to be written in the first picture group is 5, the 5 pictures to be written are sequentially ordered according to the receiving time, and each picture to be written is taken as a node, so as to obtain a node 01, a node 02, a node 03, a node 04, and a node 05, as shown in fig. 6, first, the node 01 and the node 02 are divided into a hash group 1, the node 03 and the node 04 are divided into a hash group 2, the node 05 is divided into a hash group 3, and hash values of the hash group 1, the hash group 2, and the hash group 3 are respectively calculated; then, taking the hash group 1, the hash group 2 and the hash group 3 as a node respectively to obtain a node 11, a node 12 and a node 13, dividing the node 11 and the node 12 into the hash group 4, dividing the node 13 into the hash group 5, and calculating hash values of the hash group 4 and the hash group 5 respectively; finally, the hash group 4 and the hash group 5 are respectively used as a node to obtain a node 21 and a node 22, the node 21 and the node 22 are divided into the hash group 6, the hash value of the hash group 6 is calculated, and the 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:
Node[0][i]=MD5(data[i]),i=1,2,…,5
Figure BDA0003545924600000121
Figure BDA0003545924600000122
Figure BDA0003545924600000123
Figure BDA0003545924600000124
Root=hash(Node[2][1]+Node[2][2])
node [ j ] [ i ] refers to a Node value of Node ij, for example, Node [0] [1] represents a Node value of Node 01, data [ i ] refers to data to be written into a picture of the ith picture, and Root is a Root hash value of the first picture group.
Considering that the storage device may affect the accuracy of the consistency detection result of the subsequent picture to be detected and the original picture in the process of reading the picture to be detected, such as reading misalignment, before step S103 is executed, it is further required to determine whether to continue to detect the consistency between the picture to be detected and the original picture by determining whether to continue to read the picture to be detected and the original picture. Referring to fig. 7, fig. 7 is a flowchart illustrating a method for determining whether to stop detecting consistency between a picture to be detected and an original picture according to an embodiment of the present invention, where the method includes steps S301 and S302.
In step S301, the information summary of the first written picture and the information summary of the last written picture in the second picture group are obtained.
In the embodiment of the present invention, the second picture group includes a plurality of written pictures, each written picture is obtained by executing "write" operation in sequence according to the receiving time for each to-be-written picture in the first picture group by the storage device, each written picture is named as the information digest of the corresponding to-be-written picture, all the written pictures are also sorted in sequence according to the writing time, and the information digest of the first written picture and the information digest of the last written picture are obtained according to the names of the first written picture and the last written picture in the second picture group.
Step S302, if the information abstract of the first written picture is different from the information abstract of the first to-be-written picture in the first picture group and/or the information abstract of the last written picture is different from the information abstract of the last to-be-written picture in the first picture group, stopping judging whether the picture to be detected is consistent with the original picture.
In the embodiment of the invention, the information abstract of the first picture to be written and the information abstract of the last picture to be written can be obtained from the database table according to the number of the first picture group.
If the information abstract of the first written picture in the second picture group is the same as the information abstract of the first to-be-written picture in the first picture group, and meanwhile, the information abstract of the last written picture in the second picture group is also the same as the information abstract of the last to-be-written picture in the first picture group, the picture to be detected is represented as normal reading, and the judgment of whether the picture to be detected is consistent with the original picture can be continuously carried out.
It can be understood that, if the information digest of the first written picture in the second picture group is different from the information digest of the first to-be-written picture in the first picture group, and/or the information digest of the last written picture in the second picture group is different from the information digest of the last to-be-written picture in the first picture group, it represents that an abnormal condition exists in the process of reading the picture to be detected by the storage device, and at this time, it is necessary to stop determining whether the picture to be detected is consistent with the original picture.
In addition, in the process that the storage device executes a "write" operation on a plurality of pictures to be written in the first picture group, if the storage device is restarted, the service is stopped or the number of normal nodes does not satisfy the conditions of erasure correction and the like, the "write" operation is interrupted, and in order to prevent that the consistency between the pictures to be written and the original pictures cannot be judged subsequently due to the interruption of the "write", the storage device needs to perform the following operations when an interruption event caused by the reasons occurs:
when an interruption event occurs during writing in the first picture group, determining the sequence of the picture to be written in the first picture group, which is written finally, so that after the interruption event is finished, the picture to be written in the first picture group after the sequence is continuously written according to the sequence.
In the embodiment of the present invention, the order of pictures to be written refers to the position in the first group of pictures. For example, the order of the pictures to be written is 5, that is, it represents that it is the 5 th picture in the first group of pictures, and the storage device records the position of the last picture to be written, which is written before the interruption occurs, in the first group of pictures in the database table, so that all the remaining pictures to be written in the first group of pictures can be continuously written at the end of the interruption.
As a specific implementation manner, the storage device may create a database table as shown in the following table for the case of "write" interruption, and record the order of the last written picture to be written in the first picture group, the number of the first picture group, the status of the interruption event, and other information when the interruption event occurs.
Interrupt_Group_id Numbering of groups of pictures where an interruption occurred
Last_pic_Loc Order of last written pictures
Status Interrupt event state
It should be noted that before the interrupt event is not finished, the value of the interrupt event state Status in the database table is 0, and after the interrupt event is finished and the "write" operation on the remaining pictures to be written in the group of pictures is completed, the value of the interrupt event state Status is modified to 1.
Referring to fig. 8, fig. 8 is a flowchart illustrating another method for determining picture consistency according to an embodiment of the present invention, where step S103 includes substeps S103-1, S103-2, and S103-3.
S103-1, judging whether the second root hash value is the same as the first root hash value.
In the embodiment of the present invention, it may be determined whether an error occurs when the storage device performs a write operation, so that the original picture is damaged, by determining whether the second root hash value is the same as the first root hash value.
S103-2, if the images are the same, judging that the image to be detected is consistent with the original image.
In the 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 picture is not damaged in the process of being written into the storage device, and the picture to be detected obtained by the storage device performing the "write" operation on the original picture is consistent with the original picture.
S103-3, if the images are different, judging that the image to be detected is inconsistent with the original image.
In the embodiment of the present invention, if the second root hash value is different from the first root hash value, it means that the original picture is damaged in the process of being written into the storage device, and the picture to be detected obtained by the storage device performing the "write" operation on the original picture is inconsistent with the original picture.
In order to perform the corresponding steps in the above embodiments and various possible implementations, an implementation of the picture consistency detection apparatus 300 is given below. Referring to fig. 9, fig. 9 is a block diagram illustrating an apparatus 300 for detecting picture consistency according to an embodiment of the present invention. It should be noted that the basic principle and the generated technical effect of the apparatus 300 for detecting picture consistency according to the embodiment of the present invention are the same as those of the above embodiments, and for the sake of brief description, no reference is made to the embodiment of the present invention.
The picture consistency detection apparatus 300 includes an acquisition module 301, a reading module 302, a judgment module 303, and a determination module 304.
The obtaining module 301 is configured to obtain a first root hash value of an original picture, where the first root hash value is determined according to information digests of multiple pictures to be written in a first picture group sent by a monitoring device, and the original picture is any one of the multiple pictures to be written in.
A reading module 302, configured to read a second root hash value of a to-be-detected picture, where the to-be-detected picture includes a first data area and a second data area, the first data area is used to store an original picture, the second data area is used to store a first root hash value, and the second root hash value is read from the second data area;
the determining module 303 is configured to determine whether the to-be-detected picture is consistent with the original picture according to the second root hash value and the first root hash value.
A determining module 304, configured to calculate an information summary of each to-be-written picture; determining a root hash value of the first picture group according to the information digests of all pictures to be written; and taking the root hash value of the first picture group as the first root hash value of the original picture.
As an implementation manner, a plurality of pictures to be written are sequenced in advance according to receiving time, each picture to be written is taken as a node, an information abstract of each picture to be written is taken as a node value of each node, and the determining module 304 is specifically configured to divide every two nodes in sequence to obtain at least one hash group when determining a root hash value of a first picture group according to the information abstracts of all the pictures to be written, wherein each node only belongs to one hash group; calculating 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 the number of the hash groups is multiple, taking each hash group as a node, taking the hash value of each hash group as the node value of each node, and repeating the steps until the root hash value of the first picture group is obtained.
As an implementation manner, the determining module 304 is further specifically configured to obtain the number of all nodes when the determining module is configured to divide all nodes pairwise in sequence to obtain at least one hash group; and if the number of the nodes is an odd number, dividing the last node in all the nodes into a hash group.
As an implementation manner, the multiple pictures to be written are sorted in advance according to the receiving time and written in sequence, and the determining module 304 is further configured to determine, when an interruption event occurs while writing in the first picture group, an order of the picture to be written that is written last in the first picture group, so that after the interruption event is ended, the pictures to be written that follow the order in the first picture group are continuously written according to the order.
As an implementation manner, the multiple pictures to be written are sequentially ordered and written in advance according to the receiving time, the picture to be detected is any one of the multiple written pictures in the second picture group, and the determining module 303 is further configured to obtain an information summary of a first written picture and an information summary of a last written picture in the second picture group; and if the information abstract of the first written picture is different from the information abstract of the first to-be-written picture in the first picture group and/or the information abstract of the last written picture is different from the information abstract of the last to-be-written picture in the first picture group, stopping judging whether the picture to be detected is consistent with the original picture or not.
As an implementation manner, the determining module 303 is configured to determine whether the second root hash value is the same as the first root hash value when determining whether the to-be-detected picture is consistent with the original picture according to the second root hash value and the first root hash value; if the detected picture is the same as the original picture, the picture to be detected is judged to be consistent with the original picture.
The embodiment of the present invention further provides a readable storage medium containing computer-executable instructions, where the computer-executable instructions, when executed, may be configured to perform relevant operations in the picture consistency detection method provided in the foregoing method embodiment.
To sum up, according to the method, the apparatus, the storage device, and the readable storage medium for detecting picture consistency provided in the embodiments of the present invention, first, a first root hash value of an original picture is obtained, where the first root hash value is determined according to information digests of a plurality of pictures to be written in a first picture group sent by a monitoring device, and the original picture is any one of the plurality of pictures to be written in. Then, reading a second root hash value of the picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area; and finally, judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value. According to the embodiment of the invention, the original picture and the first hash value determined based on the information digests of a plurality of pictures to be written in the first picture group in which the original picture is positioned are simultaneously written into the storage device to obtain the picture to be detected, and when the consistency between the picture to be detected and the original picture is judged, only the second hash value read from the picture to be detected is needed to be compared with the first hash value, so that the consumption of a large amount of time for downloading the original picture and calculating the information digests is avoided, the detection time is shortened, and the detection efficiency is improved.
The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A picture consistency detection method is applied to a storage device, wherein the storage device is in communication connection with a monitoring device, and the method comprises the following steps:
acquiring a first root hash value of an original picture, wherein the first root hash value is determined according to information digests of a plurality of pictures to be written in a first picture group sent by the monitoring equipment, and the original picture is any one of the plurality of pictures to be written in;
reading a second root hash value of a picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area;
and judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value.
2. The method of claim 1, wherein the step of obtaining the first root hash value of the original picture is preceded by the method further comprising:
calculating the information abstract of each picture to be written;
determining a root hash value of the first picture group according to the information digests of all the pictures to be written;
and taking the root hash value of the first picture group as the first root hash value of the original picture.
3. The method according to claim 2, wherein the multiple pictures to be written are sorted in advance according to receiving time, each picture to be written is used as a node, an information digest of each picture to be written is used as a node value of each node, and the step of determining the root hash value of the first group of pictures according to the information digests of all the pictures to be written includes:
dividing all the nodes pairwise in sequence to obtain at least one hash group, wherein each node only belongs to one hash group;
calculating 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 the number of the hash groups is multiple, taking each hash group as a node, taking the hash value of each hash group as the node value of each node, and repeating the steps until the root hash value of the first picture group is obtained.
4. The method of claim 3, wherein said step of pairwise partitioning all of said nodes in sequence to obtain at least one hash group comprises:
acquiring the number of all the nodes;
and if the number of the nodes is an odd number, dividing the last node in all the nodes into one hash group.
5. The method according to claim 1, wherein the plurality of pictures to be written are sorted in advance according to the receiving time and written in sequence, the picture to be detected is any one of the plurality of written pictures in the second picture group, and the method further comprises:
acquiring the information abstract of the first written picture and the information abstract of the last written picture in the second picture group;
and if the information abstract of the first written picture is different from the information abstract of the first to-be-written picture in the first picture group and/or the information abstract of the last written picture is different from the information abstract of the last to-be-written picture in the first picture group, stopping judging whether the picture to be detected is consistent with the original picture.
6. The method of claim 1, wherein the plurality of pictures to be written are previously ordered according to the receiving time and are written in sequence, and the method further comprises:
when an interruption event occurs during the writing of the first picture group, determining the sequence of the picture to be written which is written last in the first picture group, so that after the interruption event is ended, the picture to be written which is subsequent to the sequence in the first picture group is continuously written according to the sequence.
7. The method according to claim 1, wherein the step of determining whether the picture to be detected is consistent with the original picture according to the second root hash value and the first root hash value comprises:
judging whether the second root hash value is the same as the first root hash value;
if the images are the same, the images to be detected are judged to be consistent with the original images.
8. The picture consistency detection device is applied to a storage device, wherein the storage device is in communication connection with a monitoring device, and the picture consistency detection device comprises:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring a first root hash value of an original picture, the first root hash value is determined according to information summaries of a plurality of pictures to be written in a first picture group sent by the monitoring equipment, and the original picture is any one of the plurality of pictures to be written;
the reading module is used for reading a second root hash value of a picture to be detected, wherein the picture to be detected comprises a first data area and a second data area, the first data area is used for storing the original picture, the second data area is used for storing the first root hash value, and the second root hash value is read from the second data area;
and the judging module is used for judging whether the picture to be detected is consistent with the original picture or not according to the second root hash value and the first root hash value.
9. A storage device, comprising: a memory for storing a computer program and a processor; the processor is configured to perform the method according to any one of claims 1 to 7 when the computer program is invoked.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN202210248264.3A 2022-03-14 2022-03-14 Picture consistency detection method and device, storage equipment and readable storage medium Pending CN114581808A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210248264.3A CN114581808A (en) 2022-03-14 2022-03-14 Picture consistency detection method and device, storage equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210248264.3A CN114581808A (en) 2022-03-14 2022-03-14 Picture consistency detection method and device, storage equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114581808A true CN114581808A (en) 2022-06-03

Family

ID=81775068

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210248264.3A Pending CN114581808A (en) 2022-03-14 2022-03-14 Picture consistency detection method and device, storage equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114581808A (en)

Similar Documents

Publication Publication Date Title
JP4617405B2 (en) Electronic device for detecting defective memory, defective memory detecting method, and program therefor
WO2017215377A1 (en) Method and device for processing hard memory error
CN113608692B (en) Storage system data consistency verification method, system, equipment and medium
CN112579327B (en) Fault detection method, device and equipment
CN106373616B (en) Method and device for detecting faults of random access memory and network processor
CN111400267A (en) Method and device for recording log
CN114860745B (en) Database expansion method based on artificial intelligence and related equipment
CN114860487A (en) Memory fault identification method and memory fault isolation method
CN114385418A (en) Protection method, device, equipment and storage medium for communication equipment
CN111857603B (en) Data processing method and related device
CN114581808A (en) Picture consistency detection method and device, storage equipment and readable storage medium
CN107943415B (en) Method and system for searching free cluster based on FAT file system
CN114860432A (en) Method and device for determining information of memory fault
CN114203252A (en) Bad block detection method, device, equipment and storage medium of nonvolatile memory
CN115543685A (en) Database rollback method and device, electronic equipment and storage medium
CN113032348A (en) Spatial data management method, system and computer readable storage medium
JP3498702B2 (en) Computer system and trace information control method used therefor
JP2000047909A (en) Device and method for recording system log, and storage medium
CN112650645A (en) Heap memory use condition monitoring method and device and 5G base station equipment
CN116483641B (en) Method, system and medium for abnormal power failure detection of hard disk
CN117439871B (en) Meter reading fault positioning method and device, storage medium and electronic equipment
CN113377757B (en) Data checking method and device, electronic equipment and machine-readable storage medium
CN116737457B (en) Data verification method based on distributed storage
CN114267402B (en) Bad storage unit testing method, device, equipment and storage medium of flash memory
CN116166205B (en) File system storage and mounting method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination