Picture caching method and device, storage medium and electronic equipment
By generating a set of similar images in electronic devices and determining the root image, and caching only the storage path and feature map of the root image, the problem of loading a large number of images and occupying cache space is solved, thus achieving efficient utilization of cache space.
Patent Information
- Application Number
- CN202310710469.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-14
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-06-14
AI Technical Summary
In electronic devices, existing technologies require a large amount of cache space when loading a large number of images, resulting in a waste of system resources.
By acquiring the feature maps of images, clustering operations are performed to generate a set of similar images. A root image is then determined within the set, and the scanning paths of other images are directed to the root image. Only the storage path and feature maps of the root image are cached, reducing the amount of actual data cached.
It effectively reduces the amount of cache space occupied, saving system resources for electronic devices.
Smart Images

Figure CN119155503B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an image caching method, apparatus, storage medium, and electronic device. Background Technology
[0002] Electronic devices such as smartphones and tablets typically have camera functions, so they often store a large number of images. When processing images in batches, such as when cleaning up images, it is necessary to first load a large number of images into a cache before processing them.
[0003] Currently, when electronic devices load a large number of images, they typically load all the image data into the cache, which requires a significant amount of cache space. Summary of the Invention
[0004] This application provides an image caching method, apparatus, storage medium, and electronic device, which can reduce the occupation of cache space and save system resources of electronic devices.
[0005] This application provides an image caching method, including:
[0006] Obtain the feature map of each of the multiple images to obtain multiple feature maps;
[0007] Clustering operations are performed on the multiple feature maps to obtain multiple first similar image sets, each first similar image set including at least one of the images;
[0008] Determine the first image in the first set of similar images, wherein the first image is at least one image in the first set of similar images;
[0009] Set the scanning path of all images in the first set of similar images except the first root image to point to the first root image;
[0010] The storage path of the first root image in each of the first similar image sets and the feature map of the first root image are added to the cache to cache the multiple images.
[0011] This application embodiment also provides an image caching device, including:
[0012] The acquisition module is used to acquire the feature map of each of multiple images, resulting in multiple feature maps.
[0013] The calculation module is used to perform clustering operations on the multiple feature maps to obtain multiple first similar image sets, each first similar image set including at least one of the images;
[0014] The determining module is used to determine the first image in the first similar image set, wherein the first image is at least one image in the first similar image set;
[0015] The setting module is used to set the scanning path of the images in the first similar image set, excluding the first root image, to point to the first root image.
[0016] The caching module is used to add the storage path of the first root image of each of the first similar image sets and the feature map of the first root image to the cache, so as to cache the multiple images.
[0017] This application embodiment also provides a storage medium storing a computer program, which, when run on a computer, causes the computer to execute the above-described image caching method.
[0018] This application also provides an electronic device, which includes a processor and a memory. The memory stores a computer program, and the processor executes the above-described image storage method by calling the computer program stored in the memory.
[0019] The image caching method of this application determines the first root image in the first set of similar images 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. Only the storage path of the first root image and the feature map of the first image need to be cached. This can reduce the amount of data added to the cache, thereby reducing the occupation of cache space and saving system resources of electronic devices. Attached Figure Description
[0020] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a schematic diagram illustrating an application scenario of the image caching method according to an embodiment of this application.
[0022] Figure 2 This is a schematic diagram of the first type of image caching method according to an embodiment of this application.
[0023] Figure 3 This is a schematic diagram of the second process of the image caching method according to an embodiment of this application.
[0024] Figure 4This is a schematic diagram of the third process of the image caching method according to an embodiment of this application.
[0025] Figure 5 This is a schematic diagram of the image caching device according to an embodiment of this application.
[0026] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the protection scope of this application.
[0028] This application provides an image caching method that can be applied to electronic devices. These electronic devices can be smartphones, tablets, gaming devices, AR (Augmented Reality) devices, data storage devices, video playback devices, laptops, desktop computing devices, etc.
[0029] refer to Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of the image caching method according to an embodiment of this application. The image caching method is applied to an electronic device that stores a large number of images, such as images a to i. When performing batch processing on the images stored on the electronic device, such as image cleaning, the multiple images to be processed are first loaded into the cache, for example, images a to i are loaded into the cache. Then, the loaded images a to i are analyzed and processed to determine which images can be cleaned and which images cannot be cleaned.
[0030] In a practical application example, the image caching method of this embodiment can be applied to a scenario of cleaning up images in an electronic device. The image caching method can be integrated into an image cleaning tool (SDK), or some implementation steps of the image caching method can be integrated into the image cleaning tool (SDK). The image cleaning tool (SDK) can be, for example, a mobile phone manager or a module within a mobile phone manager. After prolonged use of an electronic device, the device will store an increasing number of images, such as photos, QR codes, screenshots, emoticons, etc. To reduce the storage space occupied by a large number of images, an image cleaning tool (SDK) can be used for image cleaning. During image cleaning, 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.
[0031] refer to Figure 2 , Figure 2 This is a schematic diagram of a first embodiment of the image caching method of this application. The image caching method includes the following steps:
[0032] 110. Obtain the feature map of each of the multiple images to obtain multiple feature maps.
[0033] When loading or scanning multiple images, electronic devices can acquire feature maps of each image to obtain multiple feature maps. These feature maps can be calculated from the images.
[0034] 120. Perform clustering operations on multiple feature maps to obtain multiple sets of first similar images.
[0035] After obtaining multiple feature maps, electronic devices can perform clustering operations on these feature maps using clustering algorithms. For example, clustering operations can be performed using the clustering algorithm in an image cleaning tool (SDK) to obtain multiple sets of first similar images (similarList). Each set of first similar images includes at least one image, and images within the same set are similar, or can be understood as similar images. For example, the resulting sets of first similar images could include multiple sets of landscapes, buildings, animals, flowers, plants, QR codes, etc. In practical applications, the similarity between images within each set of first similar images can be even higher.
[0036] In practical applications, image cleanup tools (SDKs) can integrate clustering models, and these models can be continuously updated. For example, a cvNearDup model can be used. Clustering models can perform clustering operations on multiple feature maps using clustering algorithms to obtain multiple sets of first-similar images (similarLists).
[0037] 130, Determine the first image in the first set of similar images.
[0038] After obtaining multiple sets of first similar images, the electronic device determines the first root image for each set. The first root image is at least one image in the first similar image set; for example, it can be one image, two images, or so on. Therefore, for multiple sets of first similar images, multiple first root images can be obtained. The root image can be understood as the basic image of the first similar image set, and other images in the same set can be understood as images that are highly similar to the root image.
[0039] For example, the first set of similar images includes 9 images, one of which is identified as the first root image. This first root image is the base image, and the remaining 8 images are highly similar to the first root image.
[0040] 140. Set the scan paths of all images in the first set of similar images, excluding the first image, to point to the first image.
[0041] After determining the first root image of the first similar image set, the scanning paths of all images in the first similar image set except the first root image can be set to point to the first root image, and the first root image can represent the remaining images.
[0042] For example, if the first set of similar images includes 9 images, with one image serving as the first root image, then the scan paths for the remaining 8 images can all be set to point to this first root image, using the first root image to represent the other 8 images. Therefore, when scanning all images in the first set of similar images is required, only the first root image needs to be scanned to obtain all the images.
[0043] 150. Add the storage path of the first root image of each first similar image set and the feature map of the first root image to the cache to cache the multiple images.
[0044] An electronic device can add the storage path and feature map of the first image in each set of first similar images to its cache to cache multiple images. It's understandable that in each set of first similar images, all images except the first image point to the first image; therefore, caching the storage path and feature map of the first image allows caching of multiple images within the first set of similar images. Thus, by adding the storage path and feature map of the first image in each set of first similar images to its cache, the electronic device can cache all images in multiple sets of first similar images.
[0045] The image caching method of this application determines the first root image in the first set of similar images 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. Only the storage path of the first root image and the feature map of the first image need to be cached. This can reduce the amount of data added to the cache, thereby reducing the occupation of cache space and saving system resources of electronic devices.
[0046] In some embodiments, reference Figure 3 , Figure 3This is a schematic diagram of a second process for an image caching method according to an embodiment of this application. Before step 110, which involves obtaining the feature map of each of the multiple images, the method further includes the following steps:
[0047] 162. Determine in turn whether each of the multiple images has a corresponding second image;
[0048] 163. If a corresponding second image exists, the feature map of the second image is calculated and used as the feature map of the image.
[0049] Understandably, in practical applications, the image caching method of this application can be performed cyclically to continuously update the cache of the electronic device. Therefore, during the execution of the program flow, some images may have already been processed once or multiple times, resulting in some images already having a corresponding root image, defined as the second root image in this embodiment; while some images may be newly added to the electronic device without processing, and therefore do not have a corresponding second root image.
[0050] Therefore, when the program flow begins, the electronic device, while loading multiple images, can sequentially check each image to determine if a corresponding second image exists. If a second image exists, it means that the image has already been processed once or multiple times, and the system has already assigned a second image to it, with the image's scan path pointing to the storage path of the second image. Therefore, the feature map of the second image can be calculated and used as the feature map of the current image. In practical applications, after obtaining the image's feature map, the image information and the feature map can be stored in a cache.
[0051] It should be noted that the electronic device can perform the above judgment on each of the multiple images to be loaded or scanned. For images that have a corresponding second image, the feature map of the second image is calculated and used as the feature map of the image. For images that do not have a second image, other processing can continue.
[0052] In some embodiments, continue to refer to Figure 3 Before step 162, which sequentially determines whether each of the multiple images has a corresponding second image, the following steps are also included:
[0053] 161. Read the cache, which contains at least one set of second similar images;
[0054] Step 162, after sequentially determining whether each of the multiple images has a corresponding second image, also includes the following steps:
[0055] 164. If there is no corresponding second image for the image, then determine whether the image is loaded into the second similar image set in the cache;
[0056] 165. If the image is not loaded into the second set of similar images in the cache, then the feature map of the image is calculated.
[0057] Understandably, in practical applications, the image caching method of this application can be performed cyclically to continuously update the cache of the electronic device. Therefore, when the program flow is executed, a set of similar images may already exist in the electronic device. For example, it can be a set of similar images obtained through clustering operations during the previous execution of the program flow, which is defined as the second similar image set in this embodiment of the application. The second similar image set can be loaded into the cache (similarCache).
[0058] Therefore, when the program flow begins, the electronic device can read from the cache before loading multiple images. The cache contains at least one set of second-similar images, and each set includes at least one image. Similarly, images within the same set of second-similar images are similar, or can be understood as similar images.
[0059] When an electronic device determines whether an image has a corresponding second image, if the result is that the image does not have a corresponding second image, it further checks whether the image is loaded into a cached set of second similar images. It should be noted that if multiple sets of second similar images are loaded in the cache, the image needs to be compared sequentially with images in each of the cached sets to determine if it is loaded into a set. If the image is different from all images in every set of second similar images, it is determined that the image is not loaded into a cached set of second similar images. If the image is the same as an image in a set of second similar images, it is determined that the image is loaded into a cached set of second similar images.
[0060] If the result indicates that the image is not in the second set of similar images cached, then the feature map of that image is calculated. After calculating the feature map, the image information and the feature map can be placed in the cache. If the result indicates that the image is in the second set of similar images cached, then further processing can proceed.
[0061] It should be noted that for multiple images that need to be loaded or scanned, the electronic device needs to perform the above judgment and processing for all images for which there is no corresponding second image.
[0062] In some embodiments, continue to refer to Figure 3 After step 164, which determines whether the image is loaded into the second set of similar images in the cache, the following steps are also included:
[0063] 166. Decode the images to obtain their scores, and continue until you obtain the score for each image in the second set of similar images;
[0064] 167. Determine the third image from the second set of similar images based on the score of each image in the second set of similar images;
[0065] 168. Calculate the feature map of the third image, and use the feature map of the third image as the feature map of each image in the second set of similar images.
[0066] When an electronic device determines whether an image is loaded into the second set of similar images in its cache, if the result is yes, the image is decoded to calculate its score. In one application example, the image score represents the image's blurriness; higher blurriness results in a lower score, and lower blurriness results in a higher score. In practical applications, there are multiple ways to obtain an image score; for example, it can directly analyze the image's blurriness using an algorithm to arrive at the corresponding score.
[0067] It should be noted that for multiple images that need to be loaded or scanned, for all images that do not have a corresponding second image and are loaded into the second similar image set in the cache, the electronic device needs to decode them to obtain the image score, until the score of each image in each second similar image set is obtained.
[0068] Subsequently, a third image is determined from the second set of similar images based on the score of each image in the second set of similar images. The third image can be understood as the base image of the second set of similar images. In one implementation, the image with the highest score in the second set of similar images can be determined as the third image, that is, the image with the lowest blurriness can be determined as the third image.
[0069] After identifying the third image, its feature map is calculated and used as the feature map for each image in the second set of similar images. Subsequently, the information for each image in the second set of similar images, along with the feature map of the third image, can be stored in a cache. Understandably, after identifying the third image, the scan path for each image in the second set of similar images can be set to point to the third image. If the cache contains multiple sets of second similar images, the third image for each set is obtained sequentially, and its feature map is used as the feature map for each image in its respective set.
[0070] In this embodiment of the application, after processing through the above-mentioned methods, namely steps 163, 165, and 168, the feature map of each of the multiple images to be loaded or scanned can be obtained. Then, step 110 can be executed, i.e., obtaining the feature map of each image.
[0071] In some embodiments, reference Figure 4 , Figure 4 This is a schematic diagram of the third process of the image caching method according to an embodiment of this application. Step 130, determining the first root image of the first similar image set, includes the following steps:
[0072] 131, Read the cache; the cache contains at least one fourth image.
[0073] 132. Determine whether the first set of similar images includes an image identical to the fourth image;
[0074] 133. If the first set of similar images includes an image that is the same as the fourth image, then the image that is the same as the fourth image is determined as the first image of the first set of similar images.
[0075] Understandably, in practical applications, the image caching method of this application can be executed cyclically to continuously update the cache of the electronic device. Therefore, during program execution, the cache of the electronic device may already contain one or more root images, which are defined as the fourth root image in this embodiment. For example, the fourth root image can be the root image of a set of similar images loaded in the cache, such as the root image of a second set of similar images.
[0076] After obtaining multiple sets of first similar images, the electronic device can read from a cache containing at least one fourth image. Then, it sequentially compares each image in the first similar image set with the fourth image to determine whether the first similar image set includes an image identical to the fourth image.
[0077] If the first set of similar images includes an image identical to the fourth image, then that image is designated as the first image in the first set of similar images. If the first set of similar images does not include an image identical to the fourth image, further processing can proceed.
[0078] In some embodiments, continue to refer to Figure 4 Step 130, determining the first image in the first similar image set, also includes the following steps:
[0079] 134. If the first set of similar images does not include any images that are the same as the fourth image, then obtain the score of each image in the first set of similar images.
[0080] 135. The image with the highest score in the first set of similar images is determined as the first image in the first set of similar images.
[0081] If the first set of similar images does not contain an image identical to the fourth image, then the score of each image in the first set of similar images is obtained. In one application example, the image score represents the image's blurriness; the higher the blurriness, the lower the score, and vice versa. For images whose scores have already been calculated, such as those whose scores were obtained through decoding in step 166, their scores can be directly obtained. For images whose scores have not yet been calculated, the images can be decoded to calculate their scores. Thus, the score of each image can be obtained.
[0082] Subsequently, the image with the highest score in the first set of similar images is determined as the first image in the first set of similar images, which is also the image with the lowest blurriness.
[0083] In practice, this application is not limited by the execution order of the described steps. Without causing conflicts, some steps may be performed in other orders or simultaneously.
[0084] As can be seen from the above, the image caching method provided in this application includes: obtaining feature maps of each of multiple images to obtain multiple feature maps; performing clustering operations on the multiple feature maps to obtain multiple first similar image sets; determining the first root image of the first similar image set; setting the scanning paths of the images in the first similar image set other than the first root image to point to the first root image; and adding the storage path of the first root image and the feature map of the first root image of each first similar image set to the cache to cache the multiple images. In the image caching method of this application embodiment, by determining the first root image in the first similar image set and setting the scanning paths of the remaining images to point to the first root image, when caching multiple images, it is not necessary to cache the actual data of the multiple images, but only to cache the storage path and the feature map of the first root image. This can reduce the amount of data added to the cache, thereby reducing the occupation of cache space and saving system resources of electronic devices.
[0085] This application also provides an image caching device that can be integrated into an electronic device. The electronic device can be a smartphone, tablet, gaming device, AR (Augmented Reality) device, data storage device, video playback device, laptop, desktop computing device, etc.
[0086] refer to Figure 5 , Figure 5This is a schematic diagram of the structure of an image caching device 200 according to an embodiment of this 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 caching module 250.
[0087] The acquisition module 210 is used to acquire the feature map of each of the multiple images to obtain multiple feature maps.
[0088] The operation module 220 is used to perform clustering operations on multiple feature maps to obtain multiple sets of first similar images;
[0089] Module 230 is used to determine the first image in the first set of similar images;
[0090] Setting module 240 is used to set the scanning path of the images in the first similar image set, excluding the first root image, to point to the first root image;
[0091] The caching module 250 is used to add the storage path of the first root image of each first similar image set and the feature map of the first root image to the cache to cache the multiple images.
[0092] In some embodiments, before obtaining the feature map of each of the multiple images, the acquisition module 210 is further configured to:
[0093] Check sequentially whether each of the multiple images contains a corresponding second image;
[0094] If a corresponding second image exists, the feature map of the second image is calculated and used as the feature map of the current image.
[0095] In some embodiments, before sequentially determining whether each of the multiple images has a corresponding second image, the acquisition module 210 is further configured to:
[0096] Read the cache, which contains at least one set of second-similar images;
[0097] After sequentially determining whether each of the multiple images has a corresponding second image, the acquisition module 210 is also used for:
[0098] If there is no corresponding second image for the image, then determine whether the image is loaded into the second similar image set in the cache;
[0099] If the image is not loaded into the second set of similar images in the cache, then the feature map of the image is calculated.
[0100] In some embodiments, after determining whether the image is loaded into the second set of similar images in the cache, the acquisition module 210 is further configured to:
[0101] The images are decoded to obtain their scores, and this process continues until the score of each image in the second set of similar images is obtained.
[0102] The third image is determined from the second set of similar images based on the score of each image in the second set of similar images;
[0103] The feature map of the third image is calculated, and the feature map of the third image is used as the feature map of each image in the second set of similar images.
[0104] In some embodiments, the determining module 230 is used to:
[0105] Read the cache, which contains at least one fourth image;
[0106] Determine whether the first set of similar images includes an image identical to the fourth image;
[0107] If the first set of similar images includes an image that is the same as the fourth image, then the image that is the same as the fourth image is determined as the first image in the first set of similar images.
[0108] In some embodiments, the determining module 230 is further configured to:
[0109] If the first set of similar images does not include any images that are the same as the fourth image, then the score of each image in the first set of similar images is obtained.
[0110] The image with the highest score in the first set of similar images is determined as the first image in the first set of similar images.
[0111] As you can understand, the specific implementation methods of the above modules can be found in the description of the image caching method above, and will not be repeated here.
[0112] In practice, the above modules can be implemented as independent entities or combined in any way to be implemented as the same or several entities.
[0113] As can be seen from the above, the image caching device 200 provided in this application embodiment obtains feature maps of each of multiple images through the acquisition module 210, resulting in multiple feature maps; the calculation module 220 performs clustering operations 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 paths of the images in the first similar image set, excluding the first root image, to point to the first root image; and the caching module 250 adds the storage path of the first root image of each first similar image set and the feature map of the first root image to the cache, thereby caching the multiple images. The image caching device 200 in this application embodiment, by determining the first root image in the first similar image set and setting the scanning paths of the remaining images to point to the first root image, does not need to cache the actual data of the multiple images when caching multiple images; only the storage path and feature map of the first root image need to be cached. This reduces the amount of data added to the cache, thus reducing the occupation of cache space and saving system resources of electronic devices.
[0114] This application also provides an electronic device. The electronic device can be a smartphone, tablet computer, gaming device, AR (Augmented Reality) device, data storage device, video playback device, laptop computer, desktop computing device, etc.
[0115] refer to Figure 6 , Figure 6 This is a schematic diagram of the structure of the electronic device 300 according to an embodiment of this application.
[0116] Electronic device 300 includes processor 310 and memory 320. Processor 310 and memory 320 are electrically connected.
[0117] The processor 310 is the control center of the electronic device 300. It connects various parts of the electronic device through various interfaces and lines. By running or calling computer programs stored in the memory 320 and calling data stored in the memory 320, it performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole.
[0118] Memory 320 can be used to store computer programs and data. The computer programs stored in memory 320 contain instructions that can be executed in the processor. Computer programs can be composed of various functional modules. Processor 310 executes various functional applications and data processing by calling the computer programs stored in memory 320.
[0119] In this embodiment of the application, the processor 310 in the electronic device 300 loads the 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 programs stored in the memory 320 to perform the following steps:
[0120] Obtain the feature map of each of the multiple images to obtain multiple feature maps;
[0121] Clustering operations are performed on multiple feature maps to obtain multiple sets of first similar images;
[0122] Determine the first image in the first set of similar images;
[0123] Set the scan path of all images in the first set of similar images except the first image to point to the first image;
[0124] Add the storage path of the first image in each set of first similar images and the feature map of the first image to the cache to cache the multiple images.
[0125] In some embodiments, before obtaining the feature map of each of the multiple images, the processor 310 further performs the following steps:
[0126] Check sequentially whether each of the multiple images contains a corresponding second image;
[0127] If a corresponding second image exists, the feature map of the second image is calculated and used as the feature map of the current image.
[0128] In some embodiments, before sequentially determining whether each of the multiple images has a corresponding second image, the processor 310 further performs the following steps:
[0129] Read the cache, which contains at least one set of second-similar images;
[0130] After sequentially determining whether each of the multiple images has a corresponding second image, the processor 310 also performs the following steps:
[0131] If there is no corresponding second image for the image, then determine whether the image is loaded into the second similar image set in the cache;
[0132] If the image is not loaded into the second set of similar images in the cache, then the feature map of the image is calculated.
[0133] In some embodiments, after determining whether the image is loaded into the second set of similar images in the cache, the processor 310 further performs the following steps:
[0134] The images are decoded to obtain their scores, and this process continues until the score of each image in the second set of similar images is obtained.
[0135] The third image is determined from the second set of similar images based on the score of each image in the second set of similar images;
[0136] The feature map of the third image is calculated, and the feature map of the third image is used as the feature map of each image in the second set of similar images.
[0137] In some embodiments, when determining the first root image of the first similar image set, the processor 310 performs the following steps:
[0138] Read the cache, which contains at least one fourth image;
[0139] Determine whether the first set of similar images includes an image identical to the fourth image;
[0140] If the first set of similar images includes an image that is the same as the fourth image, then the image that is the same as the fourth image is determined as the first image in the first set of similar images.
[0141] In some embodiments, when determining the first image of the first similar image set, the processor 310 further performs the following steps:
[0142] If the first set of similar images does not include any images that are the same as the fourth image, then the score of each image in the first set of similar images is obtained.
[0143] The image with the highest score in the first set of similar images is determined as the first image in the first set of similar images.
[0144] although Figure 6 As not shown in the diagram, the electronic device 300 may also include a display screen, control circuitry, input / output unit, camera module, etc., which will not be described in detail here.
[0145] As can be seen from the above, this application embodiment provides an electronic device that performs the following steps: acquiring feature maps of each of multiple images to obtain multiple feature maps; performing clustering operations on the multiple feature maps to obtain multiple first similar image sets; determining the first root image of each first similar image set; setting the scanning paths of all images in the first similar image set except the first root image to point to the first root image; and adding the storage path of the first root image and the feature map of the first root image of each first similar image set to the cache to cache the multiple images. By determining the first root image in the first similar image set and setting the scanning paths of the remaining images to point to the first root image, this electronic device does not need to cache the actual data of the multiple images when caching multiple images; it only needs to cache the storage path and feature map of the first root image. This reduces the amount of data added to the cache, thus reducing the occupation of cache space and saving system resources of the electronic device.
[0146] This application also provides a storage medium storing a computer program, which, when run on a computer, causes the computer to execute the image storage method of any of the above embodiments.
[0147] It should be noted that those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, which may include, but is not limited to, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, etc.
[0148] In the description of this application, it should be understood that terms such as “first” and “second” are used only to distinguish similar objects and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated.
[0149] The image caching method, apparatus, storage medium, and electronic device provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only for the purpose of helping to understand the method and its core ideas. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A picture buffering method, characterized by, The method comprises the following steps: obtaining a feature map of each picture in a plurality of pictures to obtain a plurality of feature maps; performing clustering operation on the plurality of feature maps to obtain a plurality of first similar picture sets, each of the first similar picture sets comprising at least one picture; determining a first root picture of the first similar picture set, the first root picture being at least one picture in the first similar picture set; setting a scanning path of a picture in the first similar picture set other than the first root picture to point to the first root picture; adding a storage path of the first root picture of each of the first similar picture sets and a feature map of the first root picture to a cache to cache the plurality of pictures.
2. The picture buffering method of claim 1, wherein, Before the step of obtaining a feature map of each picture in a plurality of pictures to obtain a plurality of feature maps, the method further comprises the following steps: sequentially judging whether each picture in the plurality of pictures has a corresponding second root picture; if the picture has a corresponding second root picture, calculating a feature map of the second root picture and taking the feature map of the second root picture as the feature map of the picture.
3. The picture buffering method of claim 2, wherein, Before the step of sequentially judging whether each picture in the plurality of pictures has a corresponding second root picture, the method further comprises the following steps: reading a cache, the cache loading at least one second similar picture set, the second similar picture set comprising at least one picture; After the step of sequentially judging whether each picture in the plurality of pictures has a corresponding second root picture, the method further comprises the following steps: if the picture does not have a corresponding second root picture, judging 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, calculating a feature map of the picture.
4. The picture buffering method of claim 3, wherein, After the step of judging whether the picture is loaded in the second similar picture set in the cache, the method further comprises the following steps: 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 picture from the second similar picture set according to the score of each picture in the second similar picture set; calculating a feature map of the third root picture and taking the feature map of the third root picture as the feature map of each picture in the second similar picture set.
5. The picture buffering method according to any one of claims 1 to 4, characterized in that, The step of determining a first root picture of the first similar picture set comprises the following steps: reading a cache, the cache loading at least one fourth root picture; judging whether the first similar picture set comprises a picture identical to the fourth root picture; if the first similar picture set comprises a picture identical to the fourth root picture, determining the picture identical to the fourth root picture as the first root picture of the first similar picture set.
6. The picture buffering method of claim 5, wherein, The step of determining a first root picture of the first similar picture set further comprises the following steps: if the first similar picture set does not comprise a picture identical to the fourth root picture, obtaining a score of each picture in the first similar picture set; determining a picture with the highest score in the first similar picture set as the first root picture of the first similar picture set.
7. The picture buffering method of claim 6, wherein, The score is used to represent the blur degree of the picture, and the higher the blur degree of the picture, the lower the score of the picture.
8. A picture buffer apparatus, characterized by, The method comprises the steps of: An acquisition module is configured to acquire feature maps of each picture in a plurality of pictures, thereby obtaining a plurality of feature maps; An operation module is configured to perform clustering operation on the plurality of feature maps, thereby obtaining a plurality of first similar picture sets, each of the first similar picture sets comprising at least one picture; A determination module is configured to determine a first root picture of the first similar picture set, the first root picture being at least one picture in the first similar picture set; A setting module is configured to set a scanning path of a picture in the first similar picture set other than the first root picture to point to the first root picture; A cache module is configured to add a storage path of the first root picture of each of the first similar picture sets and a feature map of the first root picture to a cache, thereby caching the plurality of pictures.
9. A storage medium, characterized by The storage medium stores a computer program, and when the computer program runs on a computer, the computer is caused to execute the picture caching method in any one of claims 1 to 7.
10. An electronic device, comprising: The electronic device comprises a processor and a memory, the memory stores a computer program, and the processor executes the picture caching method in any one of claims 1 to 7 by running the computer program stored in the memory.
Citation Information
Patent Citations
Picture processing method and device
CN112445922A
Image processing method and device, electronic equipment and computer readable storage medium
CN114332470A