Picture caching method and device, storage medium and electronic equipment
By clustering and determining the root image of the pictures in electronic devices, only the root image feature maps of similar pictures are cached, which solves the problem of excessive cache space occupancy when loading a large number of pictures, and achieves resource saving and processing efficiency improvement.
Patent Information
- Application Number
- CN202310709334.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-14
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2043-06-14
AI Technical Summary
In electronic devices, when loading a large number of pictures, the prior art requires loading all picture data into the cache, resulting in excessive cache space and wasting system resources.
By obtaining the feature map of the image, performing clustering operations, determining the root image of each group of similar pictures, setting the scan path of the remaining pictures to point to the root image, and only cache the feature map of the root image to reduce the amount of cached data.
It effectively reduces the use of cache space, saves system resources of electronic devices, and improves picture processing efficiency.
Smart Images

Figure CN119155502A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a picture caching method, device, storage medium and electronic device. Background Art
[0002] Electronic devices such as smartphones and tablet computers usually have a camera function, so a large number of pictures are often stored in the electronic devices. When batch processing pictures, such as cleaning pictures, a large number of pictures need to be loaded into a cache first, and then the loaded pictures are processed.
[0003] Currently, when electronic devices load a large number of pictures, they usually load all the picture data into a cache, which takes up a large amount of cache space. Summary of the invention
[0004] The embodiments of the present application provide a method, device, storage medium and electronic device for caching an image, which can reduce the occupation of cache space and save system resources of the electronic device.
[0005] The present application provides a method for caching an image, including:
[0006] Obtain a feature map of each of the multiple images to obtain multiple feature maps;
[0007] Performing a clustering operation on the plurality of feature graphs to obtain a plurality of first similar picture sets, each of the first similar picture sets including at least one of the pictures;
[0008] Determine a first root picture of the first similar picture set, where the first root picture is at least one picture in the first similar picture set;
[0009] Setting the scanning paths of the pictures in the first similar picture set except the first root picture to point to the first root picture;
[0010] Adding a feature map of a first root picture of each of the first similar picture sets to a cache to cache the multiple pictures.
[0011] The embodiment of the present application also provides a picture caching device, including:
[0012] An acquisition module, used to acquire a feature map of each of the multiple images, to obtain multiple feature maps;
[0013] A computing module, configured to perform clustering operations on the plurality of feature graphs to obtain a plurality of first similar picture sets, each of which includes at least one of the pictures;
[0014] A determination module, configured to determine a first root picture of the first similar picture set, where the first root picture is at least one picture in the first similar picture set;
[0015] A setting module, configured to set the scanning path of the pictures in the first similar picture set except the first root picture to point to the first root picture;
[0016] The cache module is used to add the feature map of the first root picture of each of the first similar picture sets to the cache to cache the multiple pictures.
[0017] An embodiment of the present application further provides a storage medium, wherein a computer program is stored in the storage medium. When the computer program is executed on a computer, the computer is enabled to execute the above-mentioned image caching method.
[0018] An embodiment of the present application also provides an electronic device, which includes a processor and a memory, wherein a computer program is stored in the memory, and the processor is used to execute the above-mentioned image storage method by calling the computer program stored in the memory.
[0019] The image caching method of the embodiment of the present application determines the first root image in the first similar image set, and sets the scanning path of the remaining images to point to the first root image. Therefore, when caching multiple images, there is no need to cache the actual data of the multiple images, and only the feature map of the first root image needs to be cached. This can reduce the amount of data added to the cache, thereby reducing the occupancy of the cache space and saving system resources of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application, and those skilled in the art can obtain other drawings based on these drawings without creative work.
[0021] Figure 1 A schematic diagram of an application scenario of the image caching method according to an embodiment of the present application.
[0022] Figure 2 This is a schematic diagram of the first flow chart of the image caching method according to an embodiment of the present application.
[0023] Figure 3 This is a second flow chart of the image caching method according to an embodiment of the present application.
[0024] Figure 4 This is a third flow chart of the image caching method according to an embodiment of the present application.
[0025] Figure 5 Schematic diagram of the structure of the image caching device according to an embodiment of the present application.
[0026] Figure 6 A schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application.
[0028] The embodiment of the present application provides a method for caching an image, which can be applied to an electronic device, such as a smart phone, a tablet computer, a gaming device, an AR (Augmented Reality) device, a data storage device, a video playback device, a laptop computer, a desktop computing device, etc.
[0029] refer to Figure 1 , Figure 1 The following is a schematic diagram of an application scenario of the image caching method of an embodiment of the present application. The image caching method is applied to an electronic device, in which a large number of images are stored, for example, multiple images such as image a to image i are stored. When batch processing is performed on images stored on the electronic device, for example, when cleaning images, multiple images to be processed are first loaded into the cache, for example, images a to image i are loaded into the cache, and then the loaded images a to image i are analyzed and processed to determine which images can be cleaned and which images cannot be cleaned.
[0030] In an example of practical application, the image caching method of an embodiment of the present application can be applied to a scenario in which images in an electronic device are cleaned up. The image caching method can be integrated in an image cleaning tool (SDK), or some implementation steps of the image caching method can be integrated in an image cleaning tool (SDK). The image cleaning tool (SDK) can be, for example, a mobile phone manager, or a module in a mobile phone manager. After a user uses an electronic device for a long time, more and more images, such as photos, QR codes, screenshots, emoticon images, and the like, will be stored in the electronic device. In order to reduce the storage space occupied by a large number of images, an image cleaning tool (SDK) can be used to clean up images. When cleaning images, a large number of images need to be loaded into the cache first, and then the loaded images are analyzed and judged to determine which images can be cleaned up.
[0031] refer to Figure 2 , Figure 2This is a first flow chart of the image caching method according to an embodiment of the present application. The image caching method includes the following steps 110 to 150:
[0032] 110, obtaining a feature map of each of the multiple images to obtain multiple feature maps.
[0033] When multiple images need to be loaded or scanned, the electronic device can obtain a feature map (FeatureMap) of each of the multiple images to obtain multiple feature maps. The feature map can be obtained by calculating the images.
[0034] 120 , performing clustering operation on the multiple feature graphs to obtain multiple first similar picture sets.
[0035] After obtaining multiple feature graphs, the electronic device can perform clustering operations on the multiple feature graphs through a clustering algorithm, for example, performing clustering operations through a clustering algorithm in an image cleaning tool (sdk), and obtaining multiple first similar image sets (similarList). Each first similar image set includes at least one image, and the images in the same first similar image set have similarities, or are understood to be similar images. For example, the multiple first similar image sets obtained may include multiple sets such as landscapes, buildings, animals, flowers, and QR codes. In practical applications, the similarity between the images in each first similar image set can be even higher.
[0036] In practical applications, a clustering model may be integrated in the image cleaning tool (sdk), and the clustering model may be continuously updated. The clustering model may be, for example, a cvNearDup model. The clustering model may perform clustering operations on multiple feature maps through a clustering algorithm to obtain multiple first similar image sets (similarList).
[0037] 130 , determining a first root picture of a first similar picture set.
[0038] After the electronic device obtains multiple first similar picture sets, for each first similar picture set, a first root picture of the first similar picture set is determined. The first root picture is at least one picture in the first similar picture set, for example, it can be one picture, or two pictures, etc. Therefore, for multiple first similar picture sets, multiple first root pictures can be obtained. Among them, the root picture can be understood as the basic picture of the first similar picture set, and other pictures in the same first similar picture set can be understood as pictures with a high similarity to the root picture.
[0039] For example, the first similar picture set includes 9 pictures, one of which is determined to be the first root picture, then the first root picture is the basic picture, and the remaining 8 pictures are highly similar to the first root picture.
[0040] 140 , setting the scanning paths of the pictures in the first similar picture set except the first root picture to point to the first root picture.
[0041] After the first root picture of the first similar picture set is determined, the scanning paths of the pictures in the first similar picture set except the first root picture may be set to point to the first root picture, and the remaining pictures are represented by the first root picture.
[0042] For example, the first similar picture set includes 9 pictures, of which 1 picture is the first root picture, then the scanning paths of the remaining 8 pictures can be set to point to the first root picture, and the remaining 8 pictures are represented by the first root picture. Therefore, when it is necessary to scan all pictures in the first similar picture set, only the first root picture needs to be scanned to obtain all pictures.
[0043] 150 , adding a feature map of a first root picture of each first similar picture set to a cache, so as to cache the multiple pictures.
[0044] The electronic device can add the feature graph of the first root image of each first similar image set to the cache to cache the multiple images. It can be understood that in each first similar image set, except for the first root image, the remaining images all point to the first root image, so by caching the feature graph of the first root image, multiple images in the first similar image set can be cached. Therefore, the electronic device adds the feature graph of the first root image of each first similar image set to the cache to cache all images in multiple first similar image sets.
[0045] The image caching method of the embodiment of the present application determines the first root image in the first similar image set, and sets the scanning path of the remaining images to point to the first root image. Therefore, when caching multiple images, there is no need to cache the actual data of the multiple images, and only the feature map of the first root image needs to be cached. This can reduce the amount of data added to the cache, thereby reducing the occupancy of the cache space and saving system resources of the electronic device.
[0046] In some embodiments, reference Figure 3 , Figure 3 This is a second flow chart of the image caching method according to an embodiment of the present application. In step 110, before obtaining a feature map of each of the multiple images, the following steps are also included:
[0047] 162, determining in sequence whether each of the plurality of pictures has a corresponding second root picture;
[0048] 163. If the image has a corresponding second root image, a feature map of the second root image is calculated and used as the feature map of the image.
[0049] It is understandable that in practical applications, the image caching method of the present application can be performed in a loop to continuously update the cache of the electronic device. Therefore, when executing the program flow, some images may have been processed once or multiple times, so that some images already have corresponding root images, which are defined as second root images in the embodiment of the present application; and some images may be newly added to the electronic device and have not been processed, so there is no corresponding second root image.
[0050] Therefore, when the program flow starts to execute, when the electronic device loads multiple pictures, it can judge each picture in turn to determine whether there is a corresponding second root picture for the picture. If there is a corresponding second root picture for the picture, it means that the picture has been processed once or multiple times, and the system has set a second root picture to point to for the picture, and the scan path of the picture points to the storage path of the second root picture. Therefore, the feature map of the second root picture can be calculated and used as the feature map of the picture. In practical applications, after obtaining the feature map of the picture, the picture information and the feature map can be put into the cache.
[0051] It should be noted that the electronic device can perform the above judgment on each of the multiple pictures that need to be loaded or scanned. For a picture that has a corresponding second root picture, the feature map of the second root picture is calculated as the feature map of the picture. For a picture that does not have a second root picture, other processing can be continued.
[0052] In some embodiments, continue to refer to Figure 3 Before step 162, sequentially determining whether each of the plurality of pictures has a corresponding second root picture, the following steps are also included:
[0053] 161, reading a cache, wherein at least one second similar picture set is loaded in the cache;
[0054] Step 162, after determining in sequence whether each of the plurality of pictures has a corresponding second root picture, the following steps are also included:
[0055] 164, if the image does not have a corresponding second root image, determine whether the image is loaded into a second similar image set in the cache;
[0056] 165. If the image is not loaded into the second similar image set in the cache, a feature map of the image is calculated.
[0057] It is understandable that in practical applications, the image caching method of the present application can be performed in a loop to continuously update the cache of the electronic device. Therefore, when executing the program flow, a similar image set may already exist in the electronic device, for example, a similar image set obtained by clustering operation when the program flow was previously executed, which is defined as a second similar image set in the embodiment of the present application, and the second similar image set can be loaded in the cache (similarCache).
[0058] Therefore, when the program flow starts to be executed, the electronic device can read the cache before loading multiple pictures. The cache is loaded with at least one second similar picture set, and each second similar picture set includes at least one picture. Similarly, pictures in the same second similar picture set have similarity, or are understood as similar pictures.
[0059] When the electronic device determines whether there is a corresponding second root picture for a picture, if the judgment result is that there is no corresponding second root picture for the picture, it further determines whether the picture is loaded in the second similar picture set in the cache. It should be noted that if there are multiple second similar picture sets loaded in the cache, it is necessary to compare the picture with the pictures in each second similar picture set in the cache in turn to determine whether the picture is loaded in the second similar picture set. If the picture is different from all the pictures in each second similar picture set, it is determined that the picture is not loaded in the second similar picture set in the cache. If the picture is the same as a picture in a second similar picture set, it is determined that the picture is loaded in the second similar picture set in the cache.
[0060] If the judgment result is that the image is not loaded into the second similar image set in the cache, a feature map of the image is calculated. After the feature map is calculated, the image information and the feature map can be put into the cache. If the judgment result is that the image is loaded into the second similar image set in the cache, other processing can be continued.
[0061] It should be noted that, for multiple pictures that need to be loaded or scanned, the electronic device needs to perform the above-mentioned judgment and processing for all pictures that do not have corresponding second root pictures.
[0062] In some embodiments, continue to refer to Figure 3 After step 164, determining whether the image is loaded in the second similar image set in the cache, the following steps are also included:
[0063] 166, decoding the picture to obtain a score of the picture, until a score of each picture in the second similar picture set is obtained;
[0064] 167, determining a third root picture from the second similar picture set according to the score of each picture in the second similar picture set;
[0065] 168, calculate and obtain a feature map of the third root image, and use the feature map of the third root image as the feature map of each image in the second similar image set.
[0066] When the electronic device determines whether the image is loaded in the second set of similar images in the cache, if the judgment result is that the image is loaded in the second set of similar images in the cache, the image is decoded to calculate the score of the image. In an application example, the score of the image is used to represent the blurriness of the image. The higher the blurriness, the lower the score of the image, and the lower the blurriness, the higher the score of the image. In actual applications, there are many ways to obtain the score of the image. For example, the blurriness of the image can be directly analyzed by an algorithm to obtain the corresponding score.
[0067] It should be noted that for multiple pictures that need to be loaded or scanned, for all pictures in the second similar picture set that do not have a corresponding second root picture and are loaded in the cache, the electronic device needs to decode the pictures to obtain the scores of the pictures until the scores of each picture in each second similar picture set are obtained.
[0068] Subsequently, a third root picture is determined from the second similar picture set according to the score of each picture in the second similar picture set. The third root picture can be understood as a base picture of the second similar picture set. In one embodiment, the picture with the highest score in the second similar picture set can be determined as the third root picture, that is, the picture with the lowest blur can be determined as the third root picture.
[0069] After determining the third root picture, the feature map of the third root picture is calculated, and the feature map of the third root picture is used as the feature map of each picture in the second similar picture set. Subsequently, the information of each picture in the second similar picture set and the feature map of the third root picture can be put into the cache. It can be understood that after determining the third root picture, the scanning path of each picture in the second similar picture set can also be set to point to the third root picture. If multiple second similar picture sets are loaded in the cache, the third root picture of each second similar picture set is obtained in turn, and the feature map of the third root picture is used as the feature map of each picture in the second similar picture set.
[0070] In the embodiment of the present application, after the above-mentioned processing in various ways, i.e., processing in step 163, step 165, and step 168, a feature map of each of the multiple pictures that need to be loaded or scanned can be obtained. Then, step 110 can be executed, i.e., obtaining a feature map of each picture.
[0071] In some embodiments, reference Figure 4 , Figure 4 This is a third flow chart of the image caching method of the embodiment of the present application. In which, step 130, determining the first root image of the first similar image set, includes the following steps:
[0072] 131, read the cache, and at least one fourth root image is loaded in the cache;
[0073] 132, determining whether the first similar picture set includes a picture that is the same as the fourth picture;
[0074] 133. If the first similar picture set includes a picture identical to the fourth root picture, determine the picture identical to the fourth root picture as a first root picture of the first similar picture set.
[0075] It is understandable that in practical applications, the image caching method of the present application can be performed in a loop to continuously update the cache of the electronic device. Therefore, when executing the program flow, the cache of the electronic device may have loaded one or more root images, for example, one or more feature images of the root images have been loaded, which is defined as the fourth root image in the embodiment of the present application. For example, the fourth root image can be the root image of the set of similar images loaded in the cache, such as the root image of the second set of similar images.
[0076] After obtaining a plurality of first similar picture sets, the electronic device may read a cache, in which at least one fourth root picture is loaded, for example, a feature map of at least one fourth root picture is loaded. Subsequently, each picture in the first similar picture set is sequentially compared with the fourth root picture to determine whether the first similar picture set includes a picture identical to the fourth root picture.
[0077] If the first similar picture set includes the same picture as the fourth root picture, the same picture as the fourth root picture is determined as the first root picture of the first similar picture set. If the first similar picture set does not include the same picture as the fourth root picture, other processing can be continued.
[0078] In some embodiments, continue to refer to Figure 4 Step 130, determining the first root image of the first similar image set, further comprising the following steps:
[0079] 134. If the first similar picture set does not include a picture that is the same as the fourth picture, obtain a score of each picture in the first similar picture set;
[0080] 135 , determine the picture with the highest score in the first similar picture set as the first root picture of the first similar picture set.
[0081] If the first similar picture set does not include a picture that is the same as the fourth root picture, the score of each picture in the first similar picture set is obtained. In an application example, the score of a picture is used to indicate the blurriness of the picture. The higher the blurriness, the lower the score of the picture, and the lower the blurriness, the higher the score of the picture. Among them, for pictures whose scores have been calculated, such as pictures whose scores have been obtained by decoding in step 166, their scores can be directly obtained. For pictures whose scores have not been calculated, the pictures can be decoded to calculate the scores of the pictures. Thus, the scores of each picture can be obtained.
[0082] Subsequently, the picture with the highest score in the first similar picture set is determined as the first root picture of the first similar picture set, that is, the picture with the lowest blur is determined as the first root picture.
[0083] In specific implementation, the present application is not limited by the execution order of the various steps described. If no conflict occurs, some steps can be performed in other orders or simultaneously.
[0084] As can be seen from the above, the image caching method provided in the embodiment of the present application includes: obtaining a feature map of each image in a plurality of images to obtain a plurality of feature maps; performing clustering operations on the plurality of feature maps to obtain a plurality of first similar image sets; determining a first root image of the first similar image set; setting the scanning path of the images other than the first root image in the first similar image set to point to the first root image; adding the feature map of the first root image of each first similar image set to the cache to cache the plurality of images. In the image caching method in the embodiment of the present application, by determining the first root image in the first similar image set, the scanning paths of the remaining images are set to point to the first root image. Therefore, when caching a plurality of images, it is not necessary to cache the actual data of the plurality of images, and only the feature map of the first root image needs to be cached. This can reduce the amount of data added to the cache, thereby reducing the occupation of the cache space and saving system resources of the electronic device.
[0085] The embodiment of the present application also provides an image caching device, which can be integrated in an electronic device. The electronic device can be a smart phone, a tablet computer, a gaming device, an AR (Augmented Reality) device, a data storage device, a video playback device, a laptop computer, a desktop computing device, etc.
[0086] refer to Figure 5 , Figure 5 2 is a schematic diagram of the structure of the image caching device 200 according to an embodiment of the present application. The image caching device 200 includes an acquisition module 210 , a calculation module 220 , a determination module 230 , a setting module 240 and a cache module 250 .
[0087] An acquisition module 210 is used to acquire a feature map of each of the multiple pictures to obtain multiple feature maps;
[0088] A computing module 220, configured to perform clustering operations on the plurality of feature graphs to obtain a plurality of first similar picture sets;
[0089] A determination module 230, configured to determine a first root image of a first similar image set;
[0090] A setting module 240, configured to set the scanning path of the pictures in the first similar picture set except the first root picture to point to the first root picture;
[0091] The cache module 250 is configured to add the feature map of the first root picture of each first similar picture set to the cache, so as to cache the multiple pictures.
[0092] In some embodiments, before obtaining a feature map of each of the multiple pictures, the obtaining module 210 is further used to:
[0093] Determine in sequence whether each of the multiple pictures has a corresponding second root picture;
[0094] If the image has a corresponding second root image, the feature map of the second root image is calculated and used as the feature map of the image.
[0095] In some embodiments, before sequentially determining whether each of the plurality of pictures has a corresponding second root picture, the acquisition module 210 is further configured to:
[0096] Reading a cache, wherein at least one second similar picture set is loaded in the cache;
[0097] After sequentially determining whether each of the plurality of pictures has a corresponding second root picture, the acquisition module 210 is further used to:
[0098] If the picture does not have a corresponding second root picture, determining whether the picture is loaded in the second similar picture set in the cache;
[0099] If the image is not loaded in the second similar image set in the cache, a feature map of the image is calculated.
[0100] In some embodiments, after determining whether the image is loaded in the second similar image set in the cache, the acquisition module 210 is further configured to:
[0101] Decoding the picture to obtain a score of the picture, until a score of each picture in the second similar picture set is obtained;
[0102] determining a third root image from the second similar image set according to the score of each image in the second similar image set;
[0103] The feature map of the third root image is calculated and used as the feature map of each image in the second similar image set.
[0104] In some embodiments, the determination module 230 is configured to:
[0105] Read the cache, which contains at least one fourth root image;
[0106] Determine whether the first similar picture set includes a picture that is the same as the fourth picture;
[0107] If the first similar picture set includes the picture identical to the fourth root picture, the picture identical to the fourth root picture is determined as the first root picture of the first similar picture set.
[0108] In some embodiments, the determination module 230 is further configured to:
[0109] If the first similar picture set does not include a picture that is the same as the fourth picture, obtaining a score for each picture in the first similar picture set;
[0110] The picture with the highest score in the first similar picture set is determined as the first root picture of the first similar picture set.
[0111] It can be understood that the specific implementation of each of the above modules can refer to the description of the above image caching method, which will not be repeated here.
[0112] In specific implementation, the above modules can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same entity or several entities.
[0113] As can be seen from the above, the image caching device 200 provided in the embodiment of the present application obtains the feature map of each image in the multiple images through the acquisition module 210 to obtain multiple feature maps; the operation module 220 performs clustering operation on the multiple feature maps to obtain multiple first similar image sets; the determination module 230 determines the first root image of the first similar image set; the setting module 240 sets the scanning path of the images other than the first root image in the first similar image set to point to the first root image; the cache module 250 adds the feature map of the first root image of each first similar image set to the cache to cache the multiple images. The image caching device 200 in the embodiment of the present application determines the first root image in the first similar image set and sets the scanning path of the remaining images to point to the first root image. Therefore, when caching multiple images, it is not necessary to cache the actual data of the multiple images, but only the feature map of the first root image needs to be cached, which can reduce the amount of data added to the cache, thereby reducing the occupation of the cache space and saving system resources of the electronic device.
[0114] The embodiment of the present application also provides an electronic device. The electronic device may be a smart phone, a tablet computer, a gaming device, an AR (Augmented Reality) device, a data storage device, a video playback device, a laptop computer, a desktop computing device, etc.
[0115] refer to Figure 6 , Figure 6 Schematic diagram of the structure of an electronic device 300 according to an embodiment of the present application.
[0116] The electronic device 300 includes a processor 310 and a memory 320. The processor 310 is electrically connected to the memory 320.
[0117] The processor 310 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device, executes various functions of the electronic device and processes data by running or calling computer programs stored in the memory 320, and calling data stored in the memory 320, thereby monitoring the electronic device as a whole.
[0118] The memory 320 may be used to store computer programs and data. The computer programs stored in the memory 320 include instructions that can be executed in the processor. The computer programs may constitute various functional modules. The processor 310 executes various functional applications and data processing by calling the computer programs stored in the memory 320.
[0119] In the embodiment of the present application, the processor 310 in the electronic device 300 loads instructions corresponding to the processes of one or more computer programs into the memory 320 according to the following steps, and the processor 310 runs the computer program stored in the memory 320, thereby performing the following steps:
[0120] Obtain a feature map of each of the multiple images to obtain multiple feature maps;
[0121] Performing clustering operation on the multiple feature graphs to obtain multiple first similar picture sets;
[0122] Determine a first root picture of a first similar picture set;
[0123] Setting the scanning paths of the pictures in the first similar picture set except the first root picture to point to the first root picture;
[0124] The feature map of the first root picture of each first similar picture set is added to the cache to cache the multiple pictures.
[0125] In some embodiments, before obtaining a feature map of each of the multiple pictures, the processor 310 further performs the following steps:
[0126] Determine in sequence whether each of the multiple pictures has a corresponding second root picture;
[0127] If the image has a corresponding second root image, the feature map of the second root image is calculated and used as the feature map of the image.
[0128] In some embodiments, before sequentially determining whether each of the plurality of pictures has a corresponding second root picture, the processor 310 further performs the following steps:
[0129] Reading a cache, wherein at least one second similar picture set is loaded in the cache;
[0130] After sequentially determining whether each of the multiple pictures has a corresponding second root picture, the processor 310 further performs the following steps:
[0131] If the picture does not have a corresponding second root picture, determining whether the picture is loaded in the second similar picture set in the cache;
[0132] If the image is not loaded in the second similar image set in the cache, a feature map of the image is calculated.
[0133] In some embodiments, after determining whether the image is loaded in the second similar image set in the cache, the processor 310 further performs the following steps:
[0134] Decoding the picture to obtain a score of the picture, until a score of each picture in the second similar picture set is obtained;
[0135] determining a third root image from the second similar image set according to the score of each image in the second similar image set;
[0136] The feature map of the third root image is calculated and used as the feature map of each image in the second similar image set.
[0137] In some embodiments, when determining the first root picture of the first similar picture set, the processor 310 performs the following steps:
[0138] Read the cache, which contains at least one fourth root image;
[0139] Determine whether the first similar picture set includes a picture that is the same as the fourth picture;
[0140] If the first similar picture set includes the picture identical to the fourth root picture, the picture identical to the fourth root picture is determined as the first root picture of the first similar picture set.
[0141] In some embodiments, when determining the first root picture of the first similar picture set, the processor 310 further performs the following steps:
[0142] If the first similar picture set does not include a picture that is the same as the fourth picture, obtaining a score for each picture in the first similar picture set;
[0143] The picture with the highest score in the first similar picture set is determined as the first root picture of the first similar picture set.
[0144] although Figure 6 Not shown, the electronic device 300 may also include a display screen, a control circuit, an input / output unit, a camera module, etc., which will not be described in detail here.
[0145] As can be seen from the above, an embodiment of the present application provides an electronic device, which performs the following steps: obtaining a feature map of each of a plurality of pictures to obtain a plurality of feature maps; performing clustering operations on the plurality of feature maps to obtain a plurality of first similar picture sets; determining a first root picture of the first similar picture set; setting the scan path of pictures other than the first root picture in the first similar picture set to point to the first root picture; adding the feature map of the first root picture of each first similar picture set to a cache to cache the plurality of pictures. The electronic device determines the first root picture in the first similar picture set and sets the scan path of the remaining pictures to point to the first root picture. Therefore, when caching a plurality of pictures, it is not necessary to cache the actual data of the plurality of pictures, but only the feature map of the first root picture needs to be cached, which can reduce the amount of data added to the cache, thereby reducing the occupation of the cache space and saving system resources of the electronic device.
[0146] An embodiment of the present application further provides a storage medium, in which a computer program is stored. When the computer program is executed on a computer, the computer executes the image storage method of any of the above embodiments.
[0147] It should be noted that a person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the storage medium may include but is not limited to: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0148] In the description of this application, it should be understood that terms such as "first" and "second" are only used to distinguish similar objects and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features.
[0149] The above is a detailed introduction to the image caching method, device, storage medium and electronic device provided in the embodiments of the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application; at the same time, for those skilled in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for caching an image, characterized in that: include: Obtain a feature map of each of the multiple images to obtain multiple feature maps; performing a clustering operation on the plurality of feature maps to obtain a plurality of first similar picture sets, each of the first similar picture sets including at least one of the pictures; Determine a first root picture of the first similar picture set, where the first root picture is at least one picture in the first similar picture set; Setting the scanning paths of pictures in the first similar picture set other than the first root picture to point to the first root picture; Adding a feature map of a first root picture of each of the first similar pictures sets to a cache to cache the multiple pictures.
2. The image caching method according to claim 1, wherein: Before obtaining the feature map of each of the multiple images, the method further includes: Determine in sequence whether each of the multiple images has a corresponding second root image; If the picture has a corresponding second root picture, a feature map of the second root picture is calculated and used as the feature map of the picture.
3. The image caching method according to claim 2, wherein: Before sequentially determining whether each of the plurality of pictures has a corresponding second root picture, the method further includes: Reading a cache, wherein the cache is loaded with at least one second similar picture set, wherein the second similar picture set includes at least one picture; After sequentially determining whether each of the plurality of pictures has a corresponding second root picture, the method further includes: If the picture does not have a corresponding second root picture, determining whether the picture is loaded in a second similar picture set in the cache; If the picture is not loaded in the second similar picture set in the cache, a feature map of the picture is calculated.
4. The image caching method according to claim 3, wherein: After determining whether the picture is loaded into the second similar picture set in the cache, the method further includes: If the picture is loaded in the second similar picture set in the cache, decoding the picture to obtain a score of the picture, until a score of each picture in the second similar picture set is obtained; determining a third root image from the second set of similar images according to the score of each image in the second set of similar images; A feature map of the third root image is obtained by calculation, and the feature map of the third root image is used as the feature map of each image in the second similar image set.
5. The image caching method according to any one of claims 1 to 4, characterized in that: The determining of the first root picture of the first similar picture set includes: Reading a cache, wherein the cache has at least one fourth root image loaded therein; Determining whether the first similar picture set includes a picture that is the same as the fourth picture; If the first similar picture set includes a picture identical to the fourth root picture, the picture identical to the fourth root picture is determined as the first root picture of the first similar picture set.
6. The image caching method according to claim 5, wherein: The determining of the first root picture of the first similar picture set further includes: If the first similar picture set does not include a picture identical to the fourth picture, obtaining a score for each picture in the first similar picture set; The picture with the highest score in the first similar picture set is determined as the first root picture of the first similar picture set.
7. The image caching method according to claim 6, wherein: The score is used to represent the blurriness of the image, and the higher the blurriness of the image, the lower the score.
8. A picture caching device, characterized in that: include: An acquisition module, configured to acquire a feature map of each of the plurality of images, thereby obtaining a plurality of feature maps; a computing module, configured to perform a clustering operation on the plurality of feature maps to obtain a plurality of first similar picture sets, each of the first similar picture sets including at least one of the pictures; a determining module, configured to determine a first root picture of the first similar picture set, where the first root picture is at least one picture in the first similar picture set; A setting module, configured to set the scanning paths of pictures in the first similar picture set other than the first root picture to point to the first root picture; The cache module is configured to add a feature map of a first root image of each of the first similar image sets to a cache, so as to cache the plurality of images.
9. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is run on a computer, the computer is enabled to execute the image caching method according to any one of claims 1 to 7.
10. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to execute the image caching method according to any one of claims 1 to 7 by running the computer program stored in the memory.
Citation Information
Patent Citations
Management method and device for caching images and client side
CN103885753A
Similar image clustering method and device, storage medium and electronic equipment
CN109697451A
Picture processing method and apparatus
WO2021036906A1
