A fast ID photo glasses detection method based on image processing
Through image processing technology, including image enhancement, slicing processing and support vector machines, it solves the problem that traditional algorithms cannot identify glasses in ID photos, achieves fast, real-time and high-accuracy glasses recognition, reduces computing resource requirements, and is suitable for Various types of glasses identification.
Patent Information
- Application Number
- CN202210094313.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-26
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-01-26
AI Technical Summary
Traditional computer vision algorithms cannot correctly identify various types of glasses. Deep learning methods rely on a large amount of computing resources, resulting in long running times, and cannot achieve a balance between the accuracy and recall rate of effectively identifying glasses in ID photos.
Using a fast ID glasses detection method based on image processing, through a combination of image enhancement, slicing processing, Gaussian smoothing, non-maximum suppression and support vector machines, the characteristics of glasses are gradually located and strengthened, reducing computing resource requirements and improving recognition accuracy. and recall rate.
It achieves fast, real-time and high-accuracy glasses identification, reduces the demand for computing resources, meets the needs of intranet security, and is suitable for the identification of rimless glasses.
Smart Images

Figure CN114463814B
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of image recognition, and in particular to a method for rapid ID photo glasses detection based on image processing. Background Art
[0002] ID photos are photos used to prove identity in various scenarios for various certificates. The requirements for ID photos are different. Some ID photos do not allow applicants to wear glasses. Manual screening not only requires a lot of manpower, but also slows down the process time. Therefore, computers are needed to intelligently determine whether the person in the ID photo is wearing glasses. Traditional computer vision algorithms cannot correctly identify a wide variety of glasses, and the end-to-end recognition method of spontaneous network training absorbs a large number of redundant features due to the lack of prior knowledge, and cannot achieve a good balance between performance and correctness. For example, directly using support vector machines to learn faces wearing glasses, due to the complexity of the face itself, the interaction between the shape and thickness of the glasses frame, and the lack of significant directional gradient histogram features for support vector machine recognition of frameless glasses, these factors make it impossible to achieve a good balance between recognition accuracy and recall rate; and deep learning calculation methods rely on a large amount of computing resources, resulting in too long algorithm running time. Summary of the invention
[0003] The object of the present invention is to provide a method for rapid ID photo glasses detection based on image processing to solve the problems raised in the above background technology.
[0004] In order to solve the above technical problems, the present invention provides the following technical solutions: a method for rapid ID photo glasses detection based on image processing, the specific steps of the glasses detection method include:
[0005] Step 1: Obtain a photo of your ID card by using a camera or a video camera or a data collection system;
[0006] Step 2: Image processing, image enhancement of the ID photo;
[0007] Step 3: Continue to slice the ID photo to obtain slices of the area where the glasses may be located;
[0008] Step 4: Perform Gaussian smoothing on the area where glasses may exist;
[0009] Step 5: Output edge strength matrix based on non-maximum suppression;
[0010] Step 6: further slice and reorganize the possible glasses area based on the updated edge strength matrix;
[0011] Step 7: Input the possible area of reconstructed glasses into the glasses support vector machine and output the final result.
[0012] The present invention does not rely on deep learning algorithms for glasses recognition. It continuously enhances the features of glasses that may exist in ID photos through image processing, and locates the possible positions of the frames step by step through continuous slicing, thereby greatly improving the accuracy of the final support vector machine in recognizing glasses. The present invention is not only fast and can meet real-time requirements, but also has an extremely high accuracy and low recall rate, which greatly reduces the demand for computing resources and can meet the needs of intranet security.
[0013] The image enhancement of the ID photo in step 2 includes histogram equalization and highlight correction;
[0014] Enhance the contrast of ID photos, suppress the noise of ID photos in the spatial domain, highlight the boundary between the frame and the face, reduce the impact of light on the image, and perform highlight correction to eliminate high-brightness singular areas in the image;
[0015] The specific content of the histogram equalization is: converting the RGB three channels of the ID photo into HSV channels, performing histogram equalization on the brightness V channel based on the cumulative distribution function, and converting the histogram-equalized HSV channel back into RGB image output;
[0016] Directly performing histogram equalization on the ID photo based on the RGB channels will lead to singular points. The RGB channels of the ID photo are converted into HSV channels. After mapping, the grayscale is 0 to 255, and the grayscale is expanded. The grayscale value is redistributed based on the cumulative distribution function and then converted into RGB image output.
[0017] The specific steps of histogram equalization include:
[0018] Step 1.1: The specific formula for calculating the maximum and minimum values of RGB three-channel pixels is:
[0019] A=max(r,g,b)
[0020] I = min(r, g, b)
[0021] Among them, r, g, and b represent the values of the three channels of RGB in the ID photo, A represents the maximum value among r, g, and b, and I represents the minimum value among r, g, and b;
[0022] Step 1.2: Convert the three RGB channels of the ID photo into HSV channels. The specific calculation formula is:
[0023]
[0024]
[0025] V=A
[0026] Among them, H represents the hue in the HSV channel, S represents the saturation in the HSV channel, and V represents the brightness in the HSV channel;
[0027] Step 1.3: The specific formula for histogram equalization of the brightness channel is:
[0028]
[0029] Among them, V hist represents the new brightness channel after histogram equalization, cdf(V) represents the cumulative distribution function of the original brightness channel, with a domain of [0, 255] and a range of [cdf(V) min, cdf(V) max ].
[0030] Step 1.4: H, S and V hist Reconvert to RGB three-channel output ID photo.
[0031] The specific content of the highlight correction is: perform highlight correction based on a highlight suppression algorithm based on bilateral filtering, establish a two-color reflection model to obtain the conversion relationship between the specular reflection component and the maximum diffuse reflection chromaticity, set a threshold to separate pixels containing only diffuse reflection components from pixels containing specular reflection components, estimate the maximum diffuse reflection chromaticity of pixels containing only diffuse reflection components and pixels containing specular reflection components, use the similarity of the estimated maximum diffuse reflection chromaticity as the value range of the bilateral filter, and use the maximum chromaticity map of the image as a guide map for bilateral filtering to preserve edge denoising and remove the specular reflection component, thereby performing highlight correction.
[0032] The specific steps of step three include:
[0033] Step 2.1: Recognize the face in the image through the directional gradient histogram feature extractor and the linear support vector machine, and output the face area slice;
[0034] Step 2.2: Identify the facial features in the face region slices using the directional gradient histogram feature extractor and the linear support vector machine to obtain the coordinates of the iris center area of the left and right eyes;
[0035] Step 2.3: Get the slice of the area where the glasses may exist, rotate the image until the line connecting the left and right eye iris center coordinates is horizontal, and scale the image until the length of the line segment connecting the left and right eye iris center coordinates is d pixels; crop d pixels above the left eye iris center coordinate, d pixels below the left eye iris center coordinate, and d pixels to the left of the left eye iris center coordinate Pixels, left eye iris center coordinates right Pixels, the glasses that finally output 2d*2d pixels may have regional slices.
[0036] Continuous slicing gradually approaches the range of the glasses. On the one hand, it reduces the interference of irrelevant information and improves the accuracy of the support vector machine. On the other hand, it greatly reduces the amount of data and avoids data redundancy.
[0037] The specific steps of Step 2.1 include:
[0038] Step 2.1.a: Grayscale the ID photo to reduce the computing resources occupied by the image in subsequent calculations, enhance visual contrast, and highlight the target features. The specific calculation formula is:
[0039] gray=0.299r+0.587g+0.114b
[0040] Among them, gray represents the gray value of the ID photo, r, g, b represent the values of the RGB channels of the ID photo;
[0041] Step 2.1.b: Calculate the gradient value and gradient direction of each pixel. The specific calculation formula is:
[0042]
[0043] Among them, g(x, y) represents the gradient value of the pixel with coordinates (x, y), g x Represents the horizontal gradient, g y Represents the vertical gradient;
[0044] Step 2.1.c: Calculate the gradient direction. The specific calculation formula is:
[0045]
[0046] Among them, θ(x, y) represents the gradient direction of the pixel with coordinates (x, y);
[0047] Step 2.1.d: Calculate the gradient histogram vector. The specific calculation formula is:
[0048] HOG(i)=∑g(x,y), (i*20≤θ(x,y)<(i+1)*20)
[0049] The value range of i is {0, 1, 2, 3, 4, 5, 6, 7, 8}. The image is divided into 8*8 units, and the directional gradient histogram feature vector is calculated according to the angle group of each unit;
[0050] Step 2.1.e: Normalize the directional gradient histogram. Take 2*2 units as a block. The directional gradient histogram feature vector of the block is a 36-dimensional vector composed of the directional gradient histogram feature vectors of 4 units. Calculate the normalized value of the directional gradient histogram feature vector of the block. The specific calculation formula is:
[0051]
[0052] Where k represents the dimension of the vector, and HOG′(k) represents the directional gradient histogram feature vector of the block;
[0053] Step 2.1.f: Input the directional gradient histogram feature vector of the block into the face support vector machine for classification and output the face area;
[0054] The directional gradient histogram feature vector of the block is a 36-dimensional vector. The directional gradient histogram feature vector of each block can be considered as a point in the 36-dimensional space. The face support vector machine is obtained in advance through the labeled face area. The face support vector machine is a set of 36-dimensional hyperplanes that can frame the points that are considered to be faces. In the two-dimensional space, the face support vector machine frames the area where the face is located through a set of straight lines, and finally outputs the face slice.
[0055] The specific contents of step 4 of performing Gaussian smoothing on the area where the glasses may be present include:
[0056] For each point (x, y) in the area where the glasses may exist, the specific calculation formula for the weights of other points (x±u, y±v) with respect to the point (x, y) is:
[0057]
[0058] Where u represents the distance between other points (x±u, y±v) and point (x, y) along the X-axis, v represents the distance between other points (x±u, y±v) and point (x, y) along the Y-axis, and G(u, v) represents the weight of other points (x±u, y±v) with respect to point (x, y);
[0059] Perform Gaussian smoothing on each point in the area where the glasses may exist. The specific calculation formula is:
[0060]
[0061] Among them, pixel (x±u, y±v) represents the pixel value of other points (x±u, y±v), c represents the length of the area where the glasses may exist, w represents the width of the area where the glasses may exist, and pixel′(x, y) represents the pixel value of the point (x, y) after Gaussian smoothing. Gaussian smoothing is performed on the area where the glasses may exist to filter out the small noise in the area where the glasses may exist, so as to further obtain the edge intensity matrix and prevent false detection caused by noise.
[0062] The image edge after gradient calculation is blurred. The edge strength matrix is calculated by non-maximum suppression to further enhance the edge. At the same time, all gradient values outside the local maximum value are suppressed to 0, and the edge strength matrix is further updated to enhance the edge to the greatest extent.
[0063] The specific contents of the step 5 based on non-maximum suppression output edge strength matrix include:
[0064] Step 3.1: Calculate the first-order derivative matrix gray' along the Y-axis direction in each area where the glasses may exist;
[0065] Step 3.2: Output the edge strength matrix g(x, y) obtained by non-maximum suppression. The specific calculation formula is:
[0066]
[0067] Step 3.3: Determine the number of zero elements in the eight pixels adjacent to each pixel of g(x, y) and output the zero-degree matrix e(x, y). The specific calculation formula is:
[0068]
[0069] Step 3.4: Calculate the zero-degree matrix E and perform the maximum pooling update edge strength matrix with a step of 1 containing upper and lower thresholds Q and H. The specific calculation formula is:
[0070]
[0071] Wherein, g(x, y)′ represents the updated edge strength matrix.
[0072] The specific contents of the possible areas of the glasses in step 6 include:
[0073] The bridge of the nose and the area under the eyes are cropped from the edge intensity matrix to obtain possible area slices for reconstructing the glasses: Based on the edge intensity matrix and the slices of the ID photo in the above steps, the bridge of the nose and the frame under the glasses are further located to emphasize the features of the bridge of the nose and the frame under the glasses.
[0074] The bridge of the nose area is composed of a rectangle defined by points (x1, y1) and (x2, y2). The specific calculation formula is:
[0075]
[0076] The area below the eyes is represented by the point (x 11 ,y 11 ) and point (x 12 ,y 12 ) and the rectangle defined by the point (x 21 ,y21 ) and point (x 22 ,y 22 ) is formed by stitching the rectangles determined by the equation. The specific calculation formula is:
[0077]
[0078] The specific contents of step seven for judging whether there is a glasses frame include: extracting directional gradient histogram features from the matrix of the possible area of the reorganized glasses, inputting the features into the glasses support vector machine for detection, setting an upper limit threshold value B, and when the return value of the glasses support vector machine is greater than the threshold value B, judging that the face in the photo is wearing glasses; when the return value of the glasses support vector machine is less than the threshold value B, judging that the face in the photo is not wearing glasses, and outputting the final result according to the judgment result.
[0079] The specific contents of step seven for judging whether there is a glasses frame also include: extracting directional gradient histogram features from the matrix of the possible area of the reorganized glasses, inputting the features into the glasses support vector machine for detection, setting an upper threshold value B and a lower threshold value S, and when the return value of the glasses support vector machine is greater than the threshold value B, judging that the face in the photo is wearing glasses; when the return value of the glasses support vector machine is less than the threshold value S, judging that the face in the photo is not wearing glasses, establishing a glass detection model based on the glass detection network GDNet, and when the return value of the glasses support vector machine is less than B and greater than S, inputting the ID photo into the glass detection model, and if glass is detected, judging that the face in the photo is wearing glasses; if glass is not detected, judging that the face in the photo is not wearing glasses, and outputting the final result according to the judgment result.
[0080] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0081] 1. The present invention does not rely on deep learning algorithms for glasses recognition. It continuously enhances the features of glasses that may exist in the ID photo through image processing, and locates the possible positions of the frames step by step with continuous slicing, which greatly improves the accuracy of glasses recognition by the final support vector machine;
[0082] 2. The present invention cooperates with image processing to slice step by step, emphasizing the features of possible glasses frames. The present invention also has a high accuracy rate for rimless glasses recognition;
[0083] 3. The present invention is not only fast and can meet the real-time requirements, but also has a very high accuracy and a low recall rate, which greatly reduces the demand for computing resources and can meet the security requirements of the intranet. BRIEF DESCRIPTION OF THE DRAWINGS
[0084] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0085] Figure 1 The present invention is a flowchart of a method for rapid ID photo glasses detection based on image processing. DETAILED DESCRIPTION
[0086] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0087] See also Figure 1 , the present invention provides a technical solution:
[0088] Embodiment 1: A method for rapid ID photo glasses detection based on image processing, the specific steps of the glasses detection method include:
[0089] Step 1: Obtain a photo of your ID card by using a camera or a video camera or a data collection system;
[0090] Step 2: Image processing, image enhancement of the ID photo;
[0091] Step 3: Continue to slice the ID photo to obtain slices of the area where the glasses may be located;
[0092] Step 4: Perform Gaussian smoothing on the area where glasses may exist;
[0093] Step 5: Output edge strength matrix based on non-maximum suppression;
[0094] Step 6: further slice and reorganize the possible glasses area based on the updated edge strength matrix;
[0095] Step 7: Input the possible area of reconstructed glasses into the glasses support vector machine and output the final result.
[0096] The present invention does not rely on deep learning algorithms for glasses recognition. It continuously enhances the features of glasses that may exist in ID photos through image processing, and locates the possible positions of the frames step by step through continuous slicing, thereby greatly improving the accuracy of the final support vector machine in recognizing glasses. The present invention is not only fast and can meet real-time requirements, but also has an extremely high accuracy and low recall rate, which greatly reduces the demand for computing resources and can meet the needs of intranet security.
[0097] In step 2, the ID photo is enhanced by histogram equalization and highlight correction.
[0098] Enhance the contrast of ID photos, suppress the noise of ID photos in the spatial domain, highlight the boundary between the frame and the face, reduce the impact of light on the image, and perform highlight correction to eliminate high-brightness singular areas in the image;
[0099] The specific content of histogram equalization is: convert the RGB three channels of the ID photo into HSV channels, perform histogram equalization on the brightness V channel based on the cumulative distribution function, and convert the histogram-equalized HSV channel back into RGB image output;
[0100] Directly performing histogram equalization on the ID photo based on the RGB channels will lead to singular points. The RGB channels of the ID photo are converted into HSV channels. After mapping, the grayscale is 0 to 255, and the grayscale is expanded. The grayscale value is redistributed based on the cumulative distribution function and then converted into RGB image output.
[0101] The specific steps of histogram equalization include:
[0102] Step 1.1: The specific formula for calculating the maximum and minimum values of RGB three-channel pixels is:
[0103] A=max(r,g,b)
[0104] I = min(r, g, b)
[0105] Among them, r, g, and b represent the values of the three channels of RGB in the ID photo, A represents the maximum value among r, g, and b, and I represents the minimum value among r, g, and b;
[0106] Step 1.2: Convert the three RGB channels of the ID photo into HSV channels. The specific calculation formula is:
[0107]
[0108]
[0109] V=A
[0110] Among them, H represents the hue in the HSV channel, S represents the saturation in the HSV channel, and V represents the brightness in the HSV channel;
[0111] Step 1.3: The specific formula for histogram equalization of the brightness channel is:
[0112]
[0113] Among them, V hist represents the new brightness channel after histogram equalization, cdf(V) represents the cumulative distribution function of the original brightness channel, with a domain of [0, 255] and a range of [cdf(V) min,cdf(V) max ].
[0114] Step 1.4: H, S and V hist Reconvert to RGB three-channel output ID photo.
[0115] The specific content of highlight correction is: highlight correction is performed based on the highlight suppression algorithm of bilateral filtering, a two-color reflection model is established to obtain the conversion relationship between the specular reflection component and the maximum diffuse reflection chromaticity, a threshold is set to separate pixels containing only diffuse reflection components and pixels containing specular reflection components, and the maximum diffuse reflection chromaticity of pixels containing only diffuse reflection components and pixels containing specular reflection components is estimated. The similarity of the estimated maximum diffuse reflection chromaticity is used as the value range of the bilateral filter. At the same time, the maximum chromaticity map of the image is used as the guiding map of bilateral filtering for edge-preserving denoising and removing the specular reflection component, thereby performing highlight correction.
[0116] The specific steps of step three include:
[0117] Step 2.1: Recognize the face in the image through the directional gradient histogram feature extractor and the linear support vector machine, and output the face area slice;
[0118] Step 2.2: Identify the facial features in the face region slices using the directional gradient histogram feature extractor and the linear support vector machine to obtain the coordinates of the iris center area of the left and right eyes;
[0119] Step 2.3: Get the slice of the area where the glasses may exist, rotate the image until the line connecting the center coordinates of the left and right irises is horizontal, and scale the image until the length of the line segment of the center coordinates of the left and right irises is 128 pixels; crop 128 pixels above the center coordinate of the left eye iris, 128 pixels below the center coordinate of the left eye, 64 pixels to the left of the center coordinate of the left eye, and 192 pixels to the right of the center coordinate of the left eye, and finally output a 256*256 pixel slice of the area where the glasses may exist.
[0120] Continuous slicing gradually approaches the range of the glasses. On the one hand, it reduces the interference of irrelevant information and improves the accuracy of the support vector machine. On the other hand, it greatly reduces the amount of data and avoids data redundancy.
[0121] Step 2.1 The specific steps include:
[0122] Step 2.1.a: Grayscale the ID photo to reduce the computing resources occupied by the image in subsequent calculations, enhance visual contrast, and highlight the target features. The specific calculation formula is:
[0123] gray=0.299r+0.587g+0.114b
[0124] Among them, gray represents the gray value of the ID photo, r, g, b represent the values of the RGB channels of the ID photo;
[0125] Step 2.1.b: Calculate the gradient value and gradient direction of each pixel. The specific calculation formula is:
[0126]
[0127] Among them, g(x, y) represents the gradient value of the pixel with coordinates (x, y), g x Represents the horizontal gradient, g y Represents the vertical gradient;
[0128] Step 2.1.c: Calculate the gradient direction. The specific calculation formula is:
[0129]
[0130] Among them, θ(x, y) represents the gradient direction of the pixel with coordinates (x, y);
[0131] Step 2.1.d: Calculate the gradient histogram vector. The specific calculation formula is:
[0132] HOG(i)=∑g(x,y), (i*20≤θ(x,y)<(i+1)*20)
[0133] The value range of i is {0, 1, 2, 3, 4, 5, 6, 7, 8}. The image is divided into 8*8 units, and the directional gradient histogram feature vector is calculated according to the angle group of each unit;
[0134] Step 2.1.e: Normalize the directional gradient histogram. Take 2*2 units as a block. The directional gradient histogram feature vector of the block is a 36-dimensional vector composed of the directional gradient histogram feature vectors of 4 units. Calculate the normalized value of the directional gradient histogram feature vector of the block. The specific calculation formula is:
[0135]
[0136] Where k represents the dimension of the vector, and HOG′(k) represents the directional gradient histogram feature vector of the block;
[0137] Step 2.1.f: Input the directional gradient histogram feature vector of the block into the face support vector machine for classification and output the face area;
[0138] The directional gradient histogram feature vector of the block is a 36-dimensional vector. The directional gradient histogram feature vector of each block can be considered as a point in the 36-dimensional space. The face support vector machine is obtained in advance through the labeled face area. The face support vector machine is a set of 36-dimensional hyperplanes that can frame the points that are considered to be faces. In the two-dimensional space, the face support vector machine frames the area where the face is located through a set of straight lines and finally outputs the face slice.
[0139] Step 4: Perform Gaussian smoothing on the areas where glasses may exist. The specific contents include:
[0140] For each point (x, y) in the area where the glasses may exist, the specific calculation formula for the weights of other points (x±u, y±v) with respect to the point (x, y) is:
[0141]
[0142] Where u represents the distance between other points (x±u, y±v) and point (x, y) along the X-axis, v represents the distance between other points (x±u, y±v) and point (x, y) along the Y-axis, and G(u, v) represents the weight of other points (x±u, y±v) with respect to point (x, y);
[0143] Perform Gaussian smoothing on each point in the area where the glasses may exist. The specific calculation formula is:
[0144]
[0145] Among them, pixel (x±u, y±v) represents the pixel value of other points (x±u, y±v), c represents the length of the area where the glasses may exist, w represents the width of the area where the glasses may exist, and pixel′(x, y) represents the pixel value of the point (x, y) after Gaussian smoothing. Gaussian smoothing is performed on the area where the glasses may exist to filter out the small noise in the area where the glasses may exist, so as to further obtain the edge intensity matrix and prevent false detection caused by noise.
[0146] The image edge after gradient calculation is blurred. The edge strength matrix is calculated by non-maximum suppression to further enhance the edge. At the same time, all gradient values outside the local maximum value are suppressed to 0, and the edge strength matrix is further updated to enhance the edge to the greatest extent.
[0147] The specific contents of step 5, outputting the edge strength matrix based on non-maximum suppression, include:
[0148] Step 3.1: Calculate the first-order derivative matrix gray' along the Y-axis direction in each area where the glasses may exist;
[0149] Step 3.2: Output the edge strength matrix g(x, y) obtained by non-maximum suppression. The specific calculation formula is:
[0150]
[0151] Step 3.3: Determine the number of zero elements in the eight pixels adjacent to each pixel of g(x, y) and output the zero-degree matrix e(x, y). The specific calculation formula is:
[0152]
[0153] Step 3.4: Calculate the zero-degree matrix E and perform the maximum pooling update edge strength matrix with a step of 1 containing upper and lower thresholds L and H. The specific calculation formula is:
[0154]
[0155] Wherein, g(x, y)′ represents the updated edge strength matrix.
[0156] Step 6: The specific contents of the possible areas of the glasses are as follows:
[0157] The bridge of the nose and the area under the eyes are cropped from the edge intensity matrix to obtain possible area slices for reconstructing the glasses: Based on the edge intensity matrix and the slices of the ID photo in the above steps, the bridge of the nose and the frame under the glasses are further located to emphasize the features of the bridge of the nose and the frame under the glasses.
[0158] The bridge of the nose area is composed of a rectangle defined by points (x1, y1) and (x2, y2). The specific calculation formula is:
[0159]
[0160] The area below the eyes is represented by the point (x 11 ,y 11 ) and point (x 12 ,y 12 ) and the rectangle defined by the point (x 21 ,y 21 ) and point (x 22 ,y 22 ) is formed by stitching the rectangles determined by the equation. The specific calculation formula is:
[0161]
[0162] Step seven determines whether there is a glasses frame. The specific contents include: extracting the directional gradient histogram features from the matrix of the possible area of the reorganized glasses, inputting it into the glasses support vector machine for detection, setting an upper limit threshold B, and when the return value of the glasses support vector machine is greater than the threshold B, it is determined that the face in the photo is wearing glasses; when the return value of the glasses support vector machine is less than the threshold B, it is determined that the face in the photo is not wearing glasses, and the final result is output based on the judgment result.
[0163] Step seven determines whether there is a glasses frame. The specific contents also include: extracting directional gradient histogram features from the matrix of the possible area of the reorganized glasses, inputting the glasses support vector machine for detection, setting an upper threshold B and a lower threshold S, and when the return value of the glasses support vector machine is greater than the threshold B, it is determined that the face in the photo is wearing glasses; when the return value of the glasses support vector machine is less than the threshold S, it is determined that the face in the photo is not wearing glasses; a glass detection model is established based on the glass detection network GDNet; when the return value of the glasses support vector machine is less than B and greater than S, the ID photo is input into the glass detection model; if glass is detected, it is determined that the face in the photo is wearing glasses; if no glass is detected, it is determined that the face in the photo is not wearing glasses; and the final result is output based on the judgment result.
[0164] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0165] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for rapid ID photo glasses detection based on image processing, characterized in that: The specific steps of glasses testing include: Step 1: Get a photo of your ID card; Step 2: Image processing, image enhancement of the ID photo; Step 3: Continue to slice the ID photo to obtain slices of the area where the glasses may be located; Step 4: Perform Gaussian smoothing on the area where glasses may exist; Step 5: Output edge strength matrix based on non-maximum suppression; Step 6: further slice and reorganize the possible glasses area based on the updated edge strength matrix; Step 7: Input the possible area of the reconstructed glasses into the glasses support vector machine and output the final result; The specific steps of step three include: Step 2.1: Recognize the face in the image through the directional gradient histogram feature extractor and the linear support vector machine, and output the face area slice; Step 2.1.a: Grayscale the ID photo. The specific calculation formula is: ; Among them, gray represents the gray value of the ID photo, Indicates the values of the three channels of RGB in the ID photo; Step 2.1.b: Calculate the gradient value and gradient direction of each pixel. The specific calculation formula is: ; in, Represents the gradient value of the pixel with coordinates (x, y), represents the horizontal gradient, Represents the vertical gradient; Step 2.1.c: Calculate the gradient direction. The specific calculation formula is: ; in, Represents the gradient direction of the pixel with coordinates (x, y); Step 2.1.d: Calculate the gradient histogram vector. The specific calculation formula is: ; The value range of i is {0,1,2,3,4,5,6,7,8}. The image is divided into 8*8 units, and the directional gradient histogram feature vector is calculated according to the angle group of each unit; Step 2.1.e: Normalize the directional gradient histogram. Take 2*2 units as a block. The directional gradient histogram feature vector of the block is a 36-dimensional vector composed of the directional gradient histogram feature vectors of 4 units. Calculate the normalized value of the directional gradient histogram feature vector of the block. The specific calculation formula is: ; in, represents the dimension of the vector, The feature vector of the histogram of oriented gradients representing the block; Step 2.1.f: Input the directional gradient histogram feature vector of the block into the face support vector machine for classification and output the face area; Step 2.2: Identify the facial features in the face region slices using the directional gradient histogram feature extractor and the linear support vector machine to obtain the coordinates of the iris center area of the left and right eyes; Step 2.3: Get the slice of the area where the glasses may exist, rotate the image until the line connecting the left and right eye iris center coordinates is horizontal, and scale the image until the length of the line segment connecting the left and right eye iris center coordinates is d pixels; crop d pixels above the left eye iris center coordinate, d pixels below the left eye iris center coordinate, and d pixels to the left of the left eye iris center coordinate Pixels, left eye iris center coordinates right Pixels, final output There may be regional slices for the pixel glasses.
2. The method for rapid ID photo glasses detection based on image processing according to claim 1, characterized in that: The image enhancement of the ID photo in step 2 includes histogram equalization and highlight correction; The specific content of the histogram equalization is: converting the RGB three channels of the ID photo into HSV channels, performing histogram equalization on the brightness V channel based on the cumulative distribution function, and converting the histogram-equalized HSV channel back into RGB image output; The specific steps of the histogram equalization include: Step 1.1: The specific formula for calculating the maximum and minimum values of RGB three-channel pixels is: , , in, Indicates the values of the three channels of RGB in the ID photo. express The maximum value, express The minimum value; Step 1.2: Convert the three RGB channels of the ID photo into HSV channels. The specific calculation formula is: , , , in, Represents the hue in the HSV channel, represents the saturation in the HSV channel, Represents the brightness in the HSV channel; Step 1.3: The specific formula for histogram equalization of the brightness channel is: ; in, Represents the new brightness channel after histogram equalization, Represents the cumulative distribution function of the original brightness channel, with a domain of [0,255] and a range of ; Step 1.4: H, S and Reconvert to RGB three-channel output ID photo.
3. The method for rapid ID photo glasses detection based on image processing according to claim 1, characterized in that: The specific contents of step 4 of performing Gaussian smoothing on the area where the glasses may be present include: For each point (x, y) in the area where the glasses may exist, the specific calculation formula for the weights of other points (x±u, y±v) with respect to the point (x, y) is: ; in, Indicates the distance between other points (x±u, y±v) and point (x, y) along the X-axis, Indicates the distance between other points (x±u, y±v) and point (x, y) along the Y axis, Represents the weight of other points (x±u, y±v) with respect to point (x, y); Perform Gaussian smoothing on each point in the area where the glasses may exist. The specific calculation formula is: ; in, Represents the pixel value of other points (x±u, y±v), Indicates the length of the area where the glasses may exist. Indicates the width of the area where the glasses may exist. Represents the pixel value of the point (x, y) after Gaussian smoothing.
4. The method for rapid ID photo glasses detection based on image processing according to claim 1, characterized in that: The specific contents of the step 5 based on non-maximum suppression output edge strength matrix include: Step 3.1: Calculate the first-order derivative matrix gray' along the Y-axis direction in each area where the glasses may exist; Step 3.2: Output the edge strength matrix obtained by non-maximum suppression , the specific calculation formula is: ; Step 3.3: Judgement The number of 0 elements in the 8 pixels adjacent to each pixel is output as a zero-degree matrix , the specific calculation formula is: ; Step 3.4: Calculate the zero-degree matrix E and perform the maximum pooling update edge strength matrix with a step of 1 containing upper and lower thresholds L and H. The specific calculation formula is: ; in, Represents the updated edge strength matrix.
5. The method for rapid ID photo glasses detection based on image processing according to claim 1, characterized in that: The specific contents of the step 6 of reorganizing the possible glasses region include: cutting the nose bridge region and the area below the eyes from the edge strength matrix to obtain slices of the possible glasses region; The bridge of the nose is marked by a point ( ) and dot ( ) is determined by the rectangular composition, and the specific calculation formula is: ; The area under the eyes is made up of dots and Point Determine the rectangle and the point and Point The specific calculation formula is: 。 6. The method for rapid ID photo glasses detection based on image processing according to claim 1, characterized in that: The specific contents of step seven for judging whether there is a glasses frame include: extracting directional gradient histogram features from the matrix of the possible area of the reorganized glasses, inputting the features into the glasses support vector machine for detection, setting an upper limit threshold value B, and when the return value of the glasses support vector machine is greater than the threshold value B, judging that the face in the photo is wearing glasses; when the return value of the glasses support vector machine is less than the threshold value B, judging that the face in the photo is not wearing glasses, and outputting the final result according to the judgment result.
7. The method for rapid ID photo glasses detection based on image processing according to claim 1, characterized in that: The specific contents of step seven for judging whether there is a glasses frame also include: extracting directional gradient histogram features from the matrix of the possible area of the reorganized glasses, inputting the features into the glasses support vector machine for detection, setting an upper threshold value B and a lower threshold value S, and when the return value of the glasses support vector machine is greater than the threshold value B, judging that the face in the photo is wearing glasses; when the return value of the glasses support vector machine is less than the threshold value S, judging that the face in the photo is not wearing glasses, establishing a glass detection model based on the glass detection network GDNet, and when the return value of the glasses support vector machine is less than B and greater than S, inputting the ID photo into the glass detection model, and if glass is detected, judging that the face in the photo is wearing glasses; if glass is not detected, judging that the face in the photo is not wearing glasses, and outputting the final result according to the judgment result.
