CN112579812A - Method and device for retrieving pictures and computer equipment - Google Patents

Method and device for retrieving pictures and computer equipment Download PDF

Info

Publication number
CN112579812A
CN112579812A CN202011506601.1A CN202011506601A CN112579812A CN 112579812 A CN112579812 A CN 112579812A CN 202011506601 A CN202011506601 A CN 202011506601A CN 112579812 A CN112579812 A CN 112579812A
Authority
CN
China
Prior art keywords
picture
preset
analyzed
fingerprint information
calculating
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011506601.1A
Other languages
Chinese (zh)
Other versions
CN112579812B (en
Inventor
季潮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202011506601.1A priority Critical patent/CN112579812B/en
Publication of CN112579812A publication Critical patent/CN112579812A/en
Application granted granted Critical
Publication of CN112579812B publication Critical patent/CN112579812B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/58Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually
    • G06F16/583Retrieval characterised by using metadata, e.g. metadata not derived from the content or metadata generated manually using metadata automatically derived from the content
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/50Information retrieval; Database structures therefor; File system structures therefor of still image data
    • G06F16/53Querying
    • G06F16/538Presentation of query results
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Library & Information Science (AREA)
  • Collating Specific Patterns (AREA)

Abstract

The application relates to the field of artificial intelligence, and discloses a method for retrieving pictures, which comprises the following steps: acquiring a picture to be analyzed; calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value; calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library; judging whether the preset picture library has a designated picture meeting the requirement of the preset similarity or not according to the similarities; and if so, returning the specified picture to a terminal display interface. The hash value of the picture is calculated through a hash algorithm to serve as fingerprint information for identifying the picture, and by deploying the distributed architecture cluster, the similar pictures with the current picture to be analyzed are quickly and accurately searched in a large-batch picture library.

Description

Method and device for retrieving pictures and computer equipment
Technical Field
The present application relates to the field of artificial intelligence, and in particular, to a method, an apparatus, and a computer device for retrieving pictures.
Background
The anti-fraud decision engine has an irreplaceable role in enterprise risk management. At present, a relatively mature anti-fraud decision engine in the financial industry mainly relies on human behavior data, and identifies users with credit fraud risks by establishing a series of customer portrait labels as factors of the anti-fraud decision engine. However, in the insurance field, especially in the fields of car insurance and property insurance, besides analyzing the portrait labels of the related insurance persons, the proof materials such as image materials and the like are still important factors for considering the fraud, such as photos of the scene of a case, driving licenses, driving license certificates and the like. However, the existing anti-fraud decision system does not rely on the non-structured data to analyze the authenticity of the image material, the similarity before every two pictures is extracted and calculated by the existing convolutional neural network, the consumption of required calculation resources is extremely high, the cost is too high, and the system is not suitable for the insurance anti-fraud engineering with large-scale pictures.
Disclosure of Invention
The application mainly aims to provide a method for retrieving pictures, and aims to solve the technical problem that the existing picture retrieval is not suitable for large-scale picture library retrieval.
The application provides a method for retrieving pictures, which comprises the following steps:
acquiring a picture to be analyzed;
calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value;
calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library;
judging whether the preset picture library has a designated picture meeting the requirement of the preset similarity or not according to the similarities;
and if so, returning the specified picture to a terminal display interface.
Preferably, the step of calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity between the picture to be analyzed and each picture in a preset picture library, respectively, includes:
setting field bits with the same number as the characters according to the number of the characters in the character string of the fingerprint information;
filling all characters in the character string into the field positions in sequence in a one-to-one correspondence manner according to the arrangement sequence in the fingerprint information to form fingerprint fields;
comparing the fingerprint field with the difference quantity corresponding to the fingerprint field of each picture in the preset picture library respectively;
and taking each difference quantity as the similarity corresponding to each picture in the picture to be analyzed and each picture in the preset picture library.
Preferably, the step of calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode includes:
converting the picture to be analyzed into a corresponding frequency domain graph;
intercepting a designated area with the frequency less than a preset frequency in a frequency domain graph corresponding to the picture to be analyzed;
calculating a hash value of the designated area;
and setting the hash value of the designated area as the picture fingerprint corresponding to the picture to be analyzed.
Preferably, the designated area is a non-zero area of discrete transform coefficients, and the step of calculating the hash value of the designated area includes:
calculating an arithmetic mean of a non-zero region of the discrete transform coefficients;
in a non-zero region of the discrete transform coefficient, a flag number that the discrete transform coefficient is greater than or equal to the arithmetic mean is 1, and a flag number that the discrete transform coefficient is less than the arithmetic mean is 0;
and combining all the mark numbers into a digital structure body as the hash value of the designated area.
Preferably, the step of intercepting the designated area with the frequency less than the preset frequency in the frequency domain graph corresponding to the picture to be analyzed includes:
identifying frequency identification data in a frequency domain graph corresponding to the picture to be analyzed;
determining a matrix area where the lowest frequency data are located according to the frequency identification data;
and taking the matrix area as the designated area.
Preferably, the step of converting the picture to be analyzed into a corresponding frequency domain map includes:
calling a first function to convert the picture to be analyzed into a digital matrix;
calling a second function to scale the picture size of the digital matrix to a preset size;
calling a third function to convert the picture of the digital matrix which is scaled to the preset size into a gray image;
and calling a fourth function to convert the gray image from a space domain signal to a frequency domain signal to obtain a frequency domain image corresponding to the picture to be analyzed.
Preferably, after the step of returning the designated picture to the terminal display interface, the method includes:
calculating the access state quantity of the appointed terminal in a preset time period according to an appointed calculation mode, wherein the appointed calculation mode is
Figure BDA0002845113900000031
F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2An access state quantity at a time, p (x) representing a frequency concentration of access information;
judging whether the appointed terminal exceeds a preset threshold value in a preset time period or not according to the access state quantity;
and if so, amplifying the memory occupation ratio of the designated terminal corresponding to the distributed architecture.
The present application further provides a device for retrieving pictures, including:
the acquisition module is used for acquiring a picture to be analyzed;
the first calculation module is used for calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value;
the calling module is used for calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library;
the first judgment module is used for judging whether the appointed pictures meeting the requirement of the preset similarity exist in the preset picture library or not according to the similarities;
and the returning module is used for returning the appointed picture to the terminal display interface if the appointed picture meeting the preset similarity requirement exists.
The present application further provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method as described above.
According to the method and the device, the Hash value of the picture is calculated through a Hash algorithm to serve as fingerprint information for identifying the picture, and the similar picture with the current picture to be analyzed is quickly and accurately searched in a large-batch picture library by deploying the distributed architecture cluster.
Drawings
FIG. 1 is a schematic flow chart illustrating a method for retrieving pictures according to an embodiment of the present application;
FIG. 2 is a schematic flow chart illustrating a system for retrieving pictures according to an embodiment of the present application;
fig. 3 is a schematic diagram of an internal structure of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
Referring to fig. 1, a method for retrieving pictures according to an embodiment of the present application includes:
s1: acquiring a picture to be analyzed;
s2: calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value;
s3: calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library;
s4: judging whether the preset picture library has a designated picture meeting the requirement of the preset similarity or not according to the similarities;
s5: and if so, returning the specified picture to a terminal display interface.
In the embodiment of the application, the hash value of the picture is calculated through the hash algorithm and is used as the fingerprint information of the picture, the hash algorithm does not need to consume expensive GPU resources, the calculation process is simple, and the accuracy of picture feature extraction is high. For a service scene needing to process the similarity of a large batch of pictures, the method is very suitable for engineering deployment of fingerprint information of the pictures calculated through a Hash algorithm, can quickly and accurately finish Hash value conversion and extraction of the characteristics of the large batch of pictures, and determines the similarity of the pictures by comparing the similarity of the Hash values. The fingerprint information corresponding to each picture is stored in the preset picture library, and the number of the stored pictures can reach billions. The python program for calculating the hash value and comparing the hash value is deployed in a big data distributed architecture Spark cluster, and pictures with second-level response occurrence times larger than 1 can be realized through the distributed processing capacity of parallel calculation.
According to the method and the device, the Hash value of the picture is calculated through a Hash algorithm to serve as fingerprint information for identifying the picture, and the similar picture with the current picture to be analyzed is quickly and accurately searched in a large-batch picture library by deploying the distributed architecture cluster.
Further, step S3, which is to call a preset calculation instruction in the distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculate the similarity between the picture to be analyzed and each picture in a preset picture library, includes:
s31: setting field bits with the same number as the characters according to the number of the characters in the character string of the fingerprint information;
s32: filling all characters in the character string into the field positions in sequence in a one-to-one correspondence manner according to the arrangement sequence in the fingerprint information to form fingerprint fields;
s33: comparing the fingerprint field with the difference quantity corresponding to the fingerprint field of each picture in the preset picture library respectively;
s34: and taking each difference quantity as the similarity corresponding to each picture in the picture to be analyzed and each picture in the preset picture library.
In the embodiment of the application, the difference degree or the similarity degree of the two pictures is represented by calculating the Hamming distance of the fingerprint information of the two pictures. Firstly, the fingerprint information is disassembled into fingerprint fields respectively filled by single characters according to the number of the characters of the character strings, and the difference number of the characters respectively corresponding to the field positions in each arrangement sequence is compared one by one through full arrangement to obtain the similarity of two pictures. The larger the hamming distance is, the larger the difference degree of the pictures is, and conversely, the smaller the hamming distance is, the higher the similarity degree is. The hamming distance is 0, i.e. the two pictures are identical.
In the embodiment of the application, fingerprint information directly acquired from a picture to be analyzed is a 64-bit binary hash value, in order to further increase the comparison speed and improve the quick response of search results from a large amount of picture data, the 64-bit binary hash value is converted into a 16-bit hash value in advance, the fingerprint information of all pictures in a picture library is converted into the 16-bit hash value and stored on a big data cluster, and then distributed concurrent batch calculation is performed by calling a big data Spark frame, so that the comparison result is quickly obtained.
For example, the fingerprint information of the picture 1 is 1888A8F16B3E188B, and the picture library includes a picture 2, a picture 3, a picture 4, a picture 5, and the like. The character string of the fingerprint information 1888A8F16B3E188B of the picture 1 is disassembled according to each character and respectively stored in 16 fields to form a fingerprint field. Thus, the fingerprint information of each picture correspondingly forms a line of data, and the data format is picture ID +16 fingerprint fields. In order to facilitate calculation and comparison, the 16-system letter segment is adjusted to be in a 10-system expression form, that is, a in the 16-system is correspondingly stored as a numerical value 10, and so on. Fingerprint information for the stored picture is finally generated as in table 1.
Table 1
Figure BDA0002845113900000061
In the comparison process, firstly, spark sql sentences for searching the identical pictures are called, and whether the hash values of all the pictures are identical or not is compared in batches. For example, spark sql is performed, "select column1, column3from table tb1 inner join table tb2 where tb1.column 1 ═ picture 1'; and tb1.column2 ═ tb2.column4 ". During execution, a process table such as table 2 is generated. The result is that the hash values of the picture 1 and the picture 5 are identical.
The corresponding spark sql statement can be selected and called according to the business scene to carry out information comparison. For example, whether there is a violation picture of human leakage in the insurance claims is judged, and such picture must be the same picture as other pictures. The duplicate picture can be quickly determined by invoking the spark sql statement that searches for duplicate pictures as described above. For another example, in the insurance claim settlement service, similar pictures with similar scene and repeated locations will be used in the counterfeit scene of the agency such as the repair shop, and in this case, the similar pictures can be searched by calling the spark sql statement "select tb1.p1-tb2.p1, tb1.p2-tb2.p2, tb1.p3-tb2.p3, …", tb1.p16-tb2.p16 from table tb1 inner join table tb2, where tb1.column 1 'picture 1'.
Table 2
Colum1 Colum2 Colum3 Colum4
Picture ID Picture hash value Picture ID Picture hash value
Picture
1 1888A8F16B3E188B Picture 2 1828A8F16B3E188B
Picture
1 1888A8F16B3E188B Picture 3 1888A8F16B3E186B
Picture
1 1888A8F16B3E188B Picture 4 2828A8F16B3E188B
Picture
1 1888A8F16B3E188B Picture 5 1888A8F16B3E188B
And a second step of the comparison process, calculating the difference of the hash values of the pictures in batch by using spark sql of the searched similar pictures, and generating a calculation result table in a form 3 style in the calculation process. The picture 1 is respectively and correspondingly compared with the picture 2, the picture 3 and the picture 4, the hash values of the picture 2, the picture 3 and the picture 4 are respectively and correspondingly subtracted through the hash value of the picture 1, so that the phase difference quantity of each field bit is obtained, the field bit with the assignment difference quantity of zero represents that the field characters are the same, and the field bits which are different in contrast can generate non-zero assignment difference quantities. The fingerprint difference is obtained by counting the field bit number of the non-zero assignment difference, and is filled in the result column of the last column, for example, if a different character appears, the result is accumulated with 1.
Table 3
Figure BDA0002845113900000072
Further, the step S2 of calculating the fingerprint information corresponding to the picture to be analyzed according to a preset manner includes:
s21: converting the picture to be analyzed into a corresponding frequency domain graph;
s22: intercepting a designated area with the frequency less than a preset frequency in a frequency domain graph corresponding to the picture to be analyzed;
s23: calculating a hash value of the designated area;
s24: and setting the hash value of the designated area as the picture fingerprint corresponding to the picture to be analyzed.
The picture fingerprint information of the embodiment of the application is realized by selecting the designated area representing the picture content. Firstly, the space domain signal of the picture is converted into the frequency domain signal through discrete cosine transform, so that the converted picture has good decorrelation performance, and the characteristic performance is more prominent. For example, the picture gray scale changes fast to high frequency data, and changes slowly to low frequency data. The high-frequency data are arranged in the edge area of the picture, the low-frequency data are arranged in the inner area of the picture, the main content area of the picture is screened by reserving the lowest-frequency data in the picture, the picture characteristics are highlighted, and the accuracy of representing the fingerprint information of the picture by the hash value of the picture is further enhanced.
In the embodiment of the present application, the discrete cosine transform is formed by
Figure BDA0002845113900000071
Wherein x, u ═ 0,1,2, …, M-1; y, v ═ 0,1,2, …, N-1, M and N are positive real numbers, and c (u) and c (v) are compensation coefficients. For example, f (x, y) is a number matrix M × N of the picture before conversion, and is calculated by the discrete cosine transform formula:
Figure BDA0002845113900000081
the gray scale map is subjected to discrete cosine transform, and F (u, v) represents a fill map of the transformed discrete transform coefficients.
Further, the step S23 of calculating the hash value of the designated area, where the designated area is a non-zero area of the discrete transform coefficient, includes:
s231: calculating an arithmetic mean of a non-zero region of the discrete transform coefficients;
s232: in a non-zero region of the discrete transform coefficient, a flag number that the discrete transform coefficient is greater than or equal to the arithmetic mean is 1, and a flag number that the discrete transform coefficient is less than the arithmetic mean is 0;
s233: and combining all the mark numbers into a digital structure body as the hash value of the designated area.
In the embodiment of the application, a matrix of 8 x 8 in the upper left corner of the picture is determined by screening low-frequency data, and the lowest-frequency data in the picture is presented as a designated area. The arithmetic mean of the discrete transform coefficients of the 8 x 8 matrix at the top left corner of the picture is calculated, and then all hash values in the matrix are marked according to the arithmetic mean. The digital structure comprises a data matrix arranged in a matrix form and also comprises data character strings which are sequentially arranged according to the matrix direction and serve as fingerprint information of the picture.
Further, in the frequency domain diagram corresponding to the picture to be analyzed, the step S22 of intercepting the designated area with the frequency less than the preset frequency includes:
s221: identifying frequency identification data in a frequency domain graph corresponding to the picture to be analyzed;
s222: determining a matrix area where the lowest frequency data are located according to the frequency identification data;
s223: and taking the matrix area as the designated area.
In the embodiment of the application, the frequency identification data is a discrete transform coefficient, and a matrix region where the lowest frequency data is located is determined according to the size of the discrete transform coefficient, that is, a non-zero region where the discrete transform coefficient is the smallest.
Further, the step S21 of converting the picture to be analyzed into a corresponding frequency domain map includes:
s211: calling a first function to convert the picture to be analyzed into a digital matrix;
s212: calling a second function to scale the picture size of the digital matrix to a preset size;
s213: calling a third function to convert the picture of the digital matrix which is scaled to the preset size into a gray image;
s214: and calling a fourth function to convert the gray image from a space domain signal to a frequency domain signal to obtain a frequency domain image corresponding to the picture to be analyzed.
In the embodiment of the present application, the first function is a cv2. immead () function, which is used to read a picture and convert the picture into a digital matrix. The second function is the cv2.resize () function, which is used to scale the picture size to simplify the computation of the discrete transform. For example, cv2.resize (img, (32,32)) means scaling the picture to a size of 32 × 32. The third function is cv2.cvtcolor () function, which converts gray. Such as cv2.cvtColor (img, cv2.COLOR _ BGR2 GRAY). The above-mentioned gray scale conversion algorithm includes, but is not limited to, the maximum value method, i.e. the converted R, G, B value is equal to the maximum value of the three values before conversion, so as to increase the brightness of the gray scale map; an average value method, namely the R, G and B values after conversion are the average values of the R, G and B values before conversion, so that the gray level image is softer; only taking green color, namely Gray ═ G, to highlight the picture features; the weighted average method is that the values of R, G, and B are weighted and averaged according to a certain weight, that is: r ═ G ═ B ═ ω (ω)RR+ωGG+ωBB)/3,ωR、ωG、ωBThe weights of R, G and B are respectively taken to form different gray level images. The embodiment of the present application preferably only takes green color, i.e., Gray ═ G, to highlight the picture features.
Further, after the step S5 of returning the designated picture to the terminal display interface, the method includes:
s51: calculating the access state quantity of the appointed terminal in a preset time period according to an appointed calculation mode, wherein the appointed calculation mode is
Figure BDA0002845113900000091
F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2An access state quantity at a time, p (x) representing a frequency concentration of access information;
s52: judging whether the appointed terminal exceeds a preset threshold value in a preset time period or not according to the access state quantity;
s53: and if so, amplifying the memory occupation ratio of the designated terminal corresponding to the distributed architecture.
According to the embodiment of the application, the computing resources of the retrieval pictures called by each terminal on the distributed architecture are reasonably distributed, the proportion of the resources can be distributed in real time according to the access state quantity of each terminal, and the operation efficiency and the operation traffic are improved.
Referring to fig. 2, an apparatus for retrieving pictures according to an embodiment of the present application includes:
the acquisition module 1 is used for acquiring a picture to be analyzed;
the first calculating module 2 is configured to calculate fingerprint information corresponding to the picture to be analyzed according to a preset manner, where the fingerprint information is a hash value;
the calling module 3 is used for calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library;
the first judging module 4 is used for judging whether the appointed pictures meeting the requirement of the preset similarity exist in the preset picture library according to the similarities;
and the returning module 5 is used for returning the specified picture to the terminal display interface if the specified picture meeting the preset similarity requirement exists.
The explanation of the embodiment of the device part of the present application is the same as that of the corresponding method part, and is not repeated.
Further, the calling module 3 includes:
a first setting unit, configured to set field bits having the same number as the number of characters in a character string of the fingerprint information;
the filling unit is used for filling all the characters in the character string into the field positions in sequence in a one-to-one correspondence manner according to the arrangement sequence in the fingerprint information to form fingerprint fields;
the comparison unit is used for comparing the fingerprint field with the difference quantity respectively corresponding to the fingerprint field of each picture in the preset picture library;
and the unit is used for taking each difference quantity as the similarity corresponding to each picture in the picture to be analyzed and each picture in the preset picture library.
Further, the calculation module 2 includes:
the conversion unit is used for converting the picture to be analyzed into a corresponding frequency domain graph;
the intercepting unit is used for intercepting a specified area with the frequency less than the preset frequency in the frequency domain graph corresponding to the picture to be analyzed;
a calculation unit configured to calculate a hash value of the designated area;
and the second setting unit is used for setting the hash value of the designated area to the picture fingerprint corresponding to the picture to be analyzed.
Further, the specified region is a non-zero region of discrete transform coefficients, and the calculation unit includes:
a calculating subunit for calculating an arithmetic mean of a non-zero region of the discrete transform coefficients;
a flag subunit, configured to set, in a non-zero region of the discrete transform coefficient, a flag number of the discrete transform coefficient greater than or equal to the arithmetic mean to 1, and a flag number of the discrete transform coefficient smaller than the arithmetic mean to 0;
the first sub-unit is used for combining all the mark numbers into a digital structure body as the hash value of the designated area.
Further, the intercepting unit includes:
the identification subunit is used for identifying frequency identification data in the frequency domain graph corresponding to the picture to be analyzed;
the determining subunit is used for determining a matrix area where the lowest frequency data are located according to the frequency identification data;
and the second is used as a subunit for taking the matrix area as the designated area.
Further, a conversion unit comprising:
the first calling subunit is used for calling a first function to convert the picture to be analyzed into a digital matrix;
the second calling subunit is used for calling a second function to zoom the picture size of the digital matrix to a preset size;
the third calling subunit is used for calling a third function to convert the picture of the digital matrix which is scaled to the preset size into a gray image;
and the fourth calling subunit is used for calling a fourth function to convert the grayscale image from a space domain signal to a frequency domain signal so as to obtain a frequency domain image corresponding to the picture to be analyzed.
Further, an apparatus for retrieving pictures, comprising:
a second calculation module, configured to calculate an access state quantity of the designated terminal in a preset time period according to a designated calculation manner, where the designated calculation manner is
Figure BDA0002845113900000111
F (x) represents t1Time to t2Of time of dayAccess state quantity, xt1Represents t1Access state quantity at time, xt2Represents t2An access state quantity at a time, p (x) representing a frequency concentration of access information;
the second judgment module is used for judging whether the appointed terminal exceeds a preset threshold value in a preset time period according to the access state quantity;
and the amplification module is used for amplifying the memory occupation ratio of the designated terminal on the distributed architecture if the memory occupation ratio exceeds a preset threshold value.
Referring to fig. 3, a computer device, which may be a server and whose internal structure may be as shown in fig. 3, is also provided in the embodiment of the present application. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the computer designed processor is used to provide computational and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store all data required by the process of retrieving pictures. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of retrieving a picture.
The processor executes the method for retrieving the picture, and the method comprises the following steps: acquiring a picture to be analyzed; calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value; calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library; judging whether the preset picture library has a designated picture meeting the requirement of the preset similarity or not according to the similarities; and if so, returning the specified picture to a terminal display interface.
According to the computer equipment, the hash value of the picture is calculated through the hash algorithm to serve as the fingerprint information for identifying the picture, and the distributed architecture cluster is deployed, so that the similar picture to the current picture to be analyzed can be quickly and accurately searched in a large-batch picture library.
In one embodiment, the step of the processor invoking a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity between the picture to be analyzed and each picture in a preset picture library, which corresponds to each other, includes: setting field bits with the same number as the characters according to the number of the characters in the character string of the fingerprint information; filling all characters in the character string into the field positions in sequence in a one-to-one correspondence manner according to the arrangement sequence in the fingerprint information to form fingerprint fields; comparing the fingerprint field with the difference quantity corresponding to the fingerprint field of each picture in the preset picture library respectively; and taking each difference quantity as the similarity corresponding to each picture in the picture to be analyzed and each picture in the preset picture library.
In an embodiment, the step of calculating, by the processor, fingerprint information corresponding to the picture to be analyzed according to a preset manner includes: converting the picture to be analyzed into a corresponding frequency domain graph; intercepting a designated area with the frequency less than a preset frequency in a frequency domain graph corresponding to the picture to be analyzed; calculating a hash value of the designated area; and setting the hash value of the designated area as the picture fingerprint corresponding to the picture to be analyzed.
In one embodiment, the processor designates the region as a non-zero region of the discrete transform coefficients, and the step of calculating the hash value of the designated region includes: calculating an arithmetic mean of a non-zero region of the discrete transform coefficients; in a non-zero region of the discrete transform coefficient, a flag number that the discrete transform coefficient is greater than or equal to the arithmetic mean is 1, and a flag number that the discrete transform coefficient is less than the arithmetic mean is 0; and combining all the mark numbers into a digital structure body as the hash value of the designated area.
In an embodiment, the step of intercepting, by the processor, the designated area with a frequency smaller than a preset frequency in the frequency domain graph corresponding to the picture to be analyzed includes: identifying frequency identification data in a frequency domain graph corresponding to the picture to be analyzed; determining a matrix area where the lowest frequency data are located according to the frequency identification data; and taking the matrix area as the designated area.
In an embodiment, the step of converting the picture to be analyzed into the corresponding frequency domain map by the processor includes: calling a first function to convert the picture to be analyzed into a digital matrix; calling a second function to scale the picture size of the digital matrix to a preset size; calling a third function to convert the picture of the digital matrix which is scaled to the preset size into a gray image; and calling a fourth function to convert the gray image from a space domain signal to a frequency domain signal to obtain a frequency domain image corresponding to the picture to be analyzed.
In an embodiment, after the step of returning the designated picture to the terminal display interface by the processor, the method includes: calculating the access state quantity of the appointed terminal in a preset time period according to an appointed calculation mode, wherein the appointed calculation mode is
Figure BDA0002845113900000131
F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2An access state quantity at a time, p (x) representing a frequency concentration of access information; judging whether the appointed terminal exceeds a preset threshold value in a preset time period or not according to the access state quantity; and if so, amplifying the memory occupation ratio of the designated terminal corresponding to the distributed architecture.
Those skilled in the art will appreciate that the architecture shown in fig. 3 is only a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects may be applied.
An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements a method for retrieving a picture, including: acquiring a picture to be analyzed; calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value; calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library; judging whether the preset picture library has a designated picture meeting the requirement of the preset similarity or not according to the similarities; and if so, returning the specified picture to a terminal display interface.
According to the computer-readable storage medium, the hash value of the picture is calculated through the hash algorithm to serve as fingerprint information for identifying the picture, and by deploying the distributed architecture cluster, the similar picture with the current picture to be analyzed can be quickly and accurately searched in a large-batch picture library.
In one embodiment, the step of the processor invoking a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity between the picture to be analyzed and each picture in a preset picture library, which corresponds to each other, includes: setting field bits with the same number as the characters according to the number of the characters in the character string of the fingerprint information; filling all characters in the character string into the field positions in sequence in a one-to-one correspondence manner according to the arrangement sequence in the fingerprint information to form fingerprint fields; comparing the fingerprint field with the difference quantity corresponding to the fingerprint field of each picture in the preset picture library respectively; and taking each difference quantity as the similarity corresponding to each picture in the picture to be analyzed and each picture in the preset picture library.
In an embodiment, the step of calculating, by the processor, fingerprint information corresponding to the picture to be analyzed according to a preset manner includes: converting the picture to be analyzed into a corresponding frequency domain graph; intercepting a designated area with the frequency less than a preset frequency in a frequency domain graph corresponding to the picture to be analyzed; calculating a hash value of the designated area; and setting the hash value of the designated area as the picture fingerprint corresponding to the picture to be analyzed.
In one embodiment, the processor designates the region as a non-zero region of the discrete transform coefficients, and the step of calculating the hash value of the designated region includes: calculating an arithmetic mean of a non-zero region of the discrete transform coefficients; in a non-zero region of the discrete transform coefficient, a flag number that the discrete transform coefficient is greater than or equal to the arithmetic mean is 1, and a flag number that the discrete transform coefficient is less than the arithmetic mean is 0; and combining all the mark numbers into a digital structure body as the hash value of the designated area.
In an embodiment, the step of intercepting, by the processor, the designated area with a frequency smaller than a preset frequency in the frequency domain graph corresponding to the picture to be analyzed includes: identifying frequency identification data in a frequency domain graph corresponding to the picture to be analyzed; determining a matrix area where the lowest frequency data are located according to the frequency identification data; and taking the matrix area as the designated area.
In an embodiment, the step of converting the picture to be analyzed into the corresponding frequency domain map by the processor includes: calling a first function to convert the picture to be analyzed into a digital matrix; calling a second function to scale the picture size of the digital matrix to a preset size; calling a third function to convert the picture of the digital matrix which is scaled to the preset size into a gray image; and calling a fourth function to convert the gray image from a space domain signal to a frequency domain signal to obtain a frequency domain image corresponding to the picture to be analyzed.
In one embodiment, the processor returns the specified picture to the terminal display interface
Figure BDA0002845113900000141
Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2An access state quantity at a time, p (x) representing a frequency concentration of access information; judging whether the appointed terminal exceeds a preset threshold value in a preset time period or not according to the access state quantity; and if so, amplifying the memory occupation ratio of the designated terminal corresponding to the distributed architecture.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium provided herein and used in the examples may include non-volatile and/or volatile memory. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), double-rate SDRAM (SSRSDRAM), Enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and bus dynamic RAM (RDRAM).
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, apparatus, article, or method that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, apparatus, article, or method. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, apparatus, article, or method that includes the element.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are also included in the scope of the present application.

