Image background recognition method and device, server and storage medium
By extracting the color distribution and geometric features of facial images, the consistency between the background and foreground is determined, solving the problem of false background recognition and improving the accuracy of facial recognition.
Patent Information
- Application Number
- CN202411363600.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-09-27
AI Technical Summary
Existing technologies struggle to effectively identify false backgrounds in facial images, leading to a decline in facial recognition accuracy.
By using image background recognition methods, the color distribution features and geometric features of the background image and the foreground portrait are extracted to determine the consistency between the background and the foreground. The color distribution features of the image are used to determine the consistency of the image brightness, color changes and light source direction, and the geometric features of the image are used to determine the consistency of the viewing angle, thereby identifying whether the image background is abnormal.
It improves the accuracy of facial recognition, effectively identifying whether the image background is abnormal and preventing false recognition of fake backgrounds.
Smart Images

Figure CN119380386B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image recognition, and in particular to an image background recognition method and device, a server and a storage medium. BACKGROUND
[0002] Face recognition is a biometric technology based on facial feature information for identity recognition, which has many characteristics such as accurate data, high safety factor, and easy use. With the wide application of face recognition and the development of computer vision technology, face recognition technology combined with remote real-time video and intelligent audit is widely used in identity verification and approval work in the financial field.
[0003] The prior art has applied various face recognition technologies to improve the recognition accuracy of face recognition, such as face recognition for user identity verification, key part action recognition, and stranger entering the mirror. However, some abnormal users use false audit backgrounds to improve the credit audit pass rate, and some abnormal users have similar audit backgrounds. At present, there are few recognition technology methods and schemes for abnormal users using false backgrounds, and the potential and unknown false backgrounds in the face image cannot be identified. SUMMARY
[0004] The present application provides an image background recognition method, device, server and storage medium, which is mainly aimed at providing a method for judging whether the background of a face image is an abnormal background when face recognition is performed.
[0005] To achieve the above purpose, the present application provides an image background recognition method, which comprises:
[0006] Obtaining a to-be-recognized image for face recognition, performing background segmentation on the to-be-recognized image to obtain a foreground portrait and a background image;
[0007] Extracting image color distribution features of the background image and image color distribution features of the foreground portrait, judging whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait, and if each preset image attribute of the background image and the foreground portrait is consistent, judging that the image color distribution of the image background of the to-be-recognized image is normal;
[0008] Extracting image geometric features of the background image and image geometric features of the foreground portrait, judging whether the image view angles of the background image and the foreground portrait are consistent based on the image geometric features of the background image and the foreground portrait, and if the image view angles of the background image and the foreground portrait are consistent, judging that the image geometric shape of the image background of the to-be-recognized image is normal;
[0009] If the image color distribution and the image geometry of the image background of the to-be-identified image are normal, it is determined that the image background of the to-be-identified image is a normal background; if one or more preset image attributes of the background image and the foreground portrait are inconsistent, or the image view angles of the background image and the foreground portrait are inconsistent, it is determined whether the background image satisfies a preset condition; if the preset condition is not satisfied, it is determined that the image background of the to-be-identified image is a normal background, and the image background of the to-be-identified image is added to a white background library; if the preset condition is satisfied, it is determined that the image background of the to-be-identified image is an abnormal background, and the image background of the to-be-identified image is added to a black background library.
[0010] Optionally, the method further includes:
[0011] Optionally, the method further includes:
[0012] Optionally, the method further includes:
[0013] Optionally, the method further includes:
[0014] Optionally, the method further includes:
[0015] Optionally, the method further includes:
[0016] Optionally, the method further includes:
[0017] Optionally, the method further includes:
[0018] Optionally, the method further includes:
[0019] Based on the RGB color space of the foreground portrait, first moments, second moments and third moments of each color channel of the foreground portrait are calculated.
[0020] Optionally, the one or more preset image attributes include image brightness, color variation and light source direction, and the judging whether the one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait includes:
[0021] A first moment difference value is calculated based on the value of the first moment of the background image and the value of the first moment of the foreground portrait, if the first moment difference value is less than a second threshold value, it is judged that the image brightness of the background image and the foreground portrait is consistent, if the first moment difference value is greater than or equal to the second threshold value, it is judged that the image brightness of the background image and the foreground portrait is inconsistent.
[0022] A second moment difference value is calculated based on the value of the second moment of the background image and the value of the second moment of the foreground portrait, if the second moment difference value is less than a third threshold value, it is judged that the color variation of the background image and the foreground portrait is consistent, if the second moment difference value is greater than or equal to the third threshold value, it is judged that the color variation of the background image and the foreground portrait is inconsistent.
[0023] The skew direction and skew degree of color distribution in the background image are identified based on the value of the third moment of the background image, the skew direction and skew degree of color distribution in the foreground portrait are identified based on the value of the third moment of the foreground portrait, the skew directions of color distribution in the background image and the foreground portrait are compared, if the skew directions of color distribution in the background image and the foreground portrait are inconsistent, it is judged that the light source direction of the background image and the foreground portrait is inconsistent, if the skew directions of color distribution in the background image and the foreground portrait are consistent, a difference value between the skew degrees of color distribution of the background image and the foreground portrait is calculated, if the difference value between the skew degrees is less than a fourth threshold value, it is judged that the light source direction of the background image and the foreground portrait is consistent, if the difference value between the skew degrees is greater than or equal to the fourth threshold value, it is judged that the light source direction of the background image and the foreground portrait is inconsistent.
[0024] Optionally, the extracting the image geometric features of the background image and the image geometric features of the foreground portrait, and the judging whether the image perspective of the background image and the foreground portrait is consistent based on the image geometric features of the background image and the foreground portrait includes:
[0025] The background feature points are extracted from the background image using a feature point detection algorithm, and the foreground feature points are extracted from the foreground portrait.
[0026] calculate a descriptor of the background feature point and a descriptor of the foreground feature point, perform feature point matching on the background feature point and the foreground feature point and estimate a geometric transformation model between the background image and the foreground portrait using a RANSAC algorithm based on the descriptor of the background feature point and the descriptor of the foreground feature point;
[0027] calculate a consistency measure of the background feature point and the foreground feature point through the geometric transformation model, the consistency measure including a re-projection error and a distance threshold;
[0028] determine whether a value of the consistency measure is less than a preset consistency threshold, if yes, determine that image view angles of the background image and the foreground portrait are consistent, and if no, determine that the image view angles of the background image and the foreground portrait are inconsistent.
[0029] Optionally, the determining whether the background image satisfies the preset condition comprises:
[0030] extracting an abnormal background feature based on an abnormal background of the black background library as the preset condition;
[0031] extracting a background feature of the background image, and determining that the background image satisfies the preset condition if the background feature of the background image is the same as or similar to the abnormal background feature extracted based on the abnormal background of the black background library.
[0032] To solve the above problems, the application further provides an image background recognition device, which comprises:
[0033] an image acquisition module, configured to acquire a to-be-recognized image for face recognition, perform background segmentation on the to-be-recognized image, and obtain a foreground portrait and a background image;
[0034] a color distribution feature comparison module, configured to extract an image color distribution feature of the background image and an image color distribution feature of the foreground portrait, and determine whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait, and determine that an image color distribution of an image background of the to-be-recognized image is normal if each preset image attribute of the background image and the foreground portrait is consistent.
[0035] an image geometric feature comparison module, configured to extract an image geometric feature of the background image and an image geometric feature of the foreground portrait, and determine whether an image view angle of the background image and the foreground portrait is consistent based on the image geometric features of the background image and the foreground portrait, and determine that an image geometric shape of an image background of the to-be-recognized image is normal if the image view angle of the background image and the foreground portrait is consistent.
[0036] The conditional judging module is configured to judge that the image background of the image to be identified is a normal background if the image color distribution and the image geometry of the image background of the image to be identified are both normal, and judge whether the background image meets preset conditions if one or more preset image attributes of the background image and the foreground portrait are inconsistent, or the image perspective of the background image and the foreground portrait is inconsistent; if the background image does not meet the preset conditions, the image background of the image to be identified is judged to be a normal background and added to a white background library; if the background image meets the preset conditions, the image background of the image to be identified is judged to be an abnormal background and added to a black background library.
[0037] To solve the above problems, the present application further provides a server, which comprises:
[0038] at least one processor; and
[0039] a memory connected in communication with the at least one processor; wherein
[0040] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image background identification method as described above.
[0041] To solve the above problems, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the image background identification method as described above.
[0042] The present application judges the consistency of image brightness, color change and light source direction between the foreground portrait and the background image based on the image color distribution characteristics, judges the consistency of image perspective between the foreground portrait and the background image based on the image geometry characteristics, and can effectively identify the consistency of the foreground portrait and the background image. By identifying the consistency of the foreground portrait and the background image in the image to be identified, it can be judged whether the image background of the image to be identified is abnormal, and the background of the face image can be judged to be an abnormal background during face recognition and verification, thereby improving the accuracy of face recognition. BRIEF DESCRIPTION OF DRAWINGS
[0043] Figure 1 a flowchart of an embodiment of the image background identification method of the present application;
[0044] Figure 2 a schematic diagram of an embodiment of the server of the present application;
[0045] Figure 3 a structural schematic diagram of an embodiment of the image background identification device of the present application.
[0046] The implementation, functional features and advantages of the present application will be further described with reference to the accompanying drawings. DETAILED DESCRIPTION
[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the principles and spirits of the present application will be described below with reference to several specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application.
[0048] It should be understood that the specific embodiments described herein are only used to explain the present application and should not be used to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application. In addition, the technical solutions of various embodiments can be combined with each other, but it should be considered that the combination of technical solutions does not exist and is not within the scope of protection required by the present application when the combination of technical solutions is contradictory or unachievable.
[0049] It should be understood that the "multiple" mentioned in the present application refers to two or more. In the description of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent three cases of A alone, A and B together, and B alone. In addition, in order to clearly describe the technical solutions of the present application, the same items or similar items with basically the same function and role are distinguished by using "first", "second" and the like. Those skilled in the art can understand that "first", "second" and the like do not limit the quantity and execution order, and "first", "second" and the like do not necessarily mean different.
[0050] The phrases "one embodiment" or "some embodiments" or the like appearing in the present application mean that the specific features, structures or characteristics described in the embodiment are included in one or more embodiments of the present application. Therefore, the phrases "in one embodiment", "in some embodiments", "in other some embodiments", "in other some embodiments" and the like appearing in the present application do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. In addition, the terms "include", "contain", "have" and their variants mean "include but not limited to", unless otherwise specifically emphasized.
[0051] As Figure 1As shown, it is a flow chart of an embodiment of the image background recognition method of the present application, the image background recognition method is applied to a server, and includes steps S1-S4.
[0052] S1, obtaining a to-be-recognized image for face recognition, performing background segmentation on the to-be-recognized image to obtain a foreground portrait and a background image.
[0053] In an embodiment, obtaining the to-be-recognized image for face recognition includes: obtaining a to-be-recognized face video through a camera, extracting a continuous video frame image containing a face image from the face video, and taking the video frame image with the highest definition as the to-be-recognized image.
[0054] In an embodiment, performing background segmentation on the to-be-recognized image to obtain a foreground portrait and a background image includes: using a frame difference method to calculate a frame difference value of the to-be-recognized image and an adjacent video frame image, extracting an image region with a frame difference value greater than or equal to a first threshold value as the foreground portrait, and separating other image regions as the background image.
[0055] Specifically, the pixel coordinates of the to-be-recognized image are (x, y), and the to-be-recognized image is the t-th frame image in the face video. The frame difference value of the to-be-recognized image and an adjacent video frame image is calculated using the frame difference method, and the formula is as follows:
[0056] D(x, y, t) = |I(x, y, t) - I(x, y, t-1)|
[0057] In the formula, D(x, y, t) is the frame difference value of the to-be-recognized image, I(x, y, t) is the image gray value of the to-be-recognized image, and I(x, y, t-1) is the image gray value of the previous frame image adjacent to the to-be-recognized image.
[0058] In an embodiment, extracting an image region with a frame difference value greater than or equal to a first threshold value as a foreground portrait and separating other image regions as a background image includes: comparing the frame difference value of the to-be-recognized image with a first threshold value, the first threshold value being a predetermined binary threshold value; assigning a value of 1 to an image region in the to-be-recognized image with a frame difference value greater than or equal to the first threshold value, and assigning a value of 0 to an image region in the to-be-recognized image with a frame difference value less than the first threshold value, performing binaryzation on the to-be-recognized image according to the assignment to obtain a binary image corresponding to the to-be-recognized image; and segmenting the to-be-recognized image according to the pixel value of the binary image to obtain a foreground portrait and a background image.
[0059] Specifically, the binaryzation formula of the to-be-recognized image is as follows:
[0060]
[0061] In the formula, B(x, y, t) is the binarization image value of the image to be identified. Assign 1 to the image region in the image to be identified whose frame difference value is greater than or equal to the first threshold value, and assign 0 to the image region in the image to be identified whose frame difference value is less than the first threshold value, and binarize the image to be identified according to the assignment.
[0062] Binarization is to set the gray value of a pixel on an image to 0 or 255, which can simplify a complex gray or color image into an image with only black and white colors, facilitating subsequent processing such as image recognition, segmentation, feature extraction, etc. Binarization is a basic technique in image processing, which converts an image into a binary image, i.e. each pixel in the image has only two possible values, usually 0 (black) and 255 (white). This conversion is achieved by setting a threshold value, all pixel values greater than the threshold value are set to white (255), and those less than the threshold value are set to black (0). Binarization can be regarded as a clustering or classification process, which simplifies the image processing process, improves the processing speed, and facilitates further processing or analysis of the image.
[0063] In this embodiment, the background of the image to be identified is extracted by the frame difference method, which utilizes the difference between consecutive frames of images. By detecting the pixel changes between the image to be identified and the adjacent frame image, the foreground is extracted and the background is separated. Since when the person in the foreground moves, the difference between the person and the background will produce a larger frame difference value, while the frame difference value of the static background is smaller. By setting an appropriate threshold value, the foreground portrait in the image to be identified can be segmented from the background image.
[0064] S2, extract the image color distribution features of the background image and the foreground portrait, and judge whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait. If each preset image attribute of the background image and the foreground portrait is consistent, it is judged that the image color distribution of the image background of the image to be identified is normal.
[0065] In an embodiment, the image color distribution feature is a color distribution moment of the image, and the color distribution moment includes a first moment for representing a mean value, a second moment for representing a variance, and a third moment for representing a skewness.
[0066] Specifically, extracting the image color distribution features of the background image and the foreground portrait includes: calculating the first moment, the second moment and the third moment of each color channel of the background image based on the RGB color space of the background image; and calculating the first moment, the second moment and the third moment of each color channel of the foreground portrait based on the RGB color space of the foreground portrait.
[0067] Specifically, the first moment of each color channel of the background image and the foreground portrait is calculated, and the formula is as follows:
[0068]
[0069]
[0070] In the formula, E i is the first moment of the background image in the i-th color channel, p ij is the color value of the i-th color channel of the j-th pixel of the background image; E i is the first moment of the foreground portrait in the i'-th color channel, p i'j' is the color value of the i'-th color channel of the j'-th pixel of the background image; N represents the number of pixels in the foreground portrait, and i takes the values of 1, 2, and 3 since there are 3 color channels in the RGB color space.
[0071] Specifically, the second moment of each color channel of the background image and the foreground portrait is calculated, and the formula is as follows:
[0072]
[0073]
[0074] In the formula, s i is the second moment of the background image in the i-th color channel, E i is the first moment of the background image in the i-th color channel, p ij is the color value of the i-th color channel of the j-th pixel of the background image; s i is the second moment of the foreground portrait in the i'-th color channel, E i is the first moment of the foreground portrait in the i'-th color channel, p i'j' is the color value of the i'-th color channel of the j'-th pixel of the background image; N represents the number of pixels in the foreground portrait, and i takes the values of 1, 2, and 3 since there are 3 color channels in the RGB color space.
[0075] Specifically, the third moment of each color channel of the background image and the foreground portrait is calculated, and the formula is as follows:
[0076]
[0077]
[0078] In the formula, L i is the third moment of the background image in the i-th color channel, E i is the first moment of the background image in the i-th color channel, p ijis the color value of the i-th color channel of the j-th pixel of the background image; L i is the third order moment of the foreground image in the i-th color channel, E i is the first order moment of the foreground image in the i-th color channel, p i'j' is the color value of the i'-th color channel of the j'-th pixel of the foreground image; N represents the number of pixels in the foreground image, and i takes the values of 1, 2, and 3 since there are 3 color channels in the RGB color space.
[0079] Specifically, the one or more preset image attributes include image brightness, color variation, and light source direction, and the determining whether the one or more preset image attributes of the background image and the foreground image are consistent based on the image color distribution features of the background image and the foreground image includes:
[0080] Based on the value of the first order moment of the background image and the value of the first order moment of the foreground image, a first order moment difference value between the background image and the foreground image is calculated, and if the first order moment difference value is less than a second threshold value, it is determined that the image brightness of the background image and the foreground image is consistent, and if the first order moment difference value is greater than or equal to the second threshold value, it is determined that the image brightness of the background image and the foreground image is inconsistent.
[0081] Based on the value of the second order moment of the background image and the value of the second order moment of the foreground image, a second order moment difference value between the background image and the foreground image is calculated, and if the second order moment difference value is less than a third threshold value, it is determined that the color variation of the background image and the foreground image is consistent, and if the second order moment difference value is greater than or equal to the third threshold value, it is determined that the color variation of the background image and the foreground image is inconsistent.
[0082] Based on the value of the third order moment of the background image, the skew direction and the skew degree of the color distribution in the background image are determined, based on the value of the third order moment of the foreground image, the skew direction and the skew degree of the color distribution in the foreground image are determined, and the skew directions of the color distributions in the background image and the foreground image are compared, and if the skew directions of the color distributions in the background image and the foreground image are inconsistent, it is determined that the light source directions of the background image and the foreground image are inconsistent, and if the skew directions of the color distributions in the background image and the foreground image are consistent, a difference value between the skew degrees of the color distributions in the background image and the foreground image is calculated, and if the difference value is less than a fourth threshold value, it is determined that the light source directions of the background image and the foreground image are consistent, and if the difference value is greater than or equal to the fourth threshold value, it is determined that the light source directions of the background image and the foreground image are inconsistent.
[0083] Color distribution moments are a mathematical tool used to describe the color distribution of an image, which represents the distribution of colors based on their moments. This method was proposed by Stricker and Oreng, and its mathematical basis is that the color distribution of any image can be represented by its moments. Since the color distribution information is mainly concentrated in the low-order moments, the first-order moment, the second-order moment, and the third-order moment are usually used to express the color distribution of the image. These moments define the average intensity of the color (first-order moment, i.e., mean), the non-uniformity of the color distribution (second-order moment, i.e., variance), and the asymmetry of the color (third-order moment, i.e., skewness). The calculation of color moments can be directly performed in the RGB space, and there are 3 low-order moments for each color channel. The first-order color moment, also known as the average color moment, reflects the overall brightness of the image by calculating the average intensity of each color component. The higher the value of the first-order moment, the brighter the image, and vice versa. The second-order color moment, i.e., the variance color moment, reflects the color distribution range of the image by calculating the square root of the second-order central distance (standard deviation). The higher the value of the second-order moment, the wider the color distribution range of the image. The third-order color moment defines the skewness of the color, i.e., the asymmetry of the color, by calculating the third-order central distance of the color. A positive third-order moment indicates a right-skewed color distribution, a negative value indicates a left-skewed color distribution, and a value close to zero indicates a relatively symmetric color distribution.
[0084] S3, extracting image geometric features of the background image and the foreground portrait, judging whether the image perspective of the background image and the foreground portrait is consistent based on the image geometric features of the background image and the foreground portrait, and if the image perspective of the background image and the foreground portrait is consistent, judging that the image geometric shape of the image background of the to-be-identified image is normal.
[0085] In an embodiment, extracting image geometric features of the background image and the foreground portrait, and judging whether the image perspective of the background image and the foreground portrait is consistent based on the image geometric features, comprises:
[0086] extracting background feature points from the background image and extracting foreground feature points from the foreground portrait using a feature point detection algorithm;
[0087] calculating the descriptors of the background feature points and the descriptors of the foreground feature points, and performing feature point matching on the background feature points and the foreground feature points and estimating a geometric transformation model between the background image and the foreground portrait using a RANSAC algorithm based on the descriptors of the background feature points and the descriptors of the foreground feature points;
[0088] calculating a consistency measure of the background feature points and the foreground feature points through the geometric transformation model, wherein the consistency measure comprises a reprojection error and a distance threshold;
[0089] determining whether the value of the consistency measure is less than a preset consistency threshold, if yes, determining that the image view angles of the background image and the foreground portrait image are consistent, if no, determining that the image view angles of the background image and the foreground portrait image are inconsistent.
[0090] In an embodiment, the feature point detection algorithm is a SIFT algorithm. Scale-invariant feature transform (SIFT) is an algorithm of machine vision used to detect and describe local features in images, for finding extreme points in spatial scale, and extracting their positions, scales and rotation-invariant numbers.
[0091] S4, if the image color distribution and the image geometry of the image background of the to-be-identified image are normal, determining that the image background of the to-be-identified image is a normal background, if one or more preset image attributes of the background image and the foreground portrait image are inconsistent, or the image view angles of the background image and the foreground portrait image are inconsistent, determining whether the background image meets a preset condition, if the preset condition is not met, determining that the image background of the to-be-identified image is a normal background and adding the image background of the to-be-identified image to a white background library, if the preset condition is met, determining that the image background of the to-be-identified image is an abnormal background and adding the image background of the to-be-identified image to a black background library.
[0092] In an embodiment, the preset condition is an abnormal background feature extracted based on the abnormal backgrounds of the black background library. The determination of whether the background image meets the preset condition comprises: extracting a background feature of the background image, if the background feature of the background image is the same as or similar to the abnormal background feature extracted based on the abnormal backgrounds of the black background library (the similarity of image background features is a common technical means for those skilled in the art, for example, the distance between two image background features can be calculated by a pre-determined feature vector distance calculation formula, if the distance is greater than a preset threshold, it is determined that the two are not similar, otherwise, they are similar, which will not be described here), it is determined that the background image meets the preset condition.
[0093] In an embodiment, after determining that the image background of the to-be-identified image is a normal background, it further comprises:
[0094] determining that the face recognition audit corresponding to the to-be-identified image is passed.
[0095] In an embodiment, the image background recognition method further comprises:
[0096] comparing the background image of the to-be-processed image with the image backgrounds in the white background library, if the comparison is passed, determining that the image background of the to-be-identified image is a normal background.
[0097] In one embodiment, after determining that the background of the image to be identified is an abnormal background and adding the background of the image to be identified to a black background library, the method further includes:
[0098] If the facial recognition verification of the image to be identified fails, the account that performed the facial recognition will be added to the blacklist.
[0099] In one embodiment, the image background recognition method further includes:
[0100] The background image of the image to be processed is compared with the background images in the black background library. If the comparison is successful, the background of the image to be identified is determined to be an abnormal background.
[0101] As can be seen from the above embodiments, the embodiments of the present invention determine the consistency of image brightness, color changes, and light source direction between the foreground portrait and the background image based on image color distribution features, and determine the consistency of image perspective between the foreground portrait and the background image based on image geometric features, which can effectively identify the consistency between the foreground portrait and the background image. By identifying the consistency between the foreground portrait and the background image in the image to be identified, it is possible to determine whether the background of the image to be identified is abnormal, thereby improving the accuracy of face recognition during face recognition verification.
[0102] like Figure 2 The diagram shown is a schematic representation of an embodiment of the server of the present invention. Server 1 is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Server 1 can be a single network server, a server group composed of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers. Cloud computing is a type of distributed computing, consisting of a super virtual computer composed of a group of loosely coupled computers.
[0103] In this embodiment, server 1 includes, but is not limited to, a memory 11, a processor 12, and a network interface 13 that can be interconnected via a system bus. The memory 11 stores an image background recognition program 10, which can be executed by the processor 12. Figure 2 Only server 1, which includes components 11-13 and image background recognition program 10, is shown. Those skilled in the art will understand that... Figure 2 The structure shown does not constitute a limitation on server 1 and may include fewer or more components than shown, or combine certain components, or have different component arrangements.
[0104] The memory 11 includes an internal memory and at least one type of readable storage medium. The internal memory provides a cache for the operation of the server 1; the readable storage medium can be volatile or non-volatile. Specifically, the readable storage medium can be a storage medium such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, etc. In some embodiments, the readable storage medium can be an internal storage unit of the server 1, such as a hard disk of the server 1; in other embodiments, the storage medium can also be an external storage device of the server 1, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the server 1. In this embodiment, the readable storage medium of the memory 11 mainly includes a program storage area and a data storage area, wherein the program storage area is usually used to store an operating system and various application software installed on the server 1, such as the code of the image background recognition program 10 in an embodiment of the present application, etc.; the data storage area can store data created according to the use of the blockchain node, such as various data that has been output or will be output.
[0105] The processor 12 in some embodiments can be composed of integrated circuits, such as a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same function or different functions, including one or more combinations of central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips, etc. The processor 12 is the control unit of the electronic device, which connects various components of the entire electronic device through various interfaces and lines, executes or runs programs or modules stored in the memory 11 (such as executing a resource dynamic scheduling program, etc.), and calls data stored in the memory 11, to execute various functions of the electronic device and process data. The processor 12 is usually used to control the overall operation of the server 1, such as performing control and processing related to data interaction or communication with other devices, etc. In this embodiment, the processor 12 is used to run program codes or process data stored in the memory 11, such as running the image background recognition program 10, etc.
[0106] The network interface 13 can include a wireless network interface or a wired network interface.
[0107] Optionally, the server 1 can also include a user interface, which can include a display, an input unit such as a keyboard, and optionally a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, an organic light-emitting diode (OLED) touch, etc. Among them, the display can also be appropriately called a display screen or a display unit, which is used to display the information processed in the server 1 and to display the visualized user interface.
[0108] In an embodiment of the present application, the image background recognition program 10 is implemented when the processor 12 is executed, and the image background recognition method comprises steps S1-S4:
[0109] S1, obtaining a to-be-recognized image for face recognition, performing background segmentation on the to-be-recognized image to obtain a foreground portrait and a background image;
[0110] S2, extracting image color distribution features of the background image and image color distribution features of the foreground portrait, judging whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait, if each preset image attribute of the background image and the foreground portrait is consistent, then judging that the image color distribution of the image background of the to-be-recognized image is normal;
[0111] S3, extracting image geometric features of the background image and image geometric features of the foreground portrait, judging whether the image view angles of the background image and the foreground portrait are consistent based on the image geometric features of the background image and the foreground portrait, if the image view angles of the background image and the foreground portrait are consistent, then judging that the image geometric shape of the image background of the to-be-recognized image is normal;
[0112] S4, if the image color distribution and the image geometric shape of the image background of the to-be-recognized image are both normal, then judging that the image background of the to-be-recognized image is a normal background, if one or more preset image attributes of the background image and the foreground portrait are inconsistent, or the image view angles of the background image and the foreground portrait are inconsistent, then judging whether the background image satisfies a preset condition, if the preset condition is not satisfied, then judging that the image background of the to-be-recognized image is a normal background and adding the image background of the to-be-recognized image to a white background library, if the preset condition is satisfied, then judging that the image background of the to-be-recognized image is an abnormal background and adding the image background of the to-be-recognized image to a black background library.
[0113] The specific operation steps realized by the above steps S1-S4 are substantially the same as steps S1-S4 of the embodiment of the image background recognition method of the present application, and will not be described here again.
[0114] In other embodiments, the image background recognition program 10 can also be divided into one or more modules, which are stored in the memory 11 and executed by one or more processors (the processor 12 in the embodiment) to complete the present application. The module referred to in the present application refers to a series of computer program instruction segments capable of completing a specific function, and is used to describe the execution process of the image background recognition program 10 in the server 1.
[0115] As shown in FIG. 1, it is a structural schematic diagram of the image background recognition device provided by an embodiment of the present application. Figure 3
[0116] In the first embodiment of the present application, the image background recognition device 100 includes an image acquisition module 110, a color distribution feature comparison module 120, an image geometric feature comparison module 130, and a condition judgment module 140, which are exemplarily described as follows.
[0117] The image acquisition module 110 is configured to acquire a to-be-recognized image for face recognition, perform background segmentation on the to-be-recognized image, and obtain a foreground portrait and a background image.
[0118] The color distribution feature comparison module 120 is configured to extract image color distribution features of the background image and the foreground portrait, judge whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait, and if each preset image attribute of the background image and the foreground portrait is consistent, judge that the image color distribution of the image background of the to-be-recognized image is normal.
[0119] The image geometric feature comparison module 130 is configured to extract image geometric features of the background image and the foreground portrait, judge whether the image view angles of the background image and the foreground portrait are consistent based on the image geometric features of the background image and the foreground portrait, and if the image view angles of the background image and the foreground portrait are consistent, judge that the image geometric shape of the image background of the to-be-recognized image is normal.
[0120] The condition judging module 140 is configured to: if the image color distribution and the image geometry of the image background of the to-be-identified image are normal, judging that the image background of the to-be-identified image is a normal background; if one or more preset image attributes of the background image and the foreground portrait are inconsistent, or the image view angle of the background image and the foreground portrait is inconsistent, judging whether the background image meets a preset condition; if the background image does not meet the preset condition, judging that the image background of the to-be-identified image is a normal background and adding the image background of the to-be-identified image to a white background library; and if the background image meets the preset condition, judging that the image background of the to-be-identified image is an abnormal background and adding the image background of the to-be-identified image to a black background library.
[0121] The image obtaining module 110, the color distribution feature comparing module 120, the image geometry feature comparing module 130 and the condition judging module 140 are configured to perform the same specific operation steps as those of the above-mentioned embodiments, and thus details are not repeated here.
[0122] In addition, the embodiment of the present application further provides a computer readable storage medium. The computer readable storage medium can be volatile or non-volatile. Specifically, the computer readable storage medium can be any one or any combination of a hard disk, a multimedia card, an SD card, a flash memory card, an SMC, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disc read-only memory (CD-ROM), a USB memory, etc. The image background identification program is stored in the computer readable storage medium.
[0123] The specific software function implementation of the computer readable storage medium of the present application is substantially the same as that of the above-mentioned server 1, and thus details are not repeated here.
[0124] The serial numbers of the above-mentioned embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.
[0125] It should be noted that, in this document, the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusions, so that a process, device, article or method including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, device, article or method. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, device, article or method including the element.
[0126] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and the necessary general hardware platform, of course, also can be through hardware, but in many cases the former is the better embodiment. Based on such understanding, the technical solutions of the present application essentially or say the part which contributes to the prior art can be embodied in the form of software product, the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disc, optical disc), including a plurality of instructions to make a terminal device (may be a mobile phone, computer, server, air conditioner, or network equipment, etc.) executes the method described in various embodiments of the present application.
[0127] It should be noted that, if the software tools or components of the company appear in the embodiments of the present application, only for example, and does not represent the actual use.
[0128] The above is only the preferred embodiment of the present application, and does not limit the patent scope of the present application, any equivalent structure or equivalent flow transformation made by using the content of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. An image background recognition method, characterized by, The method comprises: acquiring a to-be-recognized image for face recognition, performing background segmentation on the to-be-recognized image to obtain a foreground portrait and a background image; extracting image color distribution features of the background image and image color distribution features of the foreground portrait, and judging whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait, if each preset image attribute of the background image and the foreground portrait is consistent, then judging that the image color distribution of the image background of the to-be-recognized image is normal; extracting image geometric features of the background image and image geometric features of the foreground portrait, and judging whether the image view angles of the background image and the foreground portrait are consistent based on the image geometric features of the background image and the foreground portrait, if the image view angles of the background image and the foreground portrait are consistent, then judging that the image geometric shape of the image background of the to-be-recognized image is normal; if the image color distribution and the image geometric shape of the image background of the to-be-recognized image are both normal, then judging that the image background of the to-be-recognized image is a normal background, if one or more preset image attributes of the background image and the foreground portrait are inconsistent, or the image view angles of the background image and the foreground portrait are inconsistent, then judging whether the background image meets a preset condition, if the preset condition is not met, then judging that the image background of the to-be-recognized image is a normal background and adding the image background of the to-be-recognized image to a white background library, if the preset condition is met, then judging that the image background of the to-be-recognized image is an abnormal background and adding the image background of the to-be-recognized image to a black background library.
2. The image background recognition method of claim 1, wherein, The method comprises: acquiring a to-be-recognized image for face recognition, performing background segmentation on the to-be-recognized image to obtain a foreground portrait and a background image, comprising: acquiring a to-be-recognized face video through a camera, extracting continuous video frame images containing face images from the face video, and taking the video frame image with the highest clarity as the to-be-recognized image; 3. The image background recognition method of claim 2, wherein, calculating frame difference values of the to-be-recognized image and adjacent video frame images using a frame difference method, extracting image regions with frame difference values greater than or equal to a first threshold value as the foreground portrait, and separating other image regions as the background image. The method comprises: comparing the frame difference values of the to-be-recognized image with the first threshold value, the first threshold value being a pre-determined binary threshold value; assigning image regions with frame difference values greater than or equal to the first threshold value in the to-be-recognized image as 1, and assigning image regions with frame difference values less than the first threshold value in the to-be-recognized image as 0, performing binaryzation on the to-be-recognized image according to the assignment to obtain a binaryzation image corresponding to the to-be-recognized image; 4. The image background recognition method of claim 1, wherein, segmenting the to-be-recognized image according to the pixel values of the binaryzation image to obtain the foreground portrait and the background image. The method comprises: calculating first, second and third moments of each color channel of the background image based on an RGB color space of the background image; calculating first, second and third moments of each color channel of the foreground portrait based on an RGB color space of the foreground portrait.
5. The image background recognition method of claim 1, wherein, The one or more preset image attributes include image brightness, color variation and light source direction, and the determining whether the one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait comprises: calculating a first moment difference value based on the first moment value of the background image and the first moment value of the foreground portrait, and if the first moment difference value is less than a second threshold value, determining that the image brightness of the background image and the foreground portrait is consistent, and if the first moment difference value is greater than or equal to the second threshold value, determining that the image brightness of the background image and the foreground portrait is inconsistent; calculating a second moment difference value based on the second moment value of the background image and the second moment value of the foreground portrait, and if the second moment difference value is less than a third threshold value, determining that the color variation of the background image and the foreground portrait is consistent, and if the second moment difference value is greater than or equal to the third threshold value, determining that the color variation of the background image and the foreground portrait is inconsistent; identifying the skew direction and skew degree of color distribution in the background image based on the third moment value of the background image, identifying the skew direction and skew degree of color distribution in the foreground portrait based on the third moment value of the foreground portrait, comparing the skew directions of color distribution in the background image and the foreground portrait, and if the skew directions of color distribution in the background image and the foreground portrait are inconsistent, determining that the light source directions of the background image and the foreground portrait are inconsistent, and if the skew directions of color distribution in the background image and the foreground portrait are consistent, calculating a difference value between the skew degrees of color distribution of the background image and the foreground portrait, and if the difference value between the skew degrees is less than a fourth threshold value, determining that the light source directions of the background image and the foreground portrait are consistent, and if the difference value between the skew degrees is greater than or equal to the fourth threshold value, determining that the light source directions of the background image and the foreground portrait are inconsistent.
6. The image background recognition method of claim 1, wherein, The extracting the image geometric features of the background image and the image geometric features of the foreground portrait, and the determining whether the image perspectives of the background image and the foreground portrait are consistent based on the image geometric features of the background image and the foreground portrait comprises: extracting background feature points from the background image and extracting foreground feature points from the foreground portrait using a feature point detection algorithm; calculating the descriptors of the background feature points and the descriptors of the foreground feature points, and performing feature point matching on the background feature points and the foreground feature points and estimating a geometric transformation model between the background image and the foreground portrait using a RANSAC algorithm based on the descriptors of the background feature points and the descriptors of the foreground feature points; calculating a consistency measure of the background feature points and the foreground feature points through the geometric transformation model, and the consistency measure comprises a reprojection error and a distance threshold value; determining whether the value of the consistency measure is less than a preset consistency threshold, if yes, determining that the image view angles of the background image and the foreground portrait are consistent, and if no, determining that the image view angles of the background image and the foreground portrait are inconsistent.
7. The image background recognition method of claim 1, wherein, The determining whether the background image satisfies the preset condition comprises: extracting an abnormal background feature based on the abnormal background of the black background library as the preset condition; extracting a background feature of the background image, and if the background feature of the background image is the same as or similar to the abnormal background feature extracted based on the abnormal background of the black background library, determining that the background image satisfies the preset condition.
8. An image background recognition apparatus characterized by comprising: The image background recognition device comprises: an image acquisition module configured to acquire a to-be-recognized image for face recognition, perform background segmentation on the to-be-recognized image, and obtain a foreground portrait and a background image; a color distribution feature comparison module configured to extract an image color distribution feature of the background image and an image color distribution feature of the foreground portrait, and determine whether one or more preset image attributes of the background image and the foreground portrait are consistent based on the image color distribution features of the background image and the foreground portrait, if the preset image attributes of the background image and the foreground portrait are consistent, determining that the image color distribution of the image background of the to-be-recognized image is normal; an image geometric feature comparison module configured to extract an image geometric feature of the background image and an image geometric feature of the foreground portrait, and determine whether the image view angles of the background image and the foreground portrait are consistent based on the image geometric features of the background image and the foreground portrait, if the image view angles of the background image and the foreground portrait are consistent, determining that the image geometric shape of the image background of the to-be-recognized image is normal; a condition determination module configured to, if the image color distribution and the image geometric shape of the image background of the to-be-recognized image are both normal, determine that the image background of the to-be-recognized image is a normal background, if one or more preset image attributes of the background image and the foreground portrait are inconsistent, or the image view angles of the background image and the foreground portrait are inconsistent, determine whether the background image satisfies a preset condition, if the background image does not satisfy the preset condition, determine that the image background of the to-be-recognized image is a normal background and add the image background of the to-be-recognized image to a white background library, and if the background image satisfies the preset condition, determine that the image background of the to-be-recognized image is an abnormal background and add the image background of the to-be-recognized image to a black background library.
9. A server, characterized by The server comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image background recognition method of any one of claims 1 to 7.
10. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the image background recognition method of any one of claims 1 to 7.
Citation Information
Patent Citations
Abnormal panel detection algorithm based on ATM (Automatic Teller Machine) scene
CN103400382A
Face recognition method, device and terminal
CN109325413A