Image retrieval method, device, and storage medium
By grouping and similarity comparison of massive images, using the current timestamp and image number to compress the comparison results, combined with and check the clustering algorithm, the problem of inefficiency in clustering of massive images is solved, and an efficient image clustering process is achieved.
Patent Information
- Application Number
- CN202111233997.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-22
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2041-10-22
AI Technical Summary
In the process of clustering of massive images, frequent read and write operations lead to inefficiency, especially when the amount of information is large, it is impossible to complete efficient comparison and clustering within an acceptable time.
By grouping a group of pictures with the same characteristics of the picture description, obtaining picture information and comparing similarity, determining the number of compressed bits using the current timestamp and the number of pictures, compressing the comparison results, and clustering using and checking the clustering algorithm.
This improves the efficiency of image clustering, reduces the amount of information of multiple comparison results, shortens the clustering time, and improves the speed of massive image clustering.
Smart Images

Figure CN116010639B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image retrieval technology, and in particular to an image retrieval method and device, and a storage medium. Background Art
[0002] With the development of the big data era, the number of images in various business lines is increasing. By clustering all images, it is possible to perform fast retrieval based on the clustered images.
[0003] In the prior art, when multiple pictures are obtained, the multiple pictures are first grouped, and then the pictures in each group of pictures are compared to obtain the comparison results of each group of pictures. The comparison results are then clustered to obtain clustered pictures. In the process of clustering the comparison results, the comparison results need to be frequently read and written. When the amount of information in the comparison results is large, the speed of clustering the pictures is reduced, and the efficiency of picture clustering is reduced. Summary of the Invention
[0004] In order to solve the above technical problems, the present invention aims to provide an image retrieval method and device, and a storage medium, which improve the efficiency of image clustering.
[0005] The technical solution of the present invention is achieved as follows:
[0006] In a first aspect, an embodiment of the present invention provides an image retrieval method, comprising:
[0007] When a group of pictures having the same picture description feature is determined, obtaining a group of picture information corresponding to the group of pictures, and determining the number of pictures in the group of pictures;
[0008] Performing a similarity comparison on the set of image information to obtain a plurality of comparison results, and obtaining a current timestamp when the plurality of comparison results are obtained;
[0009] Determining the compression bit number of the plurality of comparison results according to the number of pictures; and compressing the plurality of comparison results according to the compression bit number and the current timestamp to obtain a plurality of compressed comparison results;
[0010] The group of images is clustered according to the multiple compressed comparison results to obtain a clustering result, so as to perform an image retrieval process based on the clustering result.
[0011] In a second aspect, an embodiment of the present invention provides an image retrieval device, the device comprising:
[0012] An acquiring unit is configured to, upon determining a group of pictures having the same picture description feature, acquire a group of picture information corresponding to the group of pictures; and acquire a current timestamp when the plurality of comparison results are obtained;
[0013] A comparison unit, configured to perform a similarity comparison on the set of image information to obtain a plurality of comparison results;
[0014] a determining unit, configured to determine the number of pictures in the group of pictures; and determine the number of compressed bits of the plurality of comparison results according to the number of pictures;
[0015] a compression unit, configured to compress the plurality of comparison results according to the compression bit number and the current timestamp to obtain a plurality of compressed comparison results;
[0016] A clustering unit is used to cluster the group of pictures according to the multiple compressed comparison results to obtain a clustering result, so as to perform a picture retrieval process based on the clustering result.
[0017] In a third aspect, an embodiment of the present invention further provides an image retrieval device, the device comprising:
[0018] A memory, a processor and a communication bus, wherein the memory communicates with the processor via the communication bus, and the memory stores an image retrieval program executable by the processor. When the image retrieval program is executed, the image retrieval method described above is executed by the processor.
[0019] In a fourth aspect, an embodiment of the present invention provides a storage medium, characterized in that a computer program is stored thereon and applied to an image retrieval device, and the computer program implements the above-mentioned image retrieval method when executed by a processor.
[0020] The present invention provides an image retrieval method and device, and a storage medium. The image retrieval method includes: when a group of images with the same image description features are determined, obtaining a group of image information corresponding to the group of images, and determining the number of images in the group of images; performing similarity comparison on the group of image information to obtain multiple comparison results, and obtaining a current timestamp when the multiple comparison results are obtained; determining the number of compression bits for the multiple comparison results according to the number of images; and compressing the multiple comparison results according to the compression bit and the current timestamp to obtain multiple compressed comparison results; clustering the group of images according to the multiple compressed comparison results to obtain clustering results, so as to execute an image retrieval process based on the clustering results. Using the above-mentioned image retrieval method, when the image retrieval device determines a group of images with the same image description features, the image retrieval device obtains multiple comparison results by comparing the similarity of a group of image information corresponding to the group of images, and obtains the current timestamp when the multiple comparison results are obtained; and determines the compression bit number of the multiple comparison results according to the number of images in a group of images; so that the image retrieval device can compress the multiple comparison results according to the compression bit number and the current timestamp to obtain multiple compressed comparison results, thereby reducing the amount of information in the multiple compressed comparison results, and performing the clustering process using the multiple compressed comparison results, thereby improving the speed of clustering images and improving the efficiency of image clustering. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A flow chart of an image retrieval method provided by an embodiment of the present invention;
[0022] Figure 2 An exemplary clustering operation diagram provided by an embodiment of the present invention;
[0023] Figure 3 An exemplary Union operation diagram provided in an embodiment of the present invention;
[0024] Figure 4 A schematic diagram of the structure of an image retrieval device provided by an embodiment of the present invention Figure 1 ;
[0025] Figure 5 A schematic diagram of the structure of an image retrieval device provided by an embodiment of the present invention Figure 2 . DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present invention.
[0027] In the process of comparing massive amounts of identical images, the following technical problems need to be solved:
[0028] (1) Grouping method of massive images:
[0029] Proper grouping, dividing and conquering massive images, can significantly reduce unnecessary computation, thereby conserving resources and improving clustering efficiency. Scientifically grouping massive images is a key consideration before clustering images from the same version.
[0030] (2) Efficiently compare massive images:
[0031] After grouping, images within the same group need to be compared to determine whether any two images are from the same version. In scenarios with massive amounts of images, this comparison is computationally intensive and cannot be completed within an acceptable timeframe on a single machine. Therefore, utilizing distributed computing to efficiently compare massive images is crucial.
[0032] (3) What model and algorithm should be used to cluster the comparison results of massive images of the same version?
[0033] Clustering massive images leverages the same-version relationships between images to establish connections between tens of millions or even hundreds of millions of images. Efficiently utilizing graph algorithms to perform clustering operations on massive images is a critical issue.
[0034] The problems existing in the prior art can be solved by using the method in Example 1.
[0035] Example 1
[0036] The embodiment of the present invention provides a picture retrieval method, which is applied to a picture retrieval device. Figure 1 A flow chart of an image retrieval method provided by an embodiment of the present invention is shown as follows: Figure 1 As shown, the image retrieval method may include:
[0037] S101. When a group of pictures having the same picture description features is determined, obtain a group of picture information corresponding to the group of pictures, and determine the number of pictures in the group of pictures.
[0038] An image retrieval method provided by an embodiment of the present invention is applied to a scenario in which a group of acquired images with the same image description features are clustered.
[0039] In the embodiments of the present application, the image retrieval device can be implemented in various forms. For example, the image retrieval device described in the present application can include devices such as mobile phones, watches, tablet computers, laptop computers, PDAs, servers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and devices such as digital TVs, desktop computers, and operating systems.
[0040] In an embodiment of the present application, a group of pictures can be portrait pictures of a group of users, or a group of pictures can be ID card pictures of a group of users; a group of pictures can also be other pictures of a group of users, and the specific ones can be determined according to actual conditions, and the embodiment of the present application does not limit this.
[0041] In the embodiment of the present application, the image description features include the user's identity document (ID), the user's location at a certain moment, the user's birth time, the user's residential address, the time when the user does something, etc. The specific image description features can be determined according to actual conditions, and the embodiment of the present application does not limit this.
[0042] It should be noted that the location of the user at a certain moment can be the location when the user applies for mobile phone network access; the time when the user does something can be the time when the user applies for mobile phone network access.
[0043] In an embodiment of the present application, a group of picture information may specifically be picture content information of a group of pictures. The picture content information may be pixel information of the pictures, or other forms of information used to describe the picture content of the group of pictures. The specific information may be determined according to actual conditions, and the embodiment of the present application does not limit this.
[0044] In an embodiment of the present application, a set of picture information corresponding to a group of pictures can be stored in a non-relational database (Not Only Structured Query Language, NoSQL). When the picture retrieval device determines a group of pictures with the same picture description features, the picture retrieval device can obtain a set of picture information corresponding to the group of pictures in NoSQL.
[0045] It should be noted that the storage method of a set of image information in NoSQL can be a key-value pair (Key-Value) storage method, specifically, it can be an object storage method, or a big data storage solution (Hbase), etc.
[0046] In an embodiment of the present application, before the image retrieval device obtains a group of image information corresponding to a group of images, upon receiving an image retrieval instruction, the image retrieval device obtains multiple image description information corresponding to multiple images from a relational database; the image retrieval device obtains image description features corresponding to the image retrieval instruction from multiple image description information based on the correspondence between a preset retrieval instruction and a preset feature value; the image retrieval device segments the multiple images according to the image description features and preset segmentation data to obtain multiple images; the image retrieval device obtains multiple groups of images from the multiple images, and the multiple groups of images include a group of images.
[0047] It should be noted that the multiple picture description information includes a group of picture description information.
[0048] In the embodiment of the present application, multiple pieces of picture description information correspond one-to-one to multiple pictures, that is, one picture corresponds to one piece of picture description information.
[0049] In the embodiment of the present application, a picture description information can specifically be a piece of Meta information of the picture. Multiple pictures correspond to multiple pieces of Meta information, and the multiple Meta information can be stored in a relational database.
[0050] It should be noted that a piece of Meta information is divided into multiple field columns, and each row in the relational database stores a piece of Meta information corresponding to a picture.
[0051] For example, if a Meta information has five fields, namely, the user's identity, the user's location at a certain moment, the user's birth time, the user's residential address, and the time when the user did something, then the first field of the Meta information is the user's identity; the second field of the Meta information is the user's location at a certain moment; the third field of the Meta information is the user's birth time; the fourth field of the Meta information is the user's residential address; and the fifth field of the Meta information is the time when the user did something.
[0052] In an embodiment of the present application, multiple pieces of picture information corresponding to multiple pictures are stored in NoSQL in a Key-Value manner, wherein multiple keys corresponding to the multiple pictures can be obtained according to multiple picture description information.
[0053] It should be noted that multiple image information corresponds to multiple keys one-to-one, specifically, one image information corresponds to one key. Multiple image description information corresponds to multiple keys one-to-one, specifically, one image description information corresponds to one key.
[0054] In the embodiment of the present application, the picture description feature is information obtained from a partial field column in multiple picture description information.
[0055] In the embodiments of the present application, the image retrieval instructions in different scenarios are different, and the corresponding image description features are also different. For example, in the scenario of opening a mobile phone account, each time a user opens a mobile phone number, a portrait picture needs to be collected. The corresponding Meta information should mainly include the following fields: user ID, address information when the user's mobile phone account is opened, user's birth time, user's residential address, user's mobile phone number access time, etc. If in a certain scenario, statistics are counted for the clustering of the same version of pictures of each user in the entire network, that is, statistics are counted for users who use the same photo to apply for multiple mobile phone numbers, the feature value of the picture can be selected from the user identity ID column; and in another scenario, statistics are needed for the clustering of the same version of pictures of users in a certain place and on a certain day, that is, statistics are counted for the situation where multiple mobile phone numbers are applied for with the same photo in a certain place and on a certain day. The picture description feature is the address when the user applies for multiple mobile phone numbers and the time when the user's mobile phone number is connected to the network.
[0056] In an embodiment of the present application, multiple pictures are grouped using picture description features, so that pictures in the same group can be compared with each other, and pictures in the same version can be clustered. Clustering is performed within pictures in the same group, and pictures in different groups will not be compared or clustered.
[0057] In an embodiment of the present application, the image retrieval device segments multiple images according to image description features and preset segmentation data to obtain multiple pieces of images, including: the image retrieval device groups multiple images according to the image description features to obtain multiple groups of images; the image retrieval device groups multiple image description information according to the multiple groups of images to obtain multiple groups of image description information, and writes the multiple groups of image description information into a comma-delimited file by line; the image retrieval device segments the comma-delimited file according to the preset segmentation data to obtain multiple pieces of image description information; the image retrieval device obtains multiple pieces of images based on the multiple piece grouping description information.
[0058] It should be noted that one line of the comma-delimited file corresponds to a set of picture description information, multiple sets of picture description information include one set of picture description information, and any one of the multiple pieces of picture description information includes at least one set of picture description information.
[0059] It should be noted that the comma-separated file may be a CSV (Comma-Separated Values) file.
[0060] In an embodiment of the present application, the image grouping method performed by the image retrieval device is to execute a grouping SQL statement on a relational database storing multiple Meta information corresponding to multiple images, obtain the grouping results, and write the grouping results into a CSV file.
[0061] For example, the format of the SQL statement may be:
[0062] copy(select columnA,string_agg(columnB,columnC,columnD,'columndelimiter')as columns from(select distinct(columnA,columnB,columnC,columnD),columnA,columnB,columnC,columnD from MetaTable where condition)as data groupby columnA)to' / data_group.csv'with delimiter'column delimiter';
[0063] It should be noted that in this SQL statement scenario, the field selected as the image description feature is columnA, and the image description information of each image consists of columnA, columnB, columnC, and columnD. For example, the structure of each row of the generated CSV file (the column separator here defaults to a single vertical line) can be:
[0064] columnA|columnB1|columnC1|columnD1|columnB2|columnC2|columnD2|columnB3|columnC3|columnD3……
[0065] It should also be noted that in the CSV file, each row is a group of images, and the image description feature (here, columnA) can correspond to multiple images (here, each image is represented by three columns: columnB|columnC|columnD).
[0066] In an embodiment of the present application, the image retrieval device can segment the comma-delimited file according to the number of multiple threads in the image retrieval device to obtain multiple pieces of image description information.
[0067] In an embodiment of the present application, the process of an image retrieval device obtaining multiple groups of images from multiple images includes: the image retrieval device transmits the multiple images to multiple threads respectively; the image retrieval device uses the first thread among the multiple threads to obtain the first thread image in the first image among the multiple images, until multiple thread images are obtained from the multiple images respectively using the multiple threads; the image retrieval device uses the multiple thread images as multiple groups of images.
[0068] It should be noted that the multiple threads correspond one-to-one to the multiple thread pictures; any one of the multiple thread pictures includes at least one group of pictures.
[0069] In an embodiment of the present application, the process of the image retrieval device using the first thread among multiple threads to obtain the first thread image in the first piece of images in multiple pieces of images includes: the image retrieval device uses the first thread to obtain the first group of images in the first piece of images, until each group of images in the first piece of images is obtained from the first piece of images, and the first thread image is obtained, so as to use the first thread to compare the image information corresponding to any two images in each group of images.
[0070] In an embodiment of the present application, the image retrieval device can compare each set of images using a distributed cluster. However, before comparing each set of images, the information processing device can first split the CSV file into slices, and the image retrieval device can evenly divide the CSV file according to the number of threads, so that each of the multiple threads processes the same number of images.
[0071] In the embodiment of the present application, the algorithm for CSV file segmentation is shown in formula (1) and formula (2):
[0072] (Total number of packets / number of servers) + 1 = number of packets processed by each server (1)
[0073] Number of packets processed by each server / Number of CPU cores + 1 = Number of packets processed by each thread (2)
[0074] It should be noted that the number of packets that each thread needs to process is the number of packets in a thread graph.
[0075] S102: Perform similarity comparison on a group of image information to obtain multiple comparison results, and obtain current timestamps when the multiple comparison results are obtained.
[0076] In an embodiment of the present application, after the image retrieval device obtains a set of image information corresponding to a group of images and determines the number of images in a group of images, the image retrieval device can perform a similarity comparison on the set of image information, obtain multiple comparison results, and obtain the current timestamp when the multiple comparison results are obtained.
[0077] In an embodiment of the present application, a process in which an image retrieval device performs a similarity comparison on a group of image information to obtain multiple comparison results includes: the image retrieval device obtains two image information corresponding to the first image and the second image in a group of image information; the image retrieval device determines the similarity between the two image information; when the similarity is greater than or equal to a preset similarity threshold, the image retrieval device uses the first image description information of the first image and the second image description information of the second image to generate a comparison result corresponding to the first image and the second image, until any two image information of any two images in a group of image information are compared, and multiple comparison results are obtained using a group of image description information of a group of images.
[0078] It should be noted that the image description feature is part of a set of image description information.
[0079] In an embodiment of the present application, the information processing device can utilize the concurrency of multiple threads supported by a multi-core CPU and use multiple threads to perform comparison operations. The process of executing image comparison for each of the multiple threads can be: the thread reads the CSV file line by line (a line in the CSV file corresponds to a group of pictures), and compares each two pictures in a group of pictures. For example, if the number of pictures in each group is N, the number of comparisons required is That is, every two pictures in the group must be compared once.
[0080] In the embodiment of the present application, when a thread compares two pictures, it needs to first obtain the two picture information corresponding to the two pictures. The two picture information is stored in NoSql in Base64 format. It is necessary to generate two keys corresponding to the two pictures in NoSql through the two Meta information fields of the two pictures, and then obtain the corresponding two Values from NoSql, that is, the Base64 encoding of the two picture information is obtained. Then, the algorithm service can be called to implement picture comparison. If the similarity between the two picture information is greater than or equal to the preset similarity threshold, it is determined that the two pictures are the same version of the picture, and then a line is added to the comparison result. The comparison result is also a CSV file. The format of each line in the CSV file of the comparison result can be:
[0081] columnA1|columnB1|columnC1|columnD1|columnA2|columnB2|columnC2|columnD2
[0082] It should be noted that each row of the comparison result records the feature fields (columnA1, columnA2) of the two identical images, as well as other descriptive information. Each thread will eventually generate a CSV file to record the comparison results. After each thread in the server completes the image comparison operation, the information processing device will copy the comparison results in the form of CSV files generated by all threads to a fixed server via SCP.
[0083] It should be noted that the preset similarity threshold can be a threshold configured in the image retrieval device; the preset similarity threshold can also be a threshold received by the image retrieval device before the image retrieval device compares the similarity between two image information with the preset similarity threshold. The preset similarity threshold can also be a threshold obtained by the image retrieval device in other ways. The specific image retrieval device can determine the preset similarity threshold based on actual conditions, and the embodiments of the present application do not limit this.
[0084] S103 , determining the compression bit number of the multiple comparison results according to the number of pictures; and compressing the multiple comparison results according to the compression bit number and the current timestamp to obtain multiple compressed comparison results.
[0085] In an embodiment of the present application, the image retrieval device performs a similarity comparison on a group of image information, obtains multiple comparison results, and obtains the current timestamp when the multiple comparison results are obtained. The image retrieval device can then determine the number of compression bits for the multiple comparison results based on the number of images; and compress the multiple comparison results based on the compression bit number and the current timestamp to obtain multiple compressed comparison results.
[0086] In the embodiment of the present application, the number of current timestamps corresponds to the number of comparison results, that is, one current timestamp corresponds to one comparison result. Specifically, when the image retrieval device obtains a comparison result, the image retrieval device obtains a current timestamp corresponding to the comparison result.
[0087] In an embodiment of the present application, the image retrieval device determines the number of compressed bits of multiple comparison results based on the number of pictures. The image retrieval device can determine the logarithm of the number of pictures with base 36 to obtain the number of compressed bits of multiple comparison results. The image retrieval device can also determine the number of compressed bits of multiple comparison results based on the number of pictures in other ways. The specific method can be determined according to actual conditions, and the embodiment of the present application does not limit this.
[0088] In an embodiment of the present application, the image retrieval device compresses multiple comparison results according to the compression bit number and the current timestamp to obtain multiple compressed comparison results, including: the image retrieval device adds the current timestamp to the multiple comparison results to obtain multiple added comparison results; the image retrieval device starts from the first information bit of the multiple added comparison results, obtains information on the compression bit number, and obtains multiple comparison results with a preset number of bits; the image retrieval device uses an information summary compression method to compress multiple comparison results with a preset number of bits to obtain multiple compressed comparison results.
[0089] In an embodiment of the present application, the image retrieval device reads the comparison results in the form of a CSV file row by row, and each row read is split in half. The two images correspond to two strings, columnA1|columnB1|columnC1|columnD1 and columnA2|columnB2|columnC2|columnD2 respectively. These two strings correspond to the information of the two images + a unique identifier, which are Key1 and Key2 respectively, that is, a comparison result.
[0090] In an embodiment of the present application, the information summary compression method can be MD5 plus salt to obtain a 32-bit MD5 compression method.
[0091] Specifically, the image retrieval device may compress multiple comparison results according to the method shown in formula (3) to obtain multiple compressed comparison results:
[0092] Compressed Key=MD5(Original Key+Current TimeStamp)[Len] (3)
[0093] It should be noted that Original Key is the comparison result of multiple entries, Current Time Stamp is the current timestamp, Len is the number of bits used to compress the comparison results based on the number of images, and Compressed Key is the compressed comparison result of multiple entries. MD5 is the 32-bit MD5 compression method obtained by adding salt to MD5.
[0094] In an embodiment of the present application, after the image retrieval device obtains multiple compressed comparison results, the image retrieval device can store the multiple compressed comparison results in the Key of HashMapCompress, where the Value in HashMapCompress is the Key value before compression. In the event of a Hash collision in the multiple compressed comparison results, the information processing device will compress the multiple compressed comparison results again until there is no Hash collision.
[0095] In an embodiment of the present application, the image retrieval device starts from the first information bit of multiple added comparison results, obtains information on the number of compression bits, and obtains a plurality of comparison results of a preset number of bits, including: the image retrieval device starts from the first information bit of multiple added comparison results, obtains information on the number of compression bits, and obtains a plurality of initial compression results; when the first compression result in the plurality of initial compression results is different from the second compression result, the image retrieval device uses the plurality of initial compression results as a plurality of compressed comparison results; when the first compression result is the same as the second compression result, the image retrieval device continues to compress the first compression result to obtain a first cyclic compression result; until the first cyclic compression result is different from any of the compression results in the initial compression results, the first cyclic compression result and the remaining compression results in the initial compression results except the first compression result are used as a plurality of compressed comparison results.
[0096] It should be noted that the first compression result is any compression result among the multiple initial compression results, and the second compression result is a compression result among the multiple initial compression results except the first compression result.
[0097] S104: Clustering a group of images according to the multiple compressed comparison results to obtain a clustering result, and performing an image retrieval process based on the clustering result.
[0098] In an embodiment of the present application, the image retrieval device compresses multiple comparison results according to the compression bit number and the current timestamp. After obtaining multiple compressed comparison results, the image retrieval device can cluster a group of images according to the multiple compressed comparison results to obtain clustering results, so as to execute the image retrieval process based on the clustering results.
[0099] In an embodiment of the present application, the image retrieval device clusters a group of images based on multiple compressed comparison results to obtain a clustering result, including: the image retrieval device uses the multiple compressed comparison results as multiple edges; the image retrieval device uses a union-find clustering method to cluster the multiple edges to obtain multiple trees; the image retrieval device merges the multiple trees to obtain a clustering result.
[0100] In the embodiment of the present application, the image retrieval device needs to apply for three HashMap structures in the memory: parent-child relationship<Stringm,String> HashMapParent, refers to the root node of each node in the union-find algorithm; generates a forest <String,List <string>>HashMapForest, used to store the forest generated by the clustering operation; image unique identifier compressed value mapping<String,String> HashMapCompress, used to store the mapping between the compressed value and the real value of the image unique identifier.
[0101] For example, the image retrieval device uses the union-find clustering method to cluster multiple edges, and the process of obtaining multiple trees is as follows: Figure 2 As shown, (Find operation performed in the union-find algorithm). Find the root nodes of the two pictures in their respective trees in the forest, and perform a Get operation on HashMapParent based on the Compressed Key of the picture just generated. If Null is returned, the return value of the Find operation is this Compressed Key, and perform the Put operation of HashMapForest, setting the Value corresponding to the Compressed Key to an empty List. If it is not Null, the corresponding Value is returned. That is, there is an edge between picture A and picture B; there is an edge between picture B and picture C; there is an edge between picture C and picture D; there is an edge between picture B and picture D; there is an edge between picture A and picture C; there is an edge between picture A and picture D; there is an edge between picture E and picture F; after performing the Find operation, we can get a tree consisting of picture A, picture B, picture C, and picture D, and another tree consisting of picture E and picture F.
[0102] For example, the image retrieval device merges multiple trees to obtain a clustering result, such as Figure 3 As shown: (Union operation is performed in the Union-Find algorithm). After the two pictures in the same row have completed the Find operation respectively, the Union operation is performed. This operation is to combine the two trees corresponding to the two pictures into one tree. The results returned by the Find operation of the two pictures are compared as strings, and the smaller Root node is selected as the new Root node, and the two trees are merged into one tree; in the corresponding HashMapForest, the Key and Value List corresponding to the larger Root node are added to the Value List of the smaller Root node, and the larger Root node is deleted. That is, the first tree corresponding to the first picture includes four nodes, K1, K2, K3 and K4; the second tree corresponding to the second picture includes three nodes, K5, K6 and K7; after performing the Union operation, the clustering results include: 7 nodes, K1, K2, K3, K4, K5, K6 and K7. Among them, K1 <K5。
[0103] It should be noted that after all the rows of the result CSV file are processed, a cluster forest of the same version of the image is formed. <String,List <string>>HashMap is stored in memory. A pair of Key Value values in Map is a cluster. To analyze all clusters, you can traverse HashMapForest and then analyze each cluster according to business needs.
[0104] For example, in a mobile phone account registration scenario, we need to compile a list of people who have registered for more than five mobile phone numbers using the same photo in each location. We then group the user ID and location fields using the feature values. After clustering, we count the Key Values whose HashMapForest Value List Size() is greater than 4. For each matching Key and Value List in the HashMapForest, we retrieve all Compressed Key values, obtain the corresponding Original Key from the HashMapCompress, and perform a Split operation on the Original Key to obtain the Meta information for each image.
[0105] It can be understood that when the image retrieval device determines a group of pictures with the same picture description features, the image retrieval device obtains multiple comparison results by comparing the similarity of a group of picture information corresponding to the group of pictures, and obtains the current timestamp when the multiple comparison results are obtained; and determines the number of compression bits for the multiple comparison results based on the number of pictures in a group of pictures; so that the image retrieval device can compress the multiple comparison results according to the compression bit number and the current timestamp to obtain multiple compressed comparison results, thereby reducing the amount of information in the multiple compressed comparison results, and performing the clustering process using the multiple compressed comparison results, thereby improving the speed of clustering pictures and improving the efficiency of picture clustering.
[0106] Example 2
[0107] Based on the same inventive concept of the first embodiment, the embodiment of the present invention provides an image retrieval device 1, corresponding to an image retrieval method; Figure 4 A schematic diagram of the structure of an image retrieval device provided by an embodiment of the present invention Figure 1 , the image retrieval device 1 may include:
[0108] The acquisition unit 10 is configured to, upon determining a group of pictures having the same picture description features, acquire a group of picture information corresponding to the group of pictures; and acquire a current timestamp when the plurality of comparison results are obtained;
[0109] A comparison unit 11 is used to perform a similarity comparison on the set of image information to obtain multiple comparison results;
[0110] A determining unit 12 is configured to determine the number of pictures in the group of pictures; and determine the number of compressed bits of the plurality of comparison results according to the number of pictures;
[0111] A compression unit 13, configured to compress the plurality of comparison results according to the compression bit number and the current timestamp to obtain a plurality of compressed comparison results;
[0112] The clustering unit 14 is configured to cluster the group of images according to the plurality of compressed comparison results to obtain a clustering result, so as to perform an image retrieval process based on the clustering result.
[0113] In some embodiments of the present invention, the apparatus further comprises an adding unit;
[0114] The adding unit is configured to add the current timestamp to the plurality of comparison results to obtain a plurality of added comparison results;
[0115] The acquiring unit 10 is configured to acquire information of the compressed bits starting from the first information bit of the plurality of added comparison results, to obtain a plurality of comparison results of a preset number of bits;
[0116] The compression unit 13 is configured to compress the plurality of comparison results of the preset number of bits using an information summary compression method to obtain the plurality of compressed comparison results.
[0117] In some embodiments of the present invention, the acquisition unit 10 is configured to acquire information about the number of compression bits starting from the first information bit of the multiple added comparison results to obtain multiple initial compression results; if a first compression result and a second compression result in the multiple initial compression results are different, use the multiple initial compression results as the multiple compressed comparison results; the first compression result is any compression result in the multiple initial compression results, and the second compression result is a compression result in the multiple initial compression results other than the first compression result;
[0118] The compression unit 13 is used to continue compressing the first compression result to obtain a first cyclic compression result when the first compression result is the same as the second compression result; until the first cyclic compression result is different from any compression result in the initial compression results, the first cyclic compression result and the remaining compression results in the initial compression results except the first compression result are used as the comparison results of the multiple compressions.
[0119] In some embodiments of the present invention, the apparatus further comprises a generating unit;
[0120] The acquiring unit 10 is configured to acquire two pieces of picture information corresponding to a first picture and a second picture in the set of picture information;
[0121] The determining unit 12 is configured to determine the similarity between the two pieces of image information;
[0122] The generation unit is used to generate a comparison result corresponding to the first image and the second image using the first image description information of the first image and the second image description information of the second image when the similarity is greater than or equal to a preset similarity threshold, until any two images of the set of image information are compared and the multiple comparison results are obtained using a set of image description information of the set of images; the image description feature is part of the information in the set of image description information.
[0123] In some embodiments of the present invention, the apparatus further comprises a merging unit;
[0124] The clustering unit 14 is configured to use the plurality of compressed comparison results as a plurality of edges; cluster the plurality of edges using a union-find clustering method to obtain a plurality of trees;
[0125] The merging unit is used to merge the multiple trees to obtain the clustering result.
[0126] In some embodiments of the present invention, the apparatus further comprises a slicing unit;
[0127] The acquisition unit 10 is configured to, upon receiving an image retrieval instruction, acquire, from a relational database, a plurality of image description information corresponding to a plurality of images; the plurality of image description information including a group of image description information; acquire, from the plurality of image description information, an image description feature corresponding to the image retrieval instruction based on a correspondence between a preset retrieval instruction and a preset feature value; and acquire, from the plurality of images, a plurality of groups of images, the plurality of groups of images including the group of images;
[0128] The slicing unit is configured to slice the multiple pictures according to the picture description features and preset slicing data to obtain multiple pictures.
[0129] In some embodiments of the present invention, the apparatus further comprises a grouping unit and a writing unit;
[0130] The grouping unit is configured to group the plurality of pictures according to the picture description features to obtain the plurality of groups of pictures; and group the plurality of picture description information according to the plurality of groups of pictures to obtain multiple groups of picture description information;
[0131] The writing unit is configured to write the multiple sets of picture description information into a comma-delimited file in rows; one row of the comma-delimited file corresponds to one set of picture description information, and the multiple sets of picture description information include one set of picture description information;
[0132] The fragmentation unit is used to fragment the comma-delimited file according to preset fragmentation data to obtain multiple pieces of picture description information; any piece of picture description information in the multiple pieces of picture description information includes at least one group of picture description information; and the multiple pieces of pictures are obtained according to the multiple piece grouping description information.
[0133] In some embodiments of the present invention, the apparatus further comprises a transmission unit;
[0134] The transmission unit is configured to transmit the multiple pictures to multiple threads respectively;
[0135] The acquisition unit 10 is used to use the first thread among the multiple threads to obtain the first thread picture in the first picture among the multiple pictures, until the multiple thread pictures are respectively obtained from the multiple pictures using the multiple threads; the multiple threads correspond to the multiple thread pictures one by one; any thread picture among the multiple thread pictures includes at least one group of pictures; and the multiple thread pictures are used as the multiple groups of pictures.
[0136] In some embodiments of the present invention, the acquisition unit 10 is used to use the first thread to obtain a first group of pictures in the first piece of pictures, until each group of pictures in the first piece of pictures is obtained from the first piece of pictures, and the first thread pictures are obtained, so as to use the first thread to compare the picture information corresponding to any two pictures in each group of pictures.
[0137] It should be noted that, in actual applications, the above-mentioned acquisition unit 10, comparison unit 11, determination unit 12, compression unit 13 and clustering unit 14 can be implemented by a processor 15 on the image retrieval device 1, specifically a CPU (Central Processing Unit), MPU (Microprocessor Unit), DSP (Digital Signal Processing) or Field Programmable Gate Array (FPGA); the above-mentioned data storage can be implemented by the memory 16 on the image retrieval device 1.
[0138] The embodiment of the present invention also provides a picture retrieval device 1, such as Figure 5 As shown, the image retrieval device 1 includes: a processor 15, a memory 16 and a communication bus 17. The memory 16 communicates with the processor 15 through the communication bus 17. The memory 16 stores a program executable by the processor 15. When the program is executed, the image retrieval method described in Example 1 is executed by the processor 15.
[0139] In practical applications, the memory 16 may be a volatile memory, such as a random-access memory (RAM); or a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or a combination of the above types of memory, and provide instructions and data to the processor 15.
[0140] An embodiment of the present invention provides a storage medium on which a program is stored. When the program is executed by the processor 15, the image retrieval method as described in the first embodiment is implemented.
[0141] It can be understood that when the image retrieval device determines a group of pictures with the same picture description features, the image retrieval device obtains multiple comparison results by comparing the similarity of a group of picture information corresponding to the group of pictures, and obtains the current timestamp when the multiple comparison results are obtained; and determines the number of compression bits for the multiple comparison results based on the number of pictures in a group of pictures; so that the image retrieval device can compress the multiple comparison results according to the compression bit number and the current timestamp to obtain multiple compressed comparison results, thereby reducing the amount of information in the multiple compressed comparison results, and performing the clustering process using the multiple compressed comparison results, thereby improving the speed of clustering pictures and improving the efficiency of picture clustering.
[0142] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage and optical storage, etc.) containing computer-usable program code.
[0143] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0144] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0145] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0146] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention.< / string> < / string>
Claims
1. A picture retrieval method, characterized in that: include: When a group of pictures having the same picture description feature is determined, obtaining a group of picture information corresponding to the group of pictures, and determining the number of pictures in the group of pictures; Performing a similarity comparison on the set of image information to obtain a plurality of comparison results, and obtaining a current timestamp when the plurality of comparison results are obtained; Determining the compression bit number of the plurality of comparison results according to the number of pictures; and compressing the plurality of comparison results according to the compression bit number and the current timestamp to obtain a plurality of compressed comparison results; The group of images is clustered according to the multiple compressed comparison results to obtain a clustering result, so as to perform an image retrieval process based on the clustering result.
2. The method according to claim 1, characterized in that The compressing the plurality of comparison results according to the compression bit number and the current timestamp to obtain a plurality of compressed comparison results includes: Adding the current timestamp to the multiple comparison results to obtain multiple added comparison results; Starting from the first information bit of the plurality of added comparison results, obtaining information of the compressed bit number to obtain a plurality of comparison results of a preset number of bits; The plurality of comparison results of the preset number of bits are compressed using an information summary compression method to obtain the plurality of compressed comparison results.
3. The method according to claim 2, characterized in that The step of obtaining the information of the compressed bits starting from the first information bit of the plurality of added comparison results to obtain the plurality of comparison results of the preset number of bits includes: Starting from the first information bit of the plurality of added comparison results, obtaining information of the number of compressed bits to obtain a plurality of initial compressed results; If a first compression result and a second compression result of the multiple initial compression results are different, the multiple initial compression results are used as the comparison results of the multiple compressed results; the first compression result is any compression result of the multiple initial compression results, and the second compression result is a compression result of the multiple initial compression results other than the first compression result; When the first compression result is the same as the second compression result, continue to compress the first compression result to obtain the first cyclic compression result; until the first cyclic compression result is different from any compression result in the initial compression results, the first cyclic compression result and the remaining compression results in the initial compression results except the first compression result are used as the comparison results after the multiple compressions.
4. The method according to claim 1, wherein The similarity comparison of the set of image information is performed to obtain multiple comparison results, including: Obtaining two pieces of picture information corresponding to the first picture and the second picture in the set of picture information; Determining the similarity between the two pieces of image information; When the similarity is greater than or equal to a preset similarity threshold, the first image description information of the first image and the second image description information of the second image are used to generate comparison results corresponding to the first image and the second image, until any two images of the set of image information are compared, and the multiple comparison results are obtained using a set of image description information of the set of images; the image description feature is part of the information in the set of image description information.
5. The method according to claim 1, wherein Clustering the set of images according to the plurality of compressed comparison results to obtain a clustering result includes: using the plurality of compressed comparison results as a plurality of edges; Clustering the multiple edges using a union-find clustering method to obtain multiple trees; The multiple trees are merged to obtain the clustering result.
6. The method according to claim 1, characterized in that Before obtaining a set of picture information corresponding to the set of pictures, the method further includes: Upon receiving the image retrieval instruction, obtaining a plurality of image description information corresponding to the plurality of images from a relational database; the plurality of image description information includes a set of image description information; According to the correspondence between the preset search instruction and the preset feature value, obtaining the image description feature corresponding to the image search instruction from the plurality of image description information; Slicing the plurality of images according to the image description features and preset slicing data to obtain a plurality of images; A plurality of groups of pictures are obtained from the plurality of pictures, where the plurality of groups of pictures include the group of pictures.
7. The method according to claim 6, characterized in that The step of slicing the plurality of images according to the image description features and the preset slicing data to obtain a plurality of images includes: Grouping the multiple pictures according to the picture description features to obtain the multiple groups of pictures; Grouping the plurality of picture description information according to the plurality of groups of pictures to obtain a plurality of groups of picture description information, and writing the plurality of groups of picture description information into a comma-delimited file in rows; wherein one row of the comma-delimited file corresponds to a group of picture description information, and the plurality of groups of picture description information includes a group of picture description information; Segmenting the comma-delimited file according to preset segmentation data to obtain multiple pieces of picture description information; any piece of picture description information in the multiple pieces of picture description information includes at least one set of picture description information; The multiple pictures are obtained according to the description information of the multiple pictures.
8. The method according to claim 6, characterized in that The obtaining of multiple groups of pictures from the multiple pictures includes: Transmitting the multiple pictures to multiple threads respectively; Obtaining a first thread picture from a first picture in a plurality of pictures using a first thread among the plurality of threads, until obtaining a plurality of thread pictures from the plurality of pictures using the plurality of threads respectively; the plurality of threads corresponding to the plurality of thread pictures one-to-one; any one of the plurality of thread pictures including at least one group of pictures; The plurality of thread pictures are used as the plurality of groups of pictures.
9. The method according to claim 8, characterized in that The obtaining a first thread picture from a first picture of the multiple pictures by using a first thread among the multiple threads includes: The first thread is used to obtain a first group of pictures from the first piece of pictures, until each group of pictures in the first piece of pictures is obtained from the first piece of pictures, and the first thread pictures are obtained, so as to use the first thread to compare the picture information corresponding to any two pictures in each group of pictures.
10. An image retrieval device, characterized in that: The device comprises: An acquiring unit is configured to acquire, when a group of pictures having the same picture description features is determined, a group of picture information corresponding to the group of pictures; and acquire a current timestamp when a plurality of comparison results are obtained; A comparison unit, configured to perform a similarity comparison on the set of image information to obtain a plurality of comparison results; a determining unit, configured to determine the number of pictures in the group of pictures; and determine the number of compressed bits of the plurality of comparison results according to the number of pictures; A compression unit, configured to compress the plurality of comparison results according to the compression bit number and the current timestamp to obtain a plurality of compressed comparison results; A clustering unit is used to cluster the group of pictures according to the multiple compressed comparison results to obtain a clustering result, so as to perform a picture retrieval process based on the clustering result.
11. An image retrieval device, characterized in that: The device comprises: A memory, a processor and a communication bus, wherein the memory communicates with the processor via the communication bus, the memory stores an image retrieval program executable by the processor, and when the image retrieval program is executed, the method according to any one of claims 1 to 9 is executed by the processor.
12. A storage medium, characterized in that: A computer program is stored thereon and is applied to an image retrieval device. When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Video image data retrieval method and device, apparatus and storage medium
CN110609916A
Picture searching method and device, storage medium and electronic equipment
CN111382287A