Claims (10)

1. A method for retrieving pictures, comprising:
acquiring a picture to be analyzed;
calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value;
calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library;
judging whether the preset picture library has a designated picture meeting the requirement of the preset similarity or not according to the similarities;
and if so, returning the specified picture to a terminal display interface.
2. The method for retrieving pictures according to claim 1, wherein the step of calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed, and calculating the similarity between the picture to be analyzed and each picture in a preset picture library respectively comprises:
setting field bits with the same number as the characters according to the number of the characters in the character string of the fingerprint information;
filling all characters in the character string into the field positions in sequence in a one-to-one correspondence manner according to the arrangement sequence in the fingerprint information to form fingerprint fields;
comparing the fingerprint field with the difference quantity corresponding to the fingerprint field of each picture in the preset picture library respectively;
and taking each difference quantity as the similarity corresponding to each picture in the picture to be analyzed and each picture in the preset picture library.
3. The method for retrieving pictures according to claim 1, wherein the step of calculating the fingerprint information corresponding to the picture to be analyzed according to a preset mode comprises:
converting the picture to be analyzed into a corresponding frequency domain graph;
intercepting a designated area with the frequency less than a preset frequency in a frequency domain graph corresponding to the picture to be analyzed;
calculating a hash value of the designated area;
and setting the hash value of the designated area as the picture fingerprint corresponding to the picture to be analyzed.
4. The method for retrieving pictures according to claim 3, wherein the designated area is a non-zero area of discrete transform coefficients, and the step of calculating the hash value of the designated area comprises:
calculating an arithmetic mean of a non-zero region of the discrete transform coefficients;
in a non-zero region of the discrete transform coefficient, a flag number that the discrete transform coefficient is greater than or equal to the arithmetic mean is 1, and a flag number that the discrete transform coefficient is less than the arithmetic mean is 0;
and combining all the mark numbers into a digital structure body as the hash value of the designated area.
5. The method for retrieving pictures according to claim 3, wherein the step of intercepting the designated area with a frequency less than a preset frequency in the frequency domain graph corresponding to the picture to be analyzed comprises:
identifying frequency identification data in a frequency domain graph corresponding to the picture to be analyzed;
determining a matrix area where the lowest frequency data are located according to the frequency identification data;
and taking the matrix area as the designated area.
6. The method for retrieving pictures according to claim 3, wherein said step of converting the picture to be analyzed into a corresponding frequency domain map comprises:
calling a first function to convert the picture to be analyzed into a digital matrix;
calling a second function to scale the picture size of the digital matrix to a preset size;
calling a third function to convert the picture of the digital matrix which is scaled to the preset size into a gray image;
and calling a fourth function to convert the gray image from a space domain signal to a frequency domain signal to obtain a frequency domain image corresponding to the picture to be analyzed.
7. The method for retrieving pictures according to claim 1, wherein said step of returning the specified picture to the terminal display interface is followed by:
calculating the access state quantity of the appointed terminal in a preset time period according to an appointed calculation mode, wherein the appointed calculation mode is
Figure FDA0002845113890000021
F (x) represents t1Time to t2Access state quantity at time, xt1Represents t1Access state quantity at time, xt2Represents t2An access state quantity at a time, p (x) representing a frequency concentration of access information;
judging whether the appointed terminal exceeds a preset threshold value in a preset time period or not according to the access state quantity;
and if so, amplifying the memory occupation ratio of the designated terminal corresponding to the distributed architecture.
8. An apparatus for retrieving pictures, comprising:
the acquisition module is used for acquiring a picture to be analyzed;
the first calculation module is used for calculating fingerprint information corresponding to the picture to be analyzed according to a preset mode, wherein the fingerprint information is a hash value;
the calling module is used for calling a preset calculation instruction in a distributed architecture according to the fingerprint information corresponding to the picture to be analyzed and calculating the similarity corresponding to the picture to be analyzed and each picture in a preset picture library;
the first judgment module is used for judging whether the appointed pictures meeting the requirement of the preset similarity exist in the preset picture library or not according to the similarities;
and the returning module is used for returning the appointed picture to the terminal display interface if the appointed picture meeting the preset similarity requirement exists.
9. A computer device comprising a memory and a processor, the memory storing a computer program, wherein the processor implements the steps of the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202011506601.1A 2020-12-18 2020-12-18 Method, device and computer equipment for retrieving pictures Active CN112579812B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011506601.1A CN112579812B (en) 2020-12-18 2020-12-18 Method, device and computer equipment for retrieving pictures

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011506601.1A CN112579812B (en) 2020-12-18 2020-12-18 Method, device and computer equipment for retrieving pictures

