Image processing method, device, terminal and storage medium
The bitmap image is obtained directly from the browser cache area through the terminal and the image fingerprint is calculated using OpenCV technology, which solves the problems of high image processing bandwidth and poor user experience in the existing technology, and achieves fast and efficient image processing.
Patent Information
- Application Number
- CN202011354312.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-26
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2040-11-26
AI Technical Summary
In the prior art, images need to be uploaded to the server for fingerprint calculation during image processing, resulting in high bandwidth usage, large server resource consumption, and poor user experience when the network environment is poor.
Get bitmap pictures directly from the browser cache through the terminal, and use OpenCV technology to calculate the image fingerprint to avoid uploading to the server.
Save bandwidth and server resources, improve the speed of image processing, especially when the image is large in size and the network environment is poor, improve the user experience.
Smart Images

Figure CN112445990B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, device, terminal and storage medium for image processing. Background Art
[0002] Image fingerprint (also called image fingerprint) is a kind of information that can reflect the characteristics of an image and can be applied in various scenarios according to user needs, such as image recognition, image search, etc.
[0003] However, in the related art, the method of processing images when determining image fingerprints still needs to be optimized. Summary of the invention
[0004] To solve related technical problems, the embodiments of the present application provide an image processing method, device, terminal and storage medium.
[0005] The technical solution of the embodiment of the present application is implemented as follows:
[0006] The embodiment of the present application provides a picture processing method, which is applied to a terminal, including:
[0007] Determine the image to be processed through the target web page;
[0008] Acquire a bitmap image corresponding to the image to be processed from a cache area of a corresponding browser; the bitmap image is generated when the terminal loads the image to be processed on the target web page;
[0009] Based on the bitmap image, the image fingerprint corresponding to the image to be processed is determined using OpenCV technology.
[0010] In the above solution, determining the image to be processed through the target web page includes:
[0011] Monitoring a selection operation on a local file using a first control on the target webpage;
[0012] The picture to be processed is determined according to the monitored selection operation on the local file.
[0013] In the above solution, based on the bitmap image, using OpenCV technology to determine the image fingerprint corresponding to the image to be processed includes:
[0014] Perform grayscale processing on the bitmap image using OpenCV technology to obtain a first image;
[0015] Based on a preset size, the first image is scaled using OpenCV technology to obtain a second image;
[0016] Grayscale binarization is performed on all pixels contained in the second image to obtain an image fingerprint corresponding to the image to be processed.
[0017] In the above solution, the grayscale binarization processing of all pixels included in the second image includes:
[0018] Determine the grayscale average value of all pixels included in the second image;
[0019] The determined grayscale average value is used to perform binarization processing on the grayscale value of each pixel included in the second image.
[0020] In the above scheme, the method further includes:
[0021] Determine the Exchangeable image file format (Exif) data corresponding to the image to be processed;
[0022] Based on the determined Exif data, the image fingerprint corresponding to the determined image to be processed is corrected to obtain a corrected image fingerprint.
[0023] In the above solution, the correcting of the determined image fingerprint based on the determined Exif data includes:
[0024] Based on the determined Exif data, determining direction information of the image to be processed;
[0025] According to the determined direction information, the direction of the image fingerprint is corrected.
[0026] In the above scheme, the method further includes:
[0027] Compare the image fingerprint corresponding to the image to be processed with the image fingerprint corresponding to the target image to obtain a comparison result;
[0028] According to the obtained comparison result, the similarity between the image to be processed and the target image is determined.
[0029] The present application also provides an image processing device, including:
[0030] A first processing unit, used to determine a picture to be processed through a target web page;
[0031] A second processing unit is used to obtain a bitmap image corresponding to the image to be processed from a cache area of a corresponding browser; the bitmap image is generated when the terminal loads the image to be processed on the target web page;
[0032] The third processing unit is used to determine the image fingerprint corresponding to the image to be processed based on the bitmap image by using OpenCV technology.
[0033] The embodiment of the present application also provides a terminal, comprising: a processor and a memory for storing a computer program that can be run on the processor;
[0034] Wherein, the processor is used to execute the steps of any of the above methods when running the computer program.
[0035] An embodiment of the present application further provides a storage medium, wherein the medium stores a computer program, and wherein the computer program implements the steps of any of the above methods when executed by a processor.
[0036] The picture processing method, device, terminal and storage medium provided in the embodiment of the present application determine the picture to be processed through the target web page; obtain the bitmap picture corresponding to the picture to be processed from the cache area of the corresponding browser; the bitmap picture is generated in the process of the terminal loading the picture to be processed on the target web page; based on the bitmap picture, the picture fingerprint corresponding to the picture to be processed is determined using OpenCV technology. The scheme of the embodiment of the present application is that the terminal directly obtains the bitmap picture corresponding to the picture to be processed from the cache area of the corresponding browser, and determines the picture fingerprint corresponding to the picture to be processed using OpenCV technology. There is no need to upload the picture to be processed to the server for calculating the picture fingerprint. In this way, bandwidth occupation and server resource overhead can be saved. Moreover, when the size of the picture to be processed is large and the network environment is not good, the picture to be processed can also be processed quickly, saving user time and thus improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a flowchart of the image processing method according to an embodiment of the present application;
[0038] Figure 2 This is a flowchart of the image processing method of the application embodiment of the present application;
[0039] Figure 3 This is a schematic diagram of the structure of the image processing device according to an embodiment of the present application;
[0040] Figure 4 This is a schematic diagram of the hardware structure of the terminal according to the embodiment of the present application. DETAILED DESCRIPTION
[0041] The technical solution of the present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0042] In the related technology, application scenarios such as image recognition and image search that require fingerprint calculation of images can be implemented based on Web applications. In these application scenarios, users can access the corresponding Web application through the browser in the terminal, and use the web page (also called the front-end page) provided by the Web application to upload the image to be processed to the server. The server uses Java, Python and other technologies to calculate the image fingerprint corresponding to the image to be processed, and performs image recognition, image search and other processing based on the determined image fingerprint, and then sends the processing results to the terminal.
[0043] However, the above image processing method has the following problems:
[0044] First, it needs to be implemented based on terminals and servers, that is, both the front-end and the server need to be developed at the same time, so the development cycle is long.
[0045] Second, when the size of the image to be processed is large, the terminal needs to occupy a high bandwidth to upload the image to be processed to the server, and the server will also occupy a high server resource when calculating the image fingerprint corresponding to the image to be processed.
[0046] Third, when the size of the image to be processed is large and the network environment is poor, the process of the terminal uploading the image to be processed to the server and the server sending the processing results to the terminal will take a lot of time, the waiting time is long, and the user experience is poor.
[0047] Based on this, in various embodiments of the present application, the terminal directly obtains the bitmap image corresponding to the image to be processed from the cache area of the corresponding browser, and uses OpenCV technology to determine the image fingerprint corresponding to the image to be processed. There is no need to upload the image to be processed to the server for calculation of the image fingerprint. In this way, bandwidth occupancy and server resource overhead can be saved. Moreover, when the image to be processed is large in size and the network environment is poor, the image to be processed can also be processed quickly, saving user time and thus improving user experience.
[0048] The present application embodiment provides a method for processing an image, which is applied to a terminal, such as Figure 1 As shown, the method includes:
[0049] Step 101: Determine the image to be processed through the target web page;
[0050] Step 102: Obtain a bitmap image corresponding to the image to be processed from the cache area of the corresponding browser;
[0051] Here, the bitmap image is generated during the process of the terminal loading the image to be processed on the target webpage;
[0052] Step 103: Based on the bitmap image, using OpenCV technology, determine the image fingerprint corresponding to the image to be processed.
[0053] Here, it should be noted that in various embodiments of the present application, the terminal can be any electronic device that can install a browser, such as a personal computer (PC), a mobile phone, etc.; the PC can include a desktop computer, a laptop computer, a tablet computer, a car computer, etc. In addition, the image fingerprint corresponding to the image to be processed is embodied by a hash string (also called a hash value).
[0054] In one embodiment, determining the image to be processed through the target webpage may include:
[0055] Monitoring a selection operation on a local file using a first control on the target webpage;
[0056] The picture to be processed is determined according to the monitored selection operation on the local file.
[0057] Here, the first control can also monitor the user's click operation on itself.
[0058] Specifically, in actual application, when the user clicks the first control on the target web page, the first control can call the system service to present the resource manager for the user to select a local file. When the user's selection operation on a local file (i.e., a local picture) in the resource manager is detected, the first control can determine the local file selected by the user as the picture to be processed, and call the window.URL.createObjectURL method to generate the Uniform Resource Locator (URL) corresponding to the picture to be processed. The generated URL is the URL corresponding to the cache area of the corresponding browser, which can be used by the target web page to load and display the picture to be processed. At the same time, the first control can dynamically create a Hyper Text Markup Language (HTML) Object( The object is used to load and display the image to be processed), and assigns the URL corresponding to the generated image to be processed to Thus, after the user clicks the first control on the target web page and selects a local file in the resource manager, the terminal can load the image to be processed on the target web page and generate a bitmap image corresponding to the image to be processed in the cache area of the corresponding browser.
[0059] In actual application, HTML5 Canvas technology can be used to process images on the front-end web page. However, Canvas technology does not meet the linear interpolation (INTER_LINEAR) algorithm for image fingerprint calculation. Therefore, in various embodiments of the present application, OpenCV technology is used to determine the image fingerprint corresponding to the image to be processed.
[0060] Based on this, in one embodiment, determining the image fingerprint corresponding to the image to be processed based on the bitmap image using OpenCV technology may include:
[0061] Perform grayscale processing on the bitmap image using OpenCV technology to obtain a first image;
[0062] Based on a preset size, the first image is scaled using OpenCV technology to obtain a second image;
[0063] Grayscale binarization is performed on all pixels contained in the second image to obtain an image fingerprint corresponding to the image to be processed.
[0064] Here, grayscale processing of the bitmap image can remove the color details of the image and prevent factors such as the light and dark relationship and saturation of the image from causing excessive differences; scaling the first image can remove the details of the image, retaining only basic information such as structure and light and dark, and discarding image differences caused by different sizes and proportions. Grayscale binarization processing of all pixels contained in the second image can obtain a hash string containing 1 and 0, that is, the image fingerprint corresponding to the image to be processed.
[0065] In actual application, the preset size can be set according to demand, such as 8 pixels by 8 pixels (which can be expressed as 8×8) for a total of 64 pixels.
[0066] In actual application, OpenCV provides a JavaScript-SDK that can be used by the front-end page, that is, the JavaScript-SDK provided by OpenCV can be used to determine the image fingerprint corresponding to the image to be processed.
[0067] In one embodiment, the performing grayscale binarization processing on all pixels included in the second image may include:
[0068] Determine the grayscale average value of all pixels included in the second image;
[0069] The determined grayscale average value is used to perform binarization processing on the grayscale value of each pixel included in the second image.
[0070] Specifically, after determining the grayscale average value of all pixels contained in the second image, you can traverse each pixel contained in the second image and compare the grayscale value of the corresponding pixel with the average value. When the grayscale value of the corresponding pixel is greater than or equal to the average value, the hash value corresponding to the corresponding pixel is determined to be 1; when the grayscale value of the corresponding pixel is less than the average value, the hash value corresponding to the corresponding pixel is determined to be 0, so as to obtain a hash string containing 1 and 0.
[0071] In actual applications, there may be a situation where the image direction of the image to be processed is incorrect, such as rotation to the left or right. At this time, in order to improve the accuracy of the image fingerprint, the image fingerprint needs to be corrected.
[0072] Based on this, in one embodiment, the method may further include:
[0073] Determine the Exif data corresponding to the image to be processed;
[0074] Based on the determined Exif data, the image fingerprint corresponding to the determined image to be processed is corrected to obtain a corrected image fingerprint.
[0075] Specifically, the Exif plug-in can be used to obtain the Exif data corresponding to the image to be processed, and the Exif data contains the attribute information of the image to be processed, such as the orientation (which can be expressed as Orientation) information. For example, when the Orientation attribute value contained in the Exif data is 6, it means that the image to be processed is a left-rotated image, that is, the determined image fingerprint needs to be rotated right for correction processing.
[0076] Based on this, in one embodiment, the correcting the determined image fingerprint based on the determined Exif data may include:
[0077] Based on the determined Exif data, determining direction information of the image to be processed;
[0078] According to the determined direction information, the direction of the image fingerprint is corrected.
[0079] Exemplarily, when the preset size is 8×8, the direction correction of the image fingerprint according to the determined direction information may include: splitting the determined hash string into a two-dimensional array, the two-dimensional array contains 8 sub-arrays, each sub-array is an array containing 8 numbers, representing a single row of pixels of the image to be processed. When the image fingerprint needs to be corrected to the right, the split two-dimensional array can be rotated to the right to obtain a corrected two-dimensional array, and then the corrected two-dimensional array is combined to obtain a corrected hash string, that is, a corrected image fingerprint.
[0080] In actual application, the image processing methods provided by various embodiments of the present application can be applied in any scenario where image fingerprints need to be calculated, such as image recognition, image search, etc.
[0081] Based on this, in one embodiment, the method may further include:
[0082] Compare the image fingerprint corresponding to the image to be processed with the image fingerprint corresponding to the target image to obtain a comparison result;
[0083] According to the obtained comparison result, the similarity between the image to be processed and the target image is determined.
[0084] In actual application, the target image can be set according to needs. For example, the target image can be another local image selected by the user other than the image to be processed; for another example, the target image can be an image obtained by the terminal from the image library of the server.
[0085] In actual application, the similarity between the image to be processed and the target image can be determined by calculating the Hamming distance between the image fingerprint corresponding to the image to be processed and the image fingerprint corresponding to the target image. Specifically, the hash string corresponding to the image to be processed and the hash string corresponding to the target image can be traversed, and each character is compared. Each time the characters are not equal, the Hamming distance value is increased by 1. After the traversal is completed, if the Hamming distance value is less than 5, it indicates that the similarity between the image to be processed and the target image is high; if the Hamming distance value is greater than 10, it indicates that the image to be processed is completely different from the target image.
[0086] In the picture processing method provided in the embodiment of the present application, the terminal determines the picture to be processed through the target web page; obtains the bitmap picture corresponding to the picture to be processed from the cache area of the corresponding browser; the bitmap picture is generated in the process of the terminal loading the picture to be processed on the target web page; based on the bitmap picture, the picture fingerprint corresponding to the picture to be processed is determined using OpenCV technology. In the scheme of the embodiment of the present application, the terminal directly obtains the bitmap picture corresponding to the picture to be processed from the cache area of the corresponding browser, and determines the picture fingerprint corresponding to the picture to be processed using OpenCV technology. There is no need to upload the picture to be processed to the server for calculating the picture fingerprint. In this way, bandwidth occupation and server resource overhead can be saved. Moreover, when the size of the picture to be processed is large and the network environment is not good, the picture to be processed can also be processed quickly, saving user time and thus improving user experience.
[0087] The present application is further described in detail below in conjunction with application examples.
[0088] In this application embodiment, the target web page is called the front-end page, and the image fingerprint is called the hash value. Figure 2 As shown, the image processing method provided by this application embodiment includes:
[0089] Step 201: Select a local file and determine the image to be processed; then execute step 202.
[0090] Specifically, a local file selection control (i.e., the first control mentioned above) is added to the front-end page, and the file selection event is listened for; when the user clicks the control, the system will display the resource manager for the user to select a file. After the user selects a picture, the picture processing function will be triggered; the picture selected by the user is the picture to be processed.
[0091] Step 202: Load the image to be processed; then execute step 203.
[0092] Specifically, after the image processing function is triggered, the file object (i.e., the image to be processed) obtained in step 201 is passed as a parameter to the window.URL.createObjectURL method. The window.URL.createObjectURL method can convert (i.e., generate) a local file into a cache URL address that can be loaded and displayed by a web page (i.e., a front-end page); at the same time, dynamically create an HTML Object, The object is mainly used to display the image to be processed; the cache URL corresponding to the image to be processed is assigned to Here, the purpose of executing step 202 is to allow the front-end page to load the image to be processed in the cache area to obtain the bitmap data (i.e., the bitmap image) corresponding to the image to be processed. After the image processing function is triggered, the front-end web page will load the bitmap image corresponding to the image to be processed in the cache area, and trigger the callback function after the loading is completed, and process the corresponding bitmap image in this callback function.
[0093] Step 203: Use OpenCV technology to obtain a bitmap image corresponding to the image to be processed, perform grayscale processing, scaling processing and binarization processing based on the bitmap image, and obtain a hash value corresponding to the image to be processed; then execute step 204.
[0094] Specifically, after the callback function is triggered, the image data (i.e., the corresponding bitmap image) is read using OpenCV technology; the image data is gray-processed; and the size of the gray-processed image is scaled to 8×8 pixels; after the scaling process is completed, the average color value (i.e., grayscale) of the 64 pixels is calculated, and then each pixel is traversed. If the grayscale value of the corresponding pixel is greater than or equal to the average value, the hash value corresponding to the corresponding pixel is counted as 1, otherwise it is counted as 0; in this way, a hash string of only 1 and 0 is obtained, which is the hash value corresponding to the image to be processed.
[0095] Here, since some mobile devices have problems with the direction of pixel data in photos taken in landscape mode, it is necessary to obtain the EXIF data of the image to be processed through the EXIF plug-in. The EXIF data contains various attributes of the image, such as the Orientation attribute, which is used to indicate the direction of the image. After obtaining the EXIF data of the image to be processed, the Orientation attribute contained therein is used to correct the hash value corresponding to the image to be processed. For example, if the Orientation attribute value contained in the EXIF data of the image to be processed is 6 (indicating that the image to be processed is a left-rotated image), the hash value corresponding to the image to be processed needs to be corrected to rotate right.
[0096] When performing rotation correction on the hash value corresponding to the image to be processed, the hash value is first split into a two-dimensional hash array (each sub-array is an array containing eight numbers, representing a single row of pixels of the image, with a total of eight groups). If the image to be processed is a left-rotated image, the image is turned right (i.e., the two-dimensional hash array is rotated). In this way, a rotation-corrected two-dimensional hash array is obtained, and the rotation-corrected hash string (i.e., the corrected fingerprint hash value) is obtained by recombining the rotation-corrected two-dimensional hash array.
[0097] Step 204: Calculate the Hamming distance between the hash value corresponding to the image to be processed and the hash value corresponding to the target image.
[0098] Specifically, for the hash value corresponding to the image to be processed and the hash value corresponding to the target image, the two hash values are traversed, that is, a character-by-character comparison is performed; each time the characters are not equal, the Hamming distance is increased by 1; after the traversal, if the final calculated result of the Hamming distance is less than 5, it means that the two images are very similar; if the final calculated result of the Hamming distance is greater than 10, it means that they are not the same images, that is, the image to be processed and the target image are completely different images.
[0099] The image processing method provided by this application embodiment has the following advantages:
[0100] First, in business scenarios such as judging image similarity and image retrieval, there is no need to call any server service. Image fingerprint hash calculation can be performed on the pure front-end page, which can save bandwidth usage and server resource overhead. Moreover, even when the size of the images to be processed is large and the network environment is poor, the images to be processed can be processed quickly, saving user time and thus improving user experience.
[0101] Second, the image processing method provided by this application embodiment can be encapsulated into a front-end tool, which can be used conveniently and quickly in various business scenarios (i.e., business projects) that require image fingerprint calculation, and the calculated image fingerprint can be stored in the relevant business system.
[0102] In order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a picture processing device, which is arranged on a terminal, such as Figure 3 As shown, the device comprises:
[0103] The first processing unit 301 is used to determine the image to be processed through the target web page;
[0104] The second processing unit 302 is used to obtain a bitmap image corresponding to the image to be processed from the cache area of the corresponding browser; the bitmap image is generated when the terminal loads the image to be processed on the target web page;
[0105] The third processing unit 303 is used to determine the image fingerprint corresponding to the image to be processed based on the bitmap image by using OpenCV technology.
[0106] In one embodiment, the first processing unit 301 is used to:
[0107] Monitoring a selection operation on a local file using a first control on the target webpage;
[0108] The picture to be processed is determined according to the monitored selection operation on the local file.
[0109] In one embodiment, the third processing unit 303 is configured to:
[0110] Perform grayscale processing on the bitmap image using OpenCV technology to obtain a first image;
[0111] Based on a preset size, the first image is scaled using OpenCV technology to obtain a second image;
[0112] Grayscale binarization is performed on all pixels contained in the second image to obtain an image fingerprint corresponding to the image to be processed.
[0113] In one embodiment, the third processing unit 303 is configured to:
[0114] Determine the grayscale average value of all pixels included in the second image;
[0115] The determined grayscale average value is used to perform binarization processing on the grayscale value of each pixel included in the second image.
[0116] In one embodiment, the image processing apparatus further includes a fourth processing unit, configured to:
[0117] Determine the Exif data corresponding to the image to be processed;
[0118] Based on the determined Exif data, the image fingerprint corresponding to the determined image to be processed is corrected to obtain a corrected image fingerprint.
[0119] In one embodiment, the fourth processing unit is used to:
[0120] Based on the determined Exif data, determining direction information of the image to be processed;
[0121] According to the determined direction information, the direction of the image fingerprint is corrected.
[0122] In one embodiment, the image processing apparatus further includes a fifth processing unit, configured to:
[0123] Compare the image fingerprint corresponding to the image to be processed with the image fingerprint corresponding to the target image to obtain a comparison result;
[0124] According to the obtained comparison result, the similarity between the image to be processed and the target image is determined.
[0125] In actual application, the first processing unit 301, the second processing unit 302, the third processing unit 303, the fourth processing unit and the fifth processing unit can be implemented by a processor in the image processing device.
[0126] It should be noted that: the image processing device provided in the above embodiment only uses the division of the above program modules as an example to illustrate when processing images. In actual application, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device is divided into different program modules to complete all or part of the processing described above. In addition, the image processing device provided in the above embodiment and the image processing method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0127] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiment of the present application, the embodiment of the present application also provides a terminal, such as Figure 4 As shown, the terminal 400 includes:
[0128] Communication interface 401, capable of exchanging information with other electronic devices;
[0129] A processor 402, connected to the communication interface 401 to implement information interaction with other electronic devices, and used to execute the method provided by one or more of the above technical solutions when running a computer program;
[0130] The memory 403 is used to store a computer program that can be executed on the processor 402 .
[0131] Specifically, the processor 402 is configured to perform the following operations:
[0132] Determine the image to be processed through the target web page;
[0133] Obtaining a bitmap image corresponding to the image to be processed from a cache area of a corresponding browser; the bitmap image is generated when the terminal 400 loads the image to be processed on the target web page;
[0134] Based on the bitmap image, the image fingerprint corresponding to the image to be processed is determined using OpenCV technology.
[0135] In one embodiment, the processor 402 is configured to perform the following operations:
[0136] Monitoring a selection operation on a local file using a first control on the target webpage;
[0137] The picture to be processed is determined according to the monitored selection operation on the local file.
[0138] In one embodiment, the processor 402 is configured to perform the following operations:
[0139] Perform grayscale processing on the bitmap image using OpenCV technology to obtain a first image;
[0140] Based on a preset size, the first image is scaled using OpenCV technology to obtain a second image;
[0141] Grayscale binarization is performed on all pixels contained in the second image to obtain an image fingerprint corresponding to the image to be processed.
[0142] In one embodiment, the processor 402 is configured to perform the following operations:
[0143] Determine the grayscale average value of all pixels included in the second image;
[0144] The determined grayscale average value is used to perform binarization processing on the grayscale value of each pixel included in the second image.
[0145] In one embodiment, the processor 402 is configured to perform the following operations:
[0146] Determine the Exif data corresponding to the image to be processed;
[0147] Based on the determined Exif data, the image fingerprint corresponding to the determined image to be processed is corrected to obtain a corrected image fingerprint.
[0148] In one embodiment, the processor 402 is configured to perform the following operations:
[0149] Based on the determined Exif data, determining direction information of the image to be processed;
[0150] According to the determined direction information, the direction of the image fingerprint is corrected.
[0151] In one embodiment, the processor 402 is configured to perform the following operations:
[0152] Compare the image fingerprint corresponding to the image to be processed with the image fingerprint corresponding to the target image to obtain a comparison result;
[0153] According to the obtained comparison result, the similarity between the image to be processed and the target image is determined.
[0154] It should be noted that: the specific process of the processor 402 performing the above operations is detailed in the method embodiment, which will not be repeated here.
[0155] Of course, in actual application, the various components in the terminal 400 are coupled together through the bus system 404. It can be understood that the bus system 404 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 404 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, Figure 4Various buses are labeled as bus system 404 .
[0156] The memory 403 in the embodiment of the present application is used to store various types of data to support the operation of the terminal 400. Examples of such data include: any computer program used to operate on the terminal 400.
[0157] The method disclosed in the above embodiment of the present application can be applied to the processor 402, or implemented by the processor 402. The processor 402 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 402. The above processor 402 may be a general processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 402 can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor may be a microprocessor or any conventional processor, etc. In combination with the steps of the method disclosed in the embodiment of the present application, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in the memory 403, and the processor 402 reads the information in the memory 403 and completes the steps of the above method in combination with its hardware.
[0158] In an exemplary embodiment, the terminal 400 may be implemented by one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD), field programmable gate array (FPGA), general processor, controller, microcontroller (MCU), microprocessor, or other electronic components to execute the aforementioned method.
[0159] It can be understood that the memory 403 of the embodiment of the present application can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a magnetic random access memory (FRAM), a ferromagnetic random access memory, a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM); the magnetic surface memory can be a disk memory or a tape memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM, SyncLink Dynamic Random Access Memory), and direct RAMbus random access memory (DRRAM, Direct Rambus Random Access Memory).The memory described in the embodiments of the present application is intended to include, but is not limited to, these and any other suitable types of memory.
[0160] In an exemplary embodiment, the present application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, for example, a memory 403 storing a computer program, and the computer program can be executed by a processor 402 of a terminal 400 to complete the steps of the aforementioned method. The computer-readable storage medium can be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface storage, optical disk, or CD-ROM.
[0161] It should be noted that: "first", "second", etc. are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0162] In addition, the technical solutions described in the embodiments of the present application can be combined arbitrarily without conflict.
[0163] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application.
Claims
1. A method for processing an image, characterized in that: Applied to terminals, including: Determine the image to be processed through the target web page; Acquire a bitmap image corresponding to the image to be processed from a cache area of a corresponding browser; the bitmap image is generated when the terminal loads the image to be processed on the target web page; Based on the bitmap image, using OpenCV technology, determine the image fingerprint corresponding to the image to be processed; Wherein, determining the image to be processed through the target webpage includes: Monitoring a selection operation on a local file using a first control on the target webpage; Determine the image to be processed according to the monitored selection operation on the local file; Before obtaining the bitmap image corresponding to the image to be processed from the cache area of the corresponding browser, the method further includes: Generate a uniform resource locator URL corresponding to the image to be processed; Assign the URL to the HTML corresponding to the image to be processed. The src attribute of the object; The object is used to load and display the image to be processed; The image to be processed is loaded on the target web page, and a bitmap image corresponding to the image to be processed is generated in a cache area of a corresponding browser.
2. The method according to claim 1, characterized in that The determining, based on the bitmap image, the image fingerprint corresponding to the image to be processed by using OpenCV technology includes: Perform grayscale processing on the bitmap image using OpenCV technology to obtain a first image; Based on a preset size, the first image is scaled using OpenCV technology to obtain a second image; Grayscale binarization is performed on all pixels contained in the second image to obtain an image fingerprint corresponding to the image to be processed.
3. The method according to claim 2, characterized in that The performing grayscale binarization processing on all pixels included in the second image includes: Determine the grayscale average value of all pixels included in the second image; The determined grayscale average value is used to perform binarization processing on the grayscale value of each pixel included in the second image.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Determine the Exchangeable Image File Format Exif data corresponding to the image to be processed; Based on the determined Exif data, the image fingerprint corresponding to the determined image to be processed is corrected to obtain a corrected image fingerprint.
5. The method according to claim 4, characterized in that The correcting the determined image fingerprint based on the determined Exif data includes: Based on the determined Exif data, determining direction information of the image to be processed; According to the determined direction information, the direction of the image fingerprint is corrected.
6. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Compare the image fingerprint corresponding to the image to be processed with the image fingerprint corresponding to the target image to obtain a comparison result; According to the obtained comparison result, the similarity between the image to be processed and the target image is determined.
7. A picture processing device, characterized in that: include: A first processing unit, used to determine a picture to be processed through a target web page; A second processing unit is used to obtain a bitmap image corresponding to the image to be processed from a cache area of a corresponding browser; the bitmap image is generated when the terminal loads the image to be processed on the target web page; A third processing unit is used to determine the image fingerprint corresponding to the image to be processed based on the bitmap image using OpenCV technology; The first processing unit is used to monitor the selection operation of the local file by using the first control on the target web page; determine the image to be processed according to the monitored selection operation of the local file; generate a uniform resource locator URL corresponding to the image to be processed; assign the URL to the hypertext markup language HTML corresponding to the image to be processed The src attribute of the object; The object is used to load and display the image to be processed; the image to be processed is loaded on the target web page, and a bitmap image corresponding to the image to be processed is generated in the cache area of the corresponding browser.
8. A terminal, characterized in that: include: a processor and a memory for storing a computer program capable of being executed on the processor; Wherein, when the processor is used to run the computer program, it executes the steps of the method described in any one of claims 1 to 6.
9. A storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Picture loading method and terminal
CN107463627A