Software window background generation method and device, electronic equipment and storage medium
By comparing the software form background image and judging the difference in hash value, the background is updated only when necessary, the problem of high power consumption of effect background generation in low-end hardware environments is solved, and performance improvement is achieved.
Patent Information
- Application Number
- CN202411292965.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-14
- Publication Date
- 2025-01-07
AI Technical Summary
In low-end hardware or resource-constrained environments, the generation of effect backgrounds of software forms may lead to high power consumption, especially the blur effect and dye effect consume more GPU resources, resulting in performance degradation.
By comparing the background image of the covered area of the software form, using the hash value difference to judge the background change, only update the background image when the difference value is greater than the threshold, and reduce the sampling frequency when the difference value is less than the threshold, skip the effect Process to reduce the frequency of background image acquisition.
It effectively reduces the power consumption of generated effect backgrounds in software forms and improves system performance, especially in resource-constrained environments.
Smart Images

Figure CN119271328A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, electronic device and storage medium for generating a background of a software window. Background Art
[0002] From Windows Vista to Windows 7, the Windows system provides the Aero Glass effect, which allows software forms to have semi-transparent borders. Starting from Windows 10, the system provides a direct acrylic effect (Acrylic Material), and developers can use Windows Composition API or XAML (eXtensible Application Markup Language) controls (such as AcrylicBrush) to implement acrylic effects in the background of software forms. However, the background effects provided by the system may not perform well on some devices or configurations, especially in low-end hardware or resource-constrained environments. For example, blur effects and tinting effects may consume more GPU (graphics processing unit) resources, increase device power consumption, and cause performance degradation.
[0003] Therefore, how to reduce the power consumption of generating effect background in software form is a problem that needs to be solved urgently. Summary of the invention
[0004] The main purpose of the present application is to provide a background generation method, device, electronic device and storage medium for a software window, aiming to solve the technical problem of how to reduce the power consumption of generating an effect background in a software window.
[0005] To achieve the above purpose, the present application proposes a background generation method for a software window, the background generation method for the software window comprising:
[0006] The software window coverage area is sampled according to a preset image sampling frequency, and when the current moment is the image sampling time point, a background image of the software window coverage area is obtained;
[0007] Comparing the background image with a historical background image corresponding to the window background of the software window, obtaining a difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background;
[0008] When the difference value is greater than a preset threshold, the background image is processed according to a preset effect scheme, and the processed image is used to update the window background;
[0009] When the difference value is less than or equal to a preset threshold, the window background is maintained, and the number of triggers for continuously triggering the step of maintaining the window background is recorded. When the number of triggers reaches a preset number, the preset image sampling frequency is reduced.
[0010] In one embodiment, the step of comparing the background image with a historical background image corresponding to the window background of the software window to obtain a difference value between the background image and the historical background image comprises:
[0011] The background image and the historical background image are respectively used as images to be processed, and hash processing is performed on the images to be processed to obtain hash processing results, wherein, when the image to be processed is the background image, the hash processing result is a mean hash value or a perceptual hash value, and when the image to be processed is the historical background image, the hash processing result is a historical mean hash value or a historical perceptual hash value;
[0012] A hash value difference between the mean hash value and the historical mean hash value, or between the perceptual hash value and the historical perceptual hash value, is calculated, and the hash value difference is used as the difference value.
[0013] In one embodiment, the step of performing hash processing on the image to be processed to obtain a hash processing result includes:
[0014] In the case where the hash processing is mean hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image;
[0015] The grayscale average value of all grayscale data in the grayscale image is calculated, and the grayscale average value is compared with each grayscale data in the grayscale image to obtain the hash processing result.
[0016] In one embodiment, the step of performing hash processing on the image to be processed to obtain a hash processing result further includes:
[0017] In a case where the hash processing is perceptual hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image;
[0018] Performing discrete cosine transform on the grayscale image to obtain a frequency matrix, and selecting a submatrix from the frequency matrix, wherein the submatrix is a region of a second preset size with the lowest frequency in the frequency matrix;
[0019] The frequency average value of all the frequency data in the sub-matrix is calculated, and the frequency average value is compared with each frequency data in the sub-matrix to obtain the hash processing result.
[0020] In one embodiment, the preset effect scheme includes a picture blurring task, and the step of processing the background picture according to the preset effect scheme includes:
[0021] A Gaussian kernel of the background image is generated according to the image blurring task, and convolution processing is performed on each pixel in the background image based on the Gaussian kernel.
[0022] In one embodiment, the step of creating a Gaussian kernel of the background image according to the image blurring task includes:
[0023] Creating an initial Gaussian kernel based on the Gaussian kernel size in the image blurring task, and determining a center position of the initial Gaussian kernel;
[0024] For any element in the initial Gaussian kernel, calculating a difference between the element and a central element corresponding to the central position, and determining a Gaussian value of the element based on the difference;
[0025] The Gaussian value corresponding to the element is divided by the sum of the Gaussian values to obtain a target Gaussian value corresponding to the element, wherein the sum of the Gaussian values is obtained by traversing each element in the initial Gaussian kernel and accumulating each Gaussian value of each element;
[0026] The elements are replaced with the target Gaussian values, wherein the Gaussian kernel is obtained when all elements in the initial Gaussian kernel are replaced with the target Gaussian kernel.
[0027] In one embodiment, the preset effect scheme includes a picture coloring task, and the step of processing the background picture according to the preset effect scheme further includes:
[0028] A color adjustment factor of the image dyeing task is obtained, and the color value of each pixel in the background image is adjusted by the color adjustment factor.
[0029] In one embodiment, the color adjustment factor includes a red adjustment factor, a green adjustment factor, and a blue adjustment factor, and the step of adjusting the color value of each pixel in the background image by using the color adjustment factor includes:
[0030] Obtain the red value, green value and blue value of each pixel in the background image;
[0031] The red adjustment factor is added to the red value, the green adjustment factor is added to the green value, and the blue adjustment factor is added to the blue value.
[0032] In one embodiment, the background generation method of the software window further includes:
[0033] When the difference value is greater than a preset threshold, the preset picture sampling frequency is set to a preset maximum sampling frequency.
[0034] In addition, to achieve the above purpose, the present application also proposes a background generation device for a software window, the background generation device for the software window comprising:
[0035] The sampling module samples the software window coverage area according to the preset image sampling frequency, and is used to obtain the background image of the software window coverage area when the current moment is the image sampling time point;
[0036] A comparison module, used for comparing the background image with a historical background image corresponding to the window background of the software window, and obtaining a difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background;
[0037] An updating module, used for processing the background image according to a preset effect scheme when the difference value is greater than a preset threshold, and using the processed image to update the window background;
[0038] A maintaining module is used to maintain the window background when the difference value is less than or equal to a preset threshold, and record the number of triggers for continuously triggering the step of maintaining the window background. When the number of triggers reaches a preset number, the preset image sampling frequency is reduced.
[0039] In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the background generation method of the software window as described above.
[0040] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by the processor, the steps of the background generation method of the software window as described above are implemented.
[0041] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the background generation method of the software window as described above are implemented.
[0042] One or more technical solutions proposed in this application have at least the following technical effects:
[0043] The present application first samples the software window coverage area according to a preset image sampling frequency, and when the current moment is the image sampling time point, obtains the background image of the software window coverage area to obtain the image material for generating the software window background; compares the background image with the historical background image corresponding to the window background of the software window, obtains the difference value between the background image and the historical background image, and judges whether the background image has changed through the difference value, thereby providing an update basis for updating the background of the software window; when the difference value is greater than a preset threshold, processes the background image according to a preset effect scheme, and updates the window background with the processed image, so as to avoid the possible limitations of calling the system interface to process the image by processing the background image, thereby improving the versatility of generating the software window effect background; when the difference value is less than a preset threshold, maintains the window background, and records the number of times the step of maintaining the window background is continuously executed, and when the number reaches the preset number, extends the interval between the picture sampling time point and the next picture sampling time point, so as to reduce the power consumption of generating the effect background of the software window by reducing the acquisition frequency of the background image and skipping the effect processing of the background image at the current picture sampling time point.
[0044] To summarize, the present application compares the background image of the area covered by the acquired software form, and when the difference between the background image and the historical background image used to generate the form background is less than a preset threshold, reduces the frequency of obtaining the background image and skips the effect processing of the background image at the current image sampling time point, thereby achieving the effect of reducing the power consumption of generating the effect background in the software form. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0046] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0047] Figure 1 A flowchart of a method for generating a background for a software window according to an embodiment of the present invention;
[0048] Figure 2 A flowchart of the second embodiment of the background generation method of the software window of the present application is provided;
[0049] Figure 3 A brief flowchart of a method for generating a background for a software window provided in Embodiment 2 of the present application;
[0050] Figure 4 A schematic diagram of the processing effect of the background generation method of the software window provided in the second embodiment of the present application;
[0051] Figure 5 A schematic diagram of the module structure of a background generating device of a software window in an embodiment of the present application;
[0052] Figure 6 Schematic diagram of the device structure of the hardware operating environment involved in the background generation method of the software window in the embodiment of the present application.
[0053] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0054] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0055] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0056] The main solution of the embodiment of the present application is: sampling the software window coverage area according to a preset image sampling frequency, and obtaining the background image of the software window coverage area when the current moment is the image sampling time point; comparing the background image with the historical background image corresponding to the window background of the software window, and obtaining the difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background; when the difference value is greater than a preset threshold, processing the background image according to a preset effect scheme, and using the processed image to update the window background; when the difference value is less than or equal to the preset threshold, maintaining the window background, and recording the number of triggers for continuously triggering the step of maintaining the window background, and when the number of triggers reaches the preset number, reducing the preset image sampling frequency.
[0057] Because the background effects provided by the existing technical system may not perform well on some devices or configurations, especially in low-end hardware or resource-constrained environments, blur effects and semi-transparent rendering may consume more GPU resources, increase device power consumption, and cause performance degradation. Therefore, how to reduce the power consumption of generating effect backgrounds in software forms is a problem that needs to be solved urgently.
[0058] The present application provides a solution, which compares the background image of the area covered by the acquired software form, and reduces the frequency of obtaining the background image and skips the effect processing of the background image at the current image sampling time point when the difference between the background image and the historical background image used to generate the form background is less than a preset threshold, thereby achieving the effect of reducing the power consumption of generating the effect background in the software form.
[0059] It should be noted that the execution subject of this embodiment may be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, etc. The following takes an electronic device as an example to illustrate this embodiment and the following embodiments.
[0060] Based on this, the present application embodiment provides a method for generating a background of a software window, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the background generation method of the software window of the present application.
[0061] In this embodiment, the background generation method of the software window includes steps S10 to S40:
[0062] Step S10, sampling the software window coverage area according to a preset image sampling frequency, and obtaining a background image of the software window coverage area when the current moment is the image sampling time point;
[0063] It should be noted that the image sampling time point refers to the time point used to determine when to obtain the background image. In this embodiment, the preset image sampling frequency set by the user can be received, and the interval between two sampling time points can be determined based on the sampling frequency, thereby determining the specific moment of the sampling time point, wherein the sampling frequency is less than or equal to the screen refresh rate of the display device where the software window is located; the software window refers to the visual elements in the software interface, usually including menus, buttons, text boxes, etc., which is the interface for users to interact with the software; the software window coverage area refers to the area that is still displayed on the screen after the software window; the background picture refers to the image at the position corresponding to the software window coverage area in the image displayed on the device screen.
[0064] It is understandable that since the background area of the software window needs to change accordingly with the changes in the coverage area, step S10 is performed to obtain the background image at the sampling time point to avoid the software interface being inconsistent with the current usage scenario due to the software window not being updated for a long time, thereby achieving the adaptability of the window background of the software window.
[0065] Step S20, comparing the background image with a historical background image corresponding to the window background of the software window, and obtaining a difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background;
[0066] It should be noted that the historical background image refers to the background image used to generate the window background of the current software window. The background image is processed with a preset effect scheme to obtain the window background of the current software window; the difference value refers to the hash value difference between the background image and the historical background image. The hash value difference can be the mean hash value difference or the perceived hash value difference. In this embodiment, the type of difference value is not specifically limited; the window background refers to the space outside the content area displayed inside the software window, which is usually used to display decorative or functional background images.
[0067] In a feasible implementation manner, the step of comparing the background image with the historical background image corresponding to the window background of the software window in step S20 to obtain the difference value between the background image and the historical background image may include steps S21 to S22:
[0068] Step S21, taking the background image and the historical background image as images to be processed respectively, performing hash processing on the images to be processed to obtain hash processing results, wherein, when the image to be processed is the background image, the hash processing result is a mean hash value or a perceptual hash value, and when the image to be processed is the historical background image, the hash processing result is a historical mean hash value or a historical perceptual hash value;
[0069] It should be noted that the historical mean hash value refers to the hash value generated after mean hashing the historical background picture, which reflects the visual content of the historical background picture and can be used to compare with the mean hash value of the current background picture to determine whether the background picture has changed; the historical perceptual hash value refers to the hash value generated after perceptual processing of the historical background picture, which reflects the visual content of the historical background picture and can be used to compare with the perceptual hash value of the current background picture to determine whether the background picture has changed; the mean hash value refers to the hash value generated after mean hashing the background picture, which reflects the visual content of the background picture and can be used to compare with the mean perceptual hash value to determine whether the background picture has changed; the perceptual hash value refers to the hash value generated after perceptual hashing the background picture, which reflects the visual content of the background picture and can be used to compare with the historical perceptual hash value to determine whether the background picture has changed.
[0070] In a feasible implementation manner, the step of performing hash processing on the image to be processed to obtain a hash processing result in step S21 may include steps A211 to A212:
[0071] Step A211, when the hash processing is mean hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image;
[0072] It should be noted that a grayscale image refers to an image that contains only grayscale levels and does not contain color information. In a grayscale image, each pixel has a grayscale value, which represents the brightness of the pixel, usually ranging from 0 to 255, where 0 represents black and 255 represents white, and the values in between represent different grayscale levels. Grayscale images use different grayscale levels to represent the shape, texture, and details of the image without involving color information.
[0073] It can be understood that since the calculation efficiency of directly calculating the mean hash value of the image to be processed is low, step A211 is performed to reduce the size of the image to be processed and convert the reduced image into a grayscale image with only brightness information, thereby reducing the difficulty of image processing and improving the calculation efficiency of the mean hash value.
[0074] Exemplarily, the background image is reduced to a size of 32*32 pixels, and the background image of the size of 32*32 pixels is converted into a grayscale image.
[0075] Step A212, calculating the grayscale average value of all grayscale data in the grayscale image, and comparing the grayscale average value with each grayscale data in the grayscale image to obtain the hash processing result;
[0076] It should be noted that the grayscale data refers to the grayscale value of each pixel in the grayscale image, and the grayscale average value refers to the average value of all grayscale data in the grayscale image.
[0077] It can be understood that since it is difficult to obtain the features of the image to be processed corresponding to the grayscale image in the obtained grayscale image, step A212 is performed to obtain a hash processing result related to the image to be processed by comparing the grayscale average value of the grayscale image and the size of each grayscale data in the grayscale image, so as to determine whether the background image has changed through the hash processing result.
[0078] Exemplarily, the average value of all grayscale data in the grayscale image is calculated, and each grayscale data in the grayscale image is compared with the grayscale average value one by one. If a certain grayscale data is greater than the grayscale average value, the hash value corresponding to the grayscale data is 1, otherwise it is 0. After traversing the hash values corresponding to each grayscale data in the grayscale image, the hash processing result is obtained.
[0079] In this implementation, the mean hash value is obtained by calculating and processing the background image, and the historical mean hash value is obtained by calculating and processing the historical background image, thereby improving the monitoring efficiency of background image and historical background image feature detection on the basis of accurately extracting the grayscale features of the background image and historical background image.
[0080] In another feasible implementation manner, the step of performing hash processing on the image to be processed to obtain a hash processing result in step S21 may further include steps B211 to B213:
[0081] Step B211, when the hash processing is perceptual hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image;
[0082] It can be understood that since the computational efficiency of directly calculating the perceptual hash value for the image to be processed is low, step B211 is performed to reduce the size of the image to be processed and convert the reduced image into a grayscale image with only brightness information, thereby reducing the difficulty of image processing and improving the computational efficiency of the perceptual hash value.
[0083] Exemplarily, the background image is reduced to a size of 32*32 pixels, and the background image of the size of 32*32 pixels is converted into a grayscale image.
[0084] Step B212, performing discrete cosine transform on the grayscale image to obtain a frequency matrix, and selecting a submatrix from the frequency matrix, wherein the submatrix is an area of a second preset size with the lowest frequency in the frequency matrix;
[0085] It should be noted that the discrete cosine transform is a mathematical transformation that converts an image from the spatial domain to the frequency domain; the frequency matrix refers to a matrix used to describe the frequency components in a grayscale image, and each element in the matrix represents the intensity of a certain frequency component in the grayscale image; the submatrix refers to a partial matrix extracted from the frequency matrix that is highly correlated with the changes in the image to be processed.
[0086] It can be understood that since it is difficult to extract frequency components related to changes in the image to be processed from a grayscale image, step B212 is performed to convert the grayscale image into a frequency matrix through discrete cosine transform, and extract the sub-matrix in the frequency matrix that is highly correlated with changes in the image to be processed, thereby providing an effective data basis for determining whether the background image has changed.
[0087] Exemplarily, a discrete cosine transform is performed on a grayscale image of 32*32 pixel size to obtain a frequency matrix of 32*32 size, and a low-frequency part of 16*16 size at the upper left corner of the frequency matrix is selected to obtain a sub-matrix.
[0088] Step B213, calculating the frequency average value of all frequency data in the sub-matrix, and comparing the frequency average value with each frequency data in the sub-matrix to obtain the hash processing result;
[0089] It should be noted that the frequency data refers to the frequency components in the sub-matrix, and the frequency average value refers to the average value of all the frequency data in the sub-matrix.
[0090] It can be understood that since it is difficult to obtain the features of the image to be processed corresponding to the sub-matrix in the obtained sub-matrix, step B213 is performed to obtain the hash processing result related to the image to be processed by comparing the average value of the sub-matrix and the size of each frequency data in the sub-matrix, so as to determine whether the background image has changed through the hash processing result.
[0091] Exemplarily, the average value of all frequency data in the submatrix is calculated, and each frequency data in the submatrix is compared with the average value one by one. If a certain frequency data is greater than the average value, the hash value corresponding to the frequency data is 1, otherwise it is 0. After traversing the hash values corresponding to each frequency data in the submatrix, the hash processing result is obtained.
[0092] In this implementation, historical background images are processed by calculation to obtain historical perceived hash values, and background images are processed by calculation to obtain perceived hash values. This improves the accuracy of background image and historical background image feature detection while achieving accurate extraction of historical background images and frequency features of background images.
[0093] Step S22: Calculate the hash value difference between the mean hash value and the historical mean hash value, or between the perceptual hash value and the historical perceptual hash value, and use the hash value difference as the difference value.
[0094] It is understandable that since the unchanged background image is often repeatedly processed when generating the effect background of the software window, step S22 is performed to achieve fast or accurate detection of background image changes by comparing the mean hash value or the perceived hash value and setting the difference value threshold, thereby providing an effective execution basis for avoiding unnecessary repeated processing.
[0095] Exemplarily, the Hamming distance between the mean hash value and the historical mean hash value, that is, the hash value difference, is calculated, and the Hamming distance is used as the difference value between the background image and the historical background image.
[0096] Exemplarily, the Hamming distance between the perceptual hash value and the historical perceptual hash value, that is, the hash value difference, is calculated, and the Hamming distance is used as the difference value between the background image and the historical background image.
[0097] In this implementation, by using the calculated hash value difference as the difference value between the background image and the historical background image, change detection based on the mean hash value or the perceived hash value is implemented, thereby improving the accuracy and efficiency of background image change monitoring.
[0098] Step S30, when the difference value is greater than a preset threshold, the background image is processed according to a preset effect scheme, and the processed image is used to update the window background;
[0099] It should be noted that the preset effect scheme refers to a series of predefined image processing effects applied to the background image of the software window coverage area, and the image processing effects may include model processing, coloring processing, etc.
[0100] In a feasible implementation manner, the preset effect scheme includes a picture blurring task, and the step of processing the background picture according to the preset effect scheme in step S30 may include step A31:
[0101] Step A31, generating a Gaussian kernel of the background image according to the image blurring task, and performing convolution processing on each pixel in the background image based on the Gaussian kernel.
[0102] It should be noted that the image blurring task refers to a technique used in image processing, which aims to reduce the details and textures in the image so that the image appears blurrier and smoother; the Gaussian kernel refers to a two-dimensional array, each element of which represents the degree of blur of a pixel in the image.
[0103] In addition, it should be noted that the image blurring task can be implemented by blurring the background image through QGraphicsBlurEffect (a class of the Qt framework) configured in Qt (a cross-platform C++ graphical user interface application development framework developed by the Qt Company), or it can be implemented by Gaussian blur using convolution processing with a Gaussian kernel. In this embodiment, it is preferred to use Gaussian blur using convolution processing with a Gaussian kernel to implement the image blurring task.
[0104] In a feasible implementation manner, the step of generating the Gaussian kernel of the background image according to the image blurring task in step A31 may include steps A311 to A314:
[0105] Step A311, creating an initial Gaussian kernel based on the Gaussian kernel size in the image blurring task, and determining the center position of the initial Gaussian kernel;
[0106] It should be noted that the Gaussian kernel size refers to the size of the Gaussian kernel specified by the image model task; the initial Gaussian kernel refers to the initially unadjusted Gaussian kernel created for image blurring, which has not yet been customized according to the specific image blurring task or application scenario; the center position refers to the geometric center of all elements in the two-dimensional array of the Gaussian kernel, which determines the center point of the blurring effect in the image.
[0107] It is understandable that since the blurring process of the background image may cause the blurring effect to be too strong or too weak in some areas, affecting the overall visual effect, step A211 is performed to ensure the blurring intensity achieved on the image by determining the size of the initial Gaussian kernel.
[0108] For example, QVector is declared by function <QVector <float>>generateGaussianKernel(int size,float sigma) defines the initial Gaussian kernel, where this function declaration defines a function named generateGaussianKernel and a return type of QVector <QVector <float>> is a two-dimensional floating-point array. The function accepts two parameters: size of int type, i.e., the Gaussian kernel size, and sigma of float type. When the Gaussian kernel size is an even number, the Gaussian kernel size is divided by two to obtain the center position of the initial Gaussian kernel (size / 2, size / 2); when the Gaussian kernel size is an odd number, the Gaussian kernel size is divided by two to obtain the division result, and the division result is rounded to obtain the center position of the initial Gaussian kernel ([size / 2], [size / 2]), where [size / 2] is the largest integer not exceeding size / 2. For example, when size is 3, the center position of the initial Gaussian kernel is (1,1); when size is 4, the center position of the initial Gaussian kernel is (2,2).
[0109] Step A312, for any element in the initial Gaussian kernel, calculating the difference between the element and the central element corresponding to the central position, and determining the Gaussian value of the element based on the difference;
[0110] It should be noted that the central element refers to the element located at the center of the initial Gaussian kernel.
[0111] It is understandable that directly applying a uniformly distributed Gaussian kernel may cause the blurring effect to be unclear due to insufficient Gaussian value at the center point. Therefore, step A312 is performed to determine the Gaussian value of each element in the initial Gaussian kernel through calculation, so that the Gaussian value gradually decreases from the center point to the outside, so as to achieve a blurring effect that gradually decreases from the center point to the outside, making the blurring effect more natural and continuous.
[0112] Exemplarily, for any element in the initial Gaussian kernel, the difference (x-x0, y-y0) between the element (x, y) and the central element (x0, y0) corresponding to the center position is calculated, and the difference is squared to obtain the square results xTerm and yTerm, and then the square results are substituted into the Gaussian formula kernel[x][y]=exp(-(xTerm+yTerm) / (2*sigma*sigma)) / (2*M_PI*sigma*sigma) to calculate the Gaussian value kernel[x][y] of any element in the Gaussian kernel, where sigma is the standard deviation of all elements in the initial Gaussian kernel, and M_PI is pi, π.
[0113] Step A313, dividing the Gaussian value corresponding to the element by the sum of the Gaussian values to obtain a target Gaussian value corresponding to the element, wherein the sum of the Gaussian values is obtained by traversing each element in the initial Gaussian kernel and accumulating each Gaussian value of each element;
[0114] It should be noted that the target Gaussian value refers to the Gaussian value after normalization, that is, the Gaussian value is divided by the total Gaussian value.
[0115] It can be understood that since the convolution operation based on the Gaussian kernel on each pixel in the background image may cause changes in the image pixel values, step A313 is performed to ensure that the Gaussian values of all elements in the Gaussian kernel are 1 by replacing the Gaussian value of each element with the sum of the Gaussian value of the element and the sum of the Gaussian values, thereby achieving normalization of the Gaussian kernel and keeping the image pixel values unchanged after the convolution operation.
[0116] Step A314, replacing the elements with the target Gaussian values, wherein the Gaussian kernel is obtained when all elements in the initial Gaussian kernel are replaced with the target Gaussian kernel.
[0117] In this implementation, by creating a Gaussian kernel based on the Gaussian kernel size in the image blurring task, a controllable normalized Gaussian kernel is created, thereby providing an effective data basis for achieving a more precise and natural blurring effect through the Gaussian kernel.
[0118] In this implementation, by generating a Gaussian kernel based on the image blurring task and performing a convolution operation on the background image based on the Gaussian kernel, a controllable blurred background effect is created in the background area of the software window, thereby improving the interactivity between the user and the software.
[0119] In another feasible implementation manner, the preset effect scheme includes a picture coloring task, and the step of processing the background picture according to the preset effect scheme in step S30 may further include step B31:
[0120] Step B31, obtaining a color adjustment factor of the image dyeing task, and adjusting the color value of each pixel in the background image by using the color adjustment factor.
[0121] It should be noted that the image colorization task refers to a technology used in image processing, which aims to adjust the color distribution of the background image, thereby changing the overall tone of the background image; the color adjustment factor refers to a numerical value used to adjust the image color, which determines the degree and direction of the color change. The color adjustment factor can be an independent adjustment value of the three color channels of red, green, and blue, or it can be an adjustment value of the overall tone.
[0122] In a feasible implementation manner, the color adjustment factor includes a red adjustment factor, a green adjustment factor, and a blue adjustment factor. The step of adjusting the color value of each pixel in the background image by using the color adjustment factor in step B31 may include steps B311 to B312:
[0123] Step B311, obtaining the red value, green value and blue value of each pixel in the background image;
[0124] It should be noted that the red value refers to the intensity of the red component in the pixel, which is usually an integer between 0 and 255, where 0 means no red and 255 means the red component reaches the maximum intensity; the green value refers to the intensity of the green component in the pixel, which is also an integer between 0 and 255, where 0 means no green and 255 means the green component reaches the maximum intensity; the blue value refers to the intensity of the blue component in the pixel, which is also an integer between 0 and 255, where 0 means no blue and 255 means the blue component reaches the maximum intensity.
[0125] Step B312: adding the red adjustment factor to the red value, adding the green adjustment factor to the green value, and adding the blue adjustment factor to the blue value.
[0126] It should be noted that the red adjustment factor refers to a value used to adjust the red value of a pixel, the green adjustment factor refers to a value used to adjust the green value of a pixel, and the blue adjustment factor refers to a value used to adjust the blue value of a pixel.
[0127] It is understandable that since the color adjustment may not be precise enough when dyeing the background image, step B312 is performed to change the different color components of each pixel to achieve the overall or local color adjustment effect of the background image, so that the color of the background image is more in line with the desired style or visual effect, thereby achieving a specific visual effect for the background image.
[0128] Exemplarily, the red value, green value, and blue value of each pixel in the background image are adjusted by the following code:
[0129] "QImage applyTint(const QImage&image,int redFactor,int greenFactor,int blueFactor){
[0130] QImage tintedImage=image.convertToFormat(QImage::Format_ARGB32);
[0131] int width=tintedImage.width();
[0132] int height=tintedImage.height();
[0133] for(int y=0;y<height;++y){
[0134] QRgb*line=reinterpret_cast<QRgb*>(tintedImage.scanLine(y));
[0135] for(int x=0;x<width;++x){
[0136] int red=qRed(line[x]);
[0137] int green=qGreen(line[x]);
[0138] int blue=qBlue(line[x]);
[0139] red+=redFactor;
[0140] green+=greenFactor;
[0141] blue+=blueFactor;
[0142] red=qBound(0,red,255);
[0143] green=qBound(0,green,255);
[0144] blue=qBound(0,blue,255);
[0145] line[x]=qRgba(red,green,blue,qAlpha(line[x]));
[0146] }
[0147] }
[0148] return tintedImage;
[0149] }”
[0150] In this code, first define a QImage type function applyTint, which accepts a QImage object as input and three int type variables (red adjustment factor redFactor, green adjustment factor greenFactor and blue adjustment factor blueFactor) as parameters for adjusting color. Then define a QImage type variable tintedImage, which is the background image, to store the image after color adjustment. The format of this variable is ARGB32. Then get the width width and height height of the background image, and traverse each row of background image pixels and each pixel in each row in two layers of loops. Then get the red value red, green value green and blue value blue of each pixel, and add the red adjustment factor redFactor to the red value red of each pixel, the green adjustment factor greenFactor to the green value green of each pixel, and the blue adjustment factor blueFactor to the blue value blue of each pixel. At the same time, ensure that the adjusted red value, green value and blue value are between 0 and 255, then create a new ARGB value qRgba, keep the original Alpha value qAlpha(line[x]) unchanged, and finally return the image tintedImage after color adjustment.
[0151] In this implementation, by acquiring the color adjustment factor and adjusting the color value of each pixel in the background image, a dynamically changing dyed background effect is created in the background area of the software window, thereby improving the interactivity between the user and the software.
[0152] Step S40, when the difference value is less than or equal to a preset threshold, maintain the window background, and record the number of triggers for continuously triggering the step of maintaining the window background. When the number of triggers reaches a preset number, reduce the preset image sampling frequency.
[0153] It should be noted that the preset number of times can be one, that is, each time the window background is triggered to be maintained, the preset image sampling frequency is reduced, or it can be any integer greater than one.
[0154] It is understandable that, since the unchanged background image is often repeatedly processed when generating the effect background of the software window, step S40 is performed. When the difference between the background image and the historical background image used to generate the window background is less than a preset threshold, the frequency of obtaining the background image is reduced and the effect processing required for the background image at the current image sampling time point is skipped. In the process of reducing the acquisition frequency, a preset number of times for keeping the window background unchanged is set continuously to avoid adjusting the sampling interval duration at too high a frequency when the background image has not changed or has not changed significantly compared to the historical background image, resulting in unnecessary resource consumption, thereby further reducing the power consumption of the effect background of the generated software window.
[0155] The present embodiment provides a background generation method for a software window. By comparing the acquired background image of the area covered by the software window, the frequency of obtaining the background image is reduced and the effect processing of the background image is skipped at the current image sampling time point when the difference between the background image and the historical background image used to generate the window background is less than a preset threshold, thereby achieving the effect of reducing the power consumption of generating the effect background in the software window.
[0156] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , Figure 2 This is a flow chart of the second embodiment of the background generation method of the software window of the present application.
[0157] After step S30, the background generation method of the software window further includes step S300:
[0158] Step S300, when the difference value is greater than a preset threshold, setting the preset picture sampling frequency to a preset maximum sampling frequency.
[0159] It should be noted that the preset maximum sampling frequency refers to the maximum sampling frequency set in advance by the user, and the upper limit of the maximum sampling frequency is the maximum refresh rate of the display device where the software window is located, such as 60Hz, 75Hz, 144Hz, etc.
[0160] It can be understood that, since the background area of the software window is required to respond in a timely manner when the background image changes, step S300 is performed. When the difference between the background image and the historical background image used to generate the window background is greater than a preset threshold, the sampling process of the next image sampling time point is performed based on the preset shortest interval duration, thereby improving the real-time and accuracy of background image change detection and ensuring that the background image can respond in a timely manner and update the background area of the software window when the background image changes.
[0161] In this embodiment, by adopting the technical means of dynamically adjusting the sampling interval, the effects of changing the background image sampling in real time and improving the processing efficiency are achieved.
[0162] For example, in order to help understand the implementation process of the background generation method of the software window obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 3 , Figure 3 A brief flowchart of a method for generating a background of a software window is provided, specifically:
[0163] First, a background image of the area covered by the software form is obtained, and the background image is compared with the historical background image used to generate the form background of the software form. When the background image and the historical background image change, that is, when the difference value between the background image and the historical background image is greater than a preset threshold, the background image is processed according to a preset effect plan, and the form background is updated with the processed image, and a sampling process for subsequent image sampling time points is performed based on the highest sampling frequency, that is, the preset image sampling frequency is set to the preset highest sampling frequency, and then the background image acquisition process for the next image sampling time point is entered; when the background image and the historical background image do not change, that is, when the difference value between the background image and the historical background image is less than or equal to the preset threshold, the form background is kept unchanged, and the number of consecutive executions of keeping the form background unchanged is recorded. When the number reaches the preset number, the preset image sampling frequency is reduced, and then the background image acquisition process for the next image sampling time point is entered; when the number does not reach the preset number, the background image acquisition process for the next image sampling time point is directly entered.
[0164] For further information, please refer to Figure 4 , Figure 4 A schematic diagram of the processing effect of a method for generating a background of a software window is provided. The software window W shown in the figure is an account login interface, and the background image of the part of the area covered by the account login interface is the dotted part of the area B in the figure, and the content of the dotted part is processed and used as the window background of the account login interface.
[0165] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the background generation method of the software window of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0166] This application also provides a background generation device for a software window, please refer to Figure 5 , the background generating device of the software window comprises:
[0167] The sampling module 10 is used to sample the software window coverage area according to a preset image sampling frequency, and obtain the background image of the software window coverage area when the current moment is the image sampling time point;
[0168] A comparison module 20, used for comparing the background image with a historical background image corresponding to the window background of the software window, and obtaining a difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background;
[0169] An updating module 30 is used to process the background image according to a preset effect scheme when the difference value is greater than a preset threshold, and use the processed image to update the window background;
[0170] The maintaining module 40 is used to maintain the window background when the difference value is less than or equal to a preset threshold value, and record the number of triggers for continuously triggering the step of maintaining the window background. When the number of triggers reaches a preset number, the preset image sampling frequency is reduced.
[0171] Optionally, the comparison module 20 is further used for:
[0172] The background image and the historical background image are respectively used as images to be processed, and hash processing is performed on the images to be processed to obtain hash processing results, wherein, when the image to be processed is the background image, the hash processing result is a mean hash value or a perceptual hash value, and when the image to be processed is the historical background image, the hash processing result is a historical mean hash value or a historical perceptual hash value;
[0173] A hash value difference between the mean hash value and the historical mean hash value, or between the perceptual hash value and the historical perceptual hash value, is calculated, and the hash value difference is used as the difference value.
[0174] Optionally, the comparison module 20 is further used for:
[0175] In the case where the hash processing is mean hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image;
[0176] The grayscale average value of all grayscale data in the grayscale image is calculated, and the grayscale average value is compared with each grayscale data in the grayscale image to obtain the hash processing result.
[0177] Optionally, the comparison module 20 is further used for:
[0178] In a case where the hash processing is perceptual hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image;
[0179] Performing discrete cosine transform on the grayscale image to obtain a frequency matrix, and selecting a submatrix from the frequency matrix, wherein the submatrix is a region of a second preset size with the lowest frequency in the frequency matrix;
[0180] The frequency average value of all the frequency data in the sub-matrix is calculated, and the frequency average value is compared with each frequency data in the sub-matrix to obtain the hash processing result.
[0181] Optionally, the preset effect scheme includes a picture blur task, and the updating module 30 is further used for:
[0182] A Gaussian kernel of the background image is generated according to the image blurring task, and convolution processing is performed on each pixel in the background image based on the Gaussian kernel.
[0183] Optionally, the updating module 30 is further used for:
[0184] Creating an initial Gaussian kernel based on the Gaussian kernel size in the image blurring task, and determining a center position of the initial Gaussian kernel;
[0185] For any element in the initial Gaussian kernel, calculating a difference between the element and a central element corresponding to the central position, and determining a Gaussian value of the element based on the difference;
[0186] The Gaussian value corresponding to the element is divided by the sum of the Gaussian values to obtain a target Gaussian value corresponding to the element, wherein the sum of the Gaussian values is obtained by traversing each element in the initial Gaussian kernel and accumulating each Gaussian value of each element;
[0187] The elements are replaced with the target Gaussian values, wherein the Gaussian kernel is obtained when all elements in the initial Gaussian kernel are replaced with the target Gaussian kernel.
[0188] Optionally, the preset effect scheme includes a picture coloring task, and the updating module 30 is further used for:
[0189] A color adjustment factor of the image dyeing task is obtained, and the color value of each pixel in the background image is adjusted by the color adjustment factor.
[0190] Optionally, the color adjustment factor includes a red adjustment factor, a green adjustment factor and a blue adjustment factor, and the updating module 30 is further used for:
[0191] Obtain the red value, green value and blue value of each pixel in the background image;
[0192] The red adjustment factor is added to the red value, the green adjustment factor is added to the green value, and the blue adjustment factor is added to the blue value.
[0193] Optionally, the updating module 30 is further used for:
[0194] When the difference value is greater than a preset threshold, the preset picture sampling frequency is set to a preset maximum sampling frequency.
[0195] The background generation device of the software window provided by the present application adopts the background generation method of the software window in the above embodiment, which can solve the technical problem of how to reduce the power consumption of generating the effect background in the software window. Compared with the prior art, the beneficial effects of the background generation device of the software window provided by the present application are the same as the beneficial effects of the background generation method of the software window provided by the above embodiment, and other technical features in the background generation device of the software window are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0196] The present application provides an electronic device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the background generation method of the software window in the above-mentioned embodiment one.
[0197] Reference below Figure 6 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic devices in the embodiments of the present application may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0198] like Figure 6 As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0199] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0200] The electronic device provided by the present application adopts the background generation method of the software window in the above embodiment, which can solve the technical problem of how to reduce the power consumption of generating the effect background in the software window. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the background generation method of the software window provided by the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0201] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0202] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0203] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the background generation method of the software window in the above-mentioned embodiment.
[0204] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.
[0205] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0206] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an electronic device, the electronic device: samples the software window coverage area according to a preset image sampling frequency, and when the current moment is the image sampling time point, obtains the background image of the software window coverage area; compares the background image with the historical background image corresponding to the window background of the software window, and obtains the difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background; when the difference value is greater than a preset threshold, processes the background image according to a preset effect scheme, and updates the window background with the processed image; when the difference value is less than or equal to the preset threshold, maintains the window background, and records the number of triggers for continuously triggering the step of maintaining the window background, and when the number of triggers reaches the preset number, extends the interval between the image sampling time point and the next image sampling time point. Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0207] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0208] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0209] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the background generation method of the above-mentioned software window, and can solve the technical problem of how to reduce the power consumption of generating the effect background in the software window. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the background generation method of the software window provided by the above-mentioned embodiment, and will not be repeated here.
[0210] The present application also provides a computer program product, including a computer program, which implements the steps of the background generation method of the software window as described above when the computer program is executed by a processor.
[0211] The computer program product provided by the present application can solve the technical problem of how to reduce the power consumption of generating an effect background in a software window. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the background generation method of the software window provided by the above embodiment, and will not be repeated here.
[0212] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.< / float> < / float>
Claims
1. A method for generating a background of a software window, characterized in that: The background generation method of the software window includes: The software window coverage area is sampled according to a preset image sampling frequency, and when the current moment is the image sampling time point, a background image of the software window coverage area is obtained; Comparing the background image with a historical background image corresponding to the window background of the software window, obtaining a difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background; When the difference value is greater than a preset threshold, the background image is processed according to a preset effect scheme, and the processed image is used to update the window background; When the difference value is less than or equal to a preset threshold, the window background is maintained, and the number of triggers for continuously triggering the step of maintaining the window background is recorded. When the number of triggers reaches a preset number, the preset image sampling frequency is reduced.
2. The background generation method of the software window as claimed in claim 1, characterized in that: The step of comparing the background image with the historical background image corresponding to the window background of the software window to obtain the difference value between the background image and the historical background image comprises: The background image and the historical background image are respectively used as images to be processed, and hash processing is performed on the images to be processed to obtain hash processing results, wherein, when the image to be processed is the background image, the hash processing result is a mean hash value or a perceptual hash value, and when the image to be processed is the historical background image, the hash processing result is a historical mean hash value or a historical perceptual hash value; A hash value difference between the mean hash value and the historical mean hash value, or between the perceptual hash value and the historical perceptual hash value, is calculated, and the hash value difference is used as the difference value.
3. The background generation method of the software window as claimed in claim 2, characterized in that: The step of performing hash processing on the image to be processed to obtain a hash processing result comprises: In the case where the hash processing is mean hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image; The grayscale average value of all grayscale data in the grayscale image is calculated, and the grayscale average value is compared with each grayscale data in the grayscale image to obtain the hash processing result.
4. The background generation method of the software window as claimed in claim 2, characterized in that: The step of performing hash processing on the image to be processed to obtain a hash processing result also includes: In a case where the hash processing is perceptual hash processing, reducing the image to be processed to a first preset size, and converting the reduced image to be processed into a grayscale image; Performing discrete cosine transform on the grayscale image to obtain a frequency matrix, and selecting a submatrix from the frequency matrix, wherein the submatrix is a region of a second preset size with the lowest frequency in the frequency matrix; The frequency average value of all the frequency data in the sub-matrix is calculated, and the frequency average value is compared with each frequency data in the sub-matrix to obtain the hash processing result.
5. The background generation method of the software window as claimed in claim 1, characterized in that: The preset effect scheme includes a picture blurring task, and the step of processing the background picture according to the preset effect scheme includes: A Gaussian kernel of the background image is generated according to the image blurring task, and convolution processing is performed on each pixel in the background image based on the Gaussian kernel.
6. The background generation method of the software window as claimed in claim 5, characterized in that: The step of creating the Gaussian kernel of the background image according to the image blurring task comprises: Creating an initial Gaussian kernel based on the Gaussian kernel size in the image blurring task, and determining a center position of the initial Gaussian kernel; For any element in the initial Gaussian kernel, calculating a difference between the element and a central element corresponding to the central position, and determining a Gaussian value of the element based on the difference; The Gaussian value corresponding to the element is divided by the sum of the Gaussian values to obtain a target Gaussian value corresponding to the element, wherein the sum of the Gaussian values is obtained by traversing each element in the initial Gaussian kernel and accumulating each Gaussian value of each element; The elements are replaced with the target Gaussian values, wherein the Gaussian kernel is obtained when all elements in the initial Gaussian kernel are replaced with the target Gaussian kernel.
7. The background generation method of a software window as claimed in claim 1, characterized in that: The preset effect scheme includes a picture coloring task, and the step of processing the background picture according to the preset effect scheme also includes: A color adjustment factor of the image dyeing task is obtained, and the color value of each pixel in the background image is adjusted by the color adjustment factor.
8. The background generation method of the software window as claimed in claim 7, characterized in that: The color adjustment factors include a red adjustment factor, a green adjustment factor, and a blue adjustment factor. The step of adjusting the color value of each pixel in the background image by using the color adjustment factors includes: Obtain the red value, green value and blue value of each pixel in the background image; The red adjustment factor is added to the red value, the green adjustment factor is added to the green value, and the blue adjustment factor is added to the blue value.
9. The background generation method of a software window as claimed in claim 1, characterized in that: The background generation method of the software window also includes: When the difference value is greater than a preset threshold, the preset picture sampling frequency is set to a preset maximum sampling frequency.
10. A background generation device for a software window, characterized in that: The background generating device of the software window comprises: The sampling module is used to sample the software window coverage area according to a preset image sampling frequency, and obtain the background image of the software window coverage area when the current moment is the image sampling time point; A comparison module, used for comparing the background image with a historical background image corresponding to the window background of the software window, and obtaining a difference value between the background image and the historical background image, wherein the historical background image is the background image used to generate the window background; An updating module, used for processing the background image according to a preset effect scheme when the difference value is greater than a preset threshold, and using the processed image to update the window background; A maintaining module is used to maintain the window background when the difference value is less than or equal to a preset threshold, and record the number of triggers for continuously triggering the step of maintaining the window background. When the number of triggers reaches a preset number, the preset image sampling frequency is reduced.
11. An electronic device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the background generation method of the software window according to any one of claims 1 to 9.
12. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the background generation method of the software window as described in any one of claims 1 to 9 are implemented.