Publications (2)

Publication Number Publication Date
CN112579812A true CN112579812A (en) 2021-03-30
CN112579812B CN112579812B (en) 2023-06-20

Family

ID=75136723

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011506601.1A Active CN112579812B (en) 2020-12-18 2020-12-18 Method, device and computer equipment for retrieving pictures

Country Status (1)

Country Link
CN (1) CN112579812B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019061185A1 (en) * 2017-09-28 2019-04-04 深圳传音通讯有限公司 Method and terminal for digitally signing picture
CN110209863A (en) * 2019-06-03 2019-09-06 上海蜜度信息技术有限公司 Method and apparatus for similar pictures retrieval
CN111368122A (en) * 2020-02-14 2020-07-03 深圳壹账通智能科技有限公司 Method and device for removing duplicate pictures
CN111428122A (en) * 2020-03-20 2020-07-17 南京中孚信息技术有限公司 Picture retrieval method and device and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019061185A1 (en) * 2017-09-28 2019-04-04 深圳传音通讯有限公司 Method and terminal for digitally signing picture
CN110209863A (en) * 2019-06-03 2019-09-06 上海蜜度信息技术有限公司 Method and apparatus for similar pictures retrieval
CN111368122A (en) * 2020-02-14 2020-07-03 深圳壹账通智能科技有限公司 Method and device for removing duplicate pictures
CN111428122A (en) * 2020-03-20 2020-07-17 南京中孚信息技术有限公司 Picture retrieval method and device and electronic equipment

Also Published As

Publication number Publication date
CN112579812B (en) 2023-06-20

Similar Documents

Publication Publication Date Title
RU2699687C1 (en) Detecting text fields using neural networks
CN109271418B (en) Suspicious group identification method, device, equipment and computer readable storage medium
CN111401375B (en) Text recognition model training method, text recognition device and text recognition equipment
CN105354307B (en) Image content identification method and device
WO2021143396A1 (en) Method and apparatus for carrying out classification prediction by using text classification model
CN109948149B (en) Text classification method and device
CN107038173B (en) Application query method and device and similar application detection method and device
CN108717512B (en) Malicious code classification method based on convolutional neural network
CN102880726B (en) A kind of image filtering method and system
CN109886330B (en) Text detection method and device, computer readable storage medium and computer equipment
CN113378710A (en) Layout analysis method and device for image file, computer equipment and storage medium
CN111899203B (en) Real image generation method based on label graph under unsupervised training and storage medium
CN113807940B (en) Information processing and fraud recognition method, device, equipment and storage medium
CN114549913A (en) Semantic segmentation method and device, computer equipment and storage medium
CN112070550A (en) Keyword determination method, device and equipment based on search platform and storage medium
CN112183494A (en) Character recognition method and device based on neural network and storage medium
CN113806613B (en) Training image set generation method, training image set generation device, computer equipment and storage medium
CN109086386B (en) Data processing method, device, computer equipment and storage medium
CN112990792A (en) Method and device for automatically detecting infringement risk and electronic equipment
CN113255498A (en) Financial reimbursement invoice management method based on block chain technology
CN112949653A (en) Text recognition method, electronic device and storage device
CN112579812A (en) Method and device for retrieving pictures and computer equipment
CN113076823B (en) Training method of age prediction model, age prediction method and related device
CN116502898A (en) Enterprise risk portrait generation method and device based on neural network
CN116012841A (en) Open set image scene matching method and device based on deep learning

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant