Face region selection method, device, storage medium and apparatus
By extracting candidate face regions that match the face regions of the previous frame in the current frame image, and determining whether they meet the selection criteria based on preset detection conditions, the problem of constantly changing face recognition regions is solved, thus improving the efficiency of face recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-22
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, the face recognition area changes continuously due to the movement of the face being recognized during the face recognition process, which reduces the efficiency of face recognition.
By acquiring the face regions in the current frame image and the previous frame image detected by the image sensor, candidate face regions that match the face regions in the previous frame are extracted, and it is determined whether they meet the selection conditions according to preset detection conditions. The candidate face regions that meet the conditions are taken as the current frame face regions of the current frame image.
The face region selection process has been optimized, overcoming the problem of constantly changing face recognition regions and improving the efficiency of face recognition.
Smart Images

Figure CN114387279B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a method, device, storage medium and apparatus for selecting a face region. Background Technology
[0002] With the maturity of technology and the increase in social acceptance, facial recognition has been applied in many fields, such as facial recognition access control and attendance systems, facial recognition security doors, and facial recognition mobile phone unlocking.
[0003] Currently, a crucial prerequisite for facial recognition is selecting a suitable facial region as the recognition image. Existing technologies select this region by comparing the area of all facial regions in the image in real time, choosing the largest one. However, in reality, because the face being recognized is constantly moving during the recognition process, the largest facial region continuously changes, leading to a continuous shift in the facial recognition area and reducing recognition efficiency.
[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention
[0005] The main objective of this invention is to provide a method, device, storage medium, and apparatus for selecting facial regions, aiming to solve the technical problem of optimizing the facial region selection process.
[0006] To achieve the above objectives, the present invention provides a method for selecting a face region, the method comprising the following steps:
[0007] Acquire the current frame image detected by the image sensor, and acquire the selected face region from the previous frame image;
[0008] Extract the candidate face region that matches the face region of the previous frame in the current frame image;
[0009] Based on the candidate face region and the current frame image, determine whether the candidate face region meets the preset detection conditions;
[0010] When the candidate face region meets the preset detection conditions, the candidate face region is used as the current frame face region selected by the current frame image.
[0011] Optionally, the step of determining whether the candidate face region meets the preset detection conditions based on the candidate face region and the current frame image specifically includes:
[0012] Obtain the face location information and the area of the candidate face region;
[0013] Determine the image boundary location information and the target face area based on the current frame image;
[0014] Based on the face location information, the area of the candidate face, the image boundary location information, and the area of the target face, it is determined whether the candidate face region meets the preset detection conditions.
[0015] Optionally, the step of determining the image boundary location information and the target face area based on the current frame image specifically includes:
[0016] Perform boundary detection on the current frame image to obtain image boundary position information;
[0017] The target face area of the current frame image is obtained by analyzing the current frame image using a preset neural network model.
[0018] Optionally, the step of analyzing the current frame image using a preset neural network model to obtain the target face area of the current frame image specifically includes:
[0019] The initial face region of the current frame image is obtained by analyzing the current frame image using a preset neural network model.
[0020] Obtain the initial face area of the initial face region, and sort the initial face regions according to the initial face area to obtain the sorting result;
[0021] The initial face region is filtered according to the sorting result to obtain the target face region;
[0022] Find the target face area corresponding to the target face region within the initial face area.
[0023] Optionally, the step of determining whether the candidate face region meets the preset detection conditions based on the face location information, the candidate face area, the image boundary location information, and the target face area specifically includes:
[0024] Based on the face location information and the image boundary location information, determine whether the candidate face region is located on the image boundary of the current frame image, and obtain the location determination result;
[0025] Determine whether the area of the candidate face is greater than a preset area, and obtain the area determination result;
[0026] The area of the candidate face is compared with the area of the target face to obtain the area comparison result;
[0027] Based on the location judgment result, the area judgment result, and the area comparison result, determine whether the candidate face region meets the preset detection conditions.
[0028] Optionally, the step of comparing the area of the candidate face with the area of the target face to obtain an area comparison result specifically includes:
[0029] Obtain the location information of the target face region and find the weight value corresponding to the location information of the target face region;
[0030] The area of the face to be compared is determined based on the weight value and the target face area.
[0031] Determine whether the area of the candidate face is greater than the area of the face to be compared, and obtain the area comparison result.
[0032] Optionally, after the step of determining whether the candidate face region meets the preset detection conditions based on the position determination result, the area determination result, and the area comparison result, the face region selection method further includes:
[0033] When the candidate face region does not meet the preset detection conditions, the target face region is selected as the current frame face region of the current frame image.
[0034] Optionally, the step of extracting the candidate face region that matches the face region of the previous frame in the current frame image specifically includes:
[0035] The initial face region of the current frame image is obtained by analyzing the current frame image using a preset neural network model.
[0036] The initial face region is matched with the face region of the previous frame, and the initial face region that is successfully matched is used as the candidate face region.
[0037] Optionally, the step of matching the initial face region with the face region of the previous frame and using the successfully matched initial face region as the candidate face region specifically includes:
[0038] The initial face region and the previous frame face region are subjected to grayscale processing to obtain the grayscale values of the initial face region and the previous frame face region.
[0039] Based on the initial face region grayscale value and the previous frame face region grayscale value, determine whether the initial face region matches the previous frame face region;
[0040] When the matching result is successful, the initial face region that has been successfully matched is taken as the candidate face region.
[0041] Optionally, after the step of selecting the candidate face region as the current frame face region selected by the current frame image when the candidate face region meets the preset detection conditions, the face region selection method further includes:
[0042] The target face information is determined based on the face region of the previous frame and the face region of the current frame;
[0043] Based on the target facial information, facial recognition is performed using a preset facial recognition model to obtain the facial recognition result.
[0044] Furthermore, to achieve the above objectives, the present invention also proposes a face region selection device, which includes a memory, a processor, and a face region selection program stored in the memory and executable on the processor. The face region selection program is configured to implement the steps of the face region selection method described above.
[0045] In addition, to achieve the above objectives, the present invention also proposes a storage medium storing a face region selection program, wherein when the face region selection program is executed by a processor, it implements the steps of the face region selection method as described above.
[0046] In addition, to achieve the above objectives, the present invention also proposes a face region selection device, which includes: an acquisition module, an extraction module, a judgment module, and a selection module;
[0047] The acquisition module is used to acquire the current frame image detected by the image sensor and to acquire the selected face region of the previous frame image.
[0048] The extraction module is used to extract a candidate face region in the current frame image that matches the face region in the previous frame.
[0049] The judgment module is used to determine whether the candidate face region meets the preset detection conditions based on the candidate face region and the current frame image;
[0050] The selection module is used to select the candidate face region as the current frame face region of the current frame image when the candidate face region meets the preset detection conditions.
[0051] Optionally, the judgment module is further configured to obtain the face location information and the area of the candidate face region;
[0052] The judgment module is also used to determine the image boundary position information and the target face area based on the current frame image;
[0053] The judgment module is further configured to determine whether the candidate face region meets the preset detection conditions based on the face location information, the candidate face area, the image boundary location information, and the target face area.
[0054] Optionally, the judgment module is further configured to perform boundary detection on the current frame image to obtain image boundary position information;
[0055] The judgment module is also used to analyze the current frame image through a preset neural network model to obtain the target face area of the current frame image.
[0056] Optionally, the judgment module is further configured to analyze the current frame image through a preset neural network model to obtain the initial face region of the current frame image;
[0057] The judgment module is further configured to obtain the initial face area of the initial face region, and sort the initial face region according to the initial face area to obtain a sorting result;
[0058] The judgment module is further configured to filter the initial face region according to the sorting result to obtain the target face region;
[0059] The judgment module is also used to find the target face area corresponding to the target face region in the initial face area.
[0060] Optionally, the judgment module is further configured to determine whether the candidate face region is located at the image boundary of the current frame image based on the face position information and the image boundary position information, and obtain a position judgment result;
[0061] The judgment module is also used to determine whether the area of the candidate face is greater than a preset area, and to obtain an area judgment result;
[0062] The judgment module is also used to compare the area of the candidate face with the area of the target face to obtain an area comparison result;
[0063] The judgment module is also used to determine whether the candidate face region meets the preset detection conditions based on the position judgment result, the area judgment result, and the area comparison result.
[0064] Optionally, the judgment module is further configured to obtain the location information of the target face region and find the weight value corresponding to the location information of the target face region;
[0065] The judgment module is also used to determine the area of the face to be compared based on the weight value and the target face area;
[0066] The judgment module is also used to determine whether the area of the candidate face is greater than the area of the face to be compared, and to obtain the area comparison result.
[0067] Optionally, the face region selection device further includes: a determination module;
[0068] The determining module is used to select the target face region as the current frame face region of the current frame image when the candidate face region does not meet the preset detection conditions.
[0069] Optionally, the extraction module is further configured to analyze the current frame image using a preset neural network model to obtain the initial face region of the current frame image;
[0070] The extraction module is further configured to match the initial face region with the face region of the previous frame, and use the successfully matched initial face region as the candidate face region.
[0071] In this invention, the current frame image detected by the image sensor is acquired, and the selected face region from the previous frame image is acquired. A candidate face region matching the face region from the previous frame is extracted from the current frame image. Based on the candidate face region and the current frame image, it is determined whether the candidate face region meets preset detection conditions. If the candidate face region meets the preset detection conditions, it is used as the selected face region for the current frame image. Compared to existing methods that compare the size of all face regions in a real-time image and use the largest face region as the face recognition region, this invention overcomes the shortcomings of existing technologies where the face recognition region constantly changes, reducing face recognition efficiency. This optimizes the face region selection process. Attached Figure Description
[0072] Figure 1 This is a schematic diagram of the structure of the face region selection device in the hardware operating environment involved in the embodiments of the present invention;
[0073] Figure 2 This is a flowchart illustrating the first embodiment of the face region selection method of the present invention;
[0074] Figure 3 This is a flowchart illustrating the second embodiment of the face region selection method of the present invention;
[0075] Figure 4This is a flowchart illustrating the third embodiment of the face region selection method of the present invention;
[0076] Figure 5 This is a structural block diagram of the first embodiment of the face region selection device of the present invention.
[0077] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0078] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0079] Reference Figure 1 , Figure 1 This is a schematic diagram of the face region selection device structure in the hardware operating environment involved in the embodiments of the present invention.
[0080] like Figure 1 As shown, the face region selection device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to establish communication between these components. The user interface 1003 may include a display screen, and optionally, it may also include a standard wired interface or a wireless interface. In this invention, the wired interface of the user interface 1003 may be a USB interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a non-volatile memory (NVM), such as a disk drive. The memory 1005 may also optionally be a storage device independent of the aforementioned processor 1001.
[0081] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the face region selection device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0082] like Figure 1 As shown, the memory 1005, which is identified as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a face region selection program.
[0083] exist Figure 1In the face region selection device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the user device; the face region selection device calls the face region selection program stored in the memory 1005 through the processor 1001 and executes the face region selection method provided in this embodiment of the invention.
[0084] Based on the above hardware structure, an embodiment of the face region selection method of the present invention is proposed.
[0085] Reference Figure 2 , Figure 2 This is a flowchart illustrating the first embodiment of the face region selection method of the present invention, which presents the first embodiment of the face region selection method of the present invention.
[0086] In the first embodiment, the face region selection method includes the following steps:
[0087] Step S10: Obtain the current frame image detected by the image sensor, and obtain the selected face region from the previous frame image.
[0088] It should be understood that the execution subject of this embodiment is the face region selection device, which can be an electronic device such as a computer or server, or other devices that can achieve the same or similar functions. This embodiment does not limit this; in this embodiment, the face region selection device is used as an example.
[0089] It should be noted that the image sensor can be a device that has established a communication connection with the face region selection device in advance; the current frame image can be the image corresponding to the video frame at the current moment; the face region selected in the previous frame image can be the face region with the largest area determined based on the previous frame image.
[0090] It is understood that obtaining the selected face region from the previous frame image can be done by reading the face region corresponding to the previous frame image from a preset storage area. The preset storage area can be a pre-set storage area used to store the face region with the largest area. This embodiment does not limit this.
[0091] Step S20: Extract the candidate face region that matches the face region of the previous frame in the current frame image.
[0092] It should be noted that the candidate face region can be the face region corresponding to the face region in the previous frame in the current frame image.
[0093] It should be understood that extracting a candidate face region that matches the face region of the previous frame in the current frame image can be done by performing feature extraction on the current frame image to obtain the features of the current frame image, performing feature extraction on the face region of the previous frame to obtain the features of the face region of the previous frame, matching the features of the current frame image with the features of the face region of the previous frame to obtain the matching result, and extracting the candidate face region from the current frame image based on the matching result.
[0094] Furthermore, considering practical applications, matching the features of the current frame image with the facial region features of the previous frame would inevitably lead to too many objects involved in the matching process and excessive computation. To overcome this drawback, the step of extracting the candidate facial region that matches the facial region of the previous frame from the current frame image includes:
[0095] The current frame image is analyzed by a preset neural network model to obtain the initial face region of the current frame image. The initial face region is then matched with the face region of the previous frame, and the successfully matched initial face region is taken as the candidate face region.
[0096] Step S30: Determine whether the candidate face region meets the preset detection conditions based on the candidate face region and the current frame image.
[0097] It should be noted that the preset detection conditions can be user-defined restrictions, and this embodiment does not impose any restrictions on them.
[0098] It should be understood that determining whether a candidate face region meets the preset detection conditions based on the candidate face region and the current frame image can be done by comparing the candidate face region with the current frame image, obtaining the comparison result, and then determining whether the candidate face region meets the preset detection conditions based on the comparison result.
[0099] Furthermore, in order to quickly and accurately determine whether the candidate face region meets the preset detection conditions, the step of determining whether the candidate face region meets the preset detection conditions based on the candidate face region and the current frame image includes:
[0100] The face location information and face area of the candidate face region are obtained. The image boundary location information and target face area are determined based on the current frame image. The candidate face region is judged to meet the preset detection conditions based on the face location information, the face area of the candidate face, the image boundary location information, and the target face area.
[0101] Step S40: When the candidate face region meets the preset detection conditions, the candidate face region is selected as the current frame face region of the current frame image.
[0102] It should be noted that the face region selected in the current frame image can be any region selected in the current frame image for image recognition.
[0103] It should be understood that when the candidate face region meets the preset detection conditions, it means that the face region corresponding to the face region of the previous frame in the current frame image meets the preset detection conditions. At this time, the face region corresponding to the face region of the previous frame in the current frame image can be directly used as the current frame face region selected for the current frame image for subsequent image recognition processing.
[0104] In the first embodiment, the current frame image detected by the image sensor is acquired, and the selected face region from the previous frame image is acquired. A candidate face region matching the face region from the previous frame is extracted from the current frame image. Based on the candidate face region and the current frame image, it is determined whether the candidate face region meets preset detection conditions. If the candidate face region meets the preset detection conditions, it is used as the selected face region for the current frame image. Compared to the existing method of comparing the area of all face regions in a real-time image and using the largest face region as the face recognition region, this embodiment overcomes the defect in the prior art where the face recognition region constantly changes, reducing face recognition efficiency, by extracting a candidate face region matching the face region from the current frame image, determining whether the candidate face region meets preset detection conditions based on the previous frame image and the current frame image, and using the candidate face region as the selected face region for the current frame image when the preset detection conditions are met. This optimizes the face region selection process.
[0105] Reference Figure 3 , Figure 3 This is a flowchart illustrating the second embodiment of the face region selection method of the present invention, based on the above. Figure 2 The first embodiment shown presents a second embodiment of the face region selection method of the present invention.
[0106] In the second embodiment, step S20 includes:
[0107] Step S201: Analyze the current frame image using a preset neural network model to obtain the initial face region of the current frame image.
[0108] It should be noted that the preset neural network model can be a pre-set neural network, such as a convolutional neural network; the initial face region can be a region in the current frame image where a face exists, and this embodiment does not impose any restrictions on this.
[0109] Step S202: Match the initial face region with the face region of the previous frame, and use the successfully matched initial face region as the candidate face region.
[0110] It should be noted that the candidate face region can be the face region corresponding to the face region in the previous frame in the current frame image.
[0111] In a specific implementation, for example, the initial face region is traversed to find the face region corresponding to the largest face region in the previous frame image, and this face region is used as the candidate face region.
[0112] It should be understood that matching the initial face region with the face region of the previous frame and using the successfully matched initial face region as the candidate face region can be done by performing image matching between the initial face region and the face region of the previous frame, obtaining the image matching result, and using the successfully matched initial face region as the candidate face region.
[0113] Furthermore, considering practical applications, matching the initial face region with the face region of the previous frame would inevitably lead to too many objects involved in the matching process and excessive computation. To overcome this drawback, step S202 includes:
[0114] The initial face region and the previous frame face region are subjected to grayscale processing to obtain the grayscale values of the initial face region and the previous frame face region.
[0115] Based on the initial face region grayscale value and the previous frame face region grayscale value, determine whether the initial face region matches the previous frame face region;
[0116] When the matching result is successful, the initial face region that has been successfully matched is taken as the candidate face region.
[0117] It should be noted that the initial face region grayscale value can be used to represent the grayscale value of each pixel in the initial face region; the previous frame face region grayscale value can be used to represent the grayscale value of each pixel in the previous frame face region.
[0118] It should be understood that grayscale processing of the initial face region and the face region of the previous frame to obtain the grayscale values of the initial face region and the face region of the previous frame can be performed by performing grayscale processing of the initial face region and the face region of the previous frame using a preset grayscale model. The preset grayscale model can be an image grayscale processing model preset by the user, and this embodiment does not limit it.
[0119] It is understandable that determining whether the initial face region matches the previous frame face region based on the initial face region grayscale value and the previous frame face region grayscale value can be done by calculating the region similarity between the initial face region and the previous frame face region based on the initial face region grayscale value and the previous frame face region grayscale value, and determining whether the region similarity is greater than a preset similarity threshold. If the region similarity is greater than the preset threshold, it is determined that the initial face region matches the previous frame face region. The preset similarity threshold can be a value preset by the user.
[0120] In the second embodiment, the current frame image is analyzed by a preset neural network model to obtain the initial face region of the current frame image. The initial face region is matched with the face region of the previous frame, and the successfully matched initial face region is used as the candidate face region. This enables the candidate face region corresponding to the face region of the previous frame to be selected quickly and accurately from the current frame image.
[0121] In the second embodiment, step S30 includes:
[0122] Step S301: Obtain the face location information and the area of the candidate face region.
[0123] It should be noted that the face location information can be the location information of the face in the candidate face region in the current frame image, or it can be the location information of the candidate face region in the current frame image. In this embodiment, the location information of the candidate face region in the current frame image is used as an example for explanation; the candidate face area can be the area value of the candidate face in the candidate face region.
[0124] Step S302: Determine the image boundary location information and the target face area based on the current frame image.
[0125] It should be noted that the target face region can be the largest face region in the current frame image, but this embodiment does not impose any restrictions on this.
[0126] It should be understood that determining the image boundary location information and the target face area based on the current frame image can be achieved by analyzing the current frame image, obtaining the analysis results, and then determining the image boundary location information and the target face area based on the analysis results.
[0127] Furthermore, to improve the reliability of image boundary location information and target face area, the step of determining image boundary location information and target face area based on the current frame image includes:
[0128] Boundary detection is performed on the current frame image to obtain image boundary position information. The current frame image is then analyzed using a preset neural network model to obtain the target face area of the current frame image.
[0129] Step S303: Determine whether the candidate face region meets the preset detection conditions based on the face location information, the area of the candidate face, the image boundary location information, and the area of the target face.
[0130] It should be noted that the preset detection conditions can be user-defined restrictions, and this embodiment does not impose any restrictions on them.
[0131] Furthermore, to improve the accuracy of the judgment results, the step of determining whether the candidate face region meets the preset detection conditions based on the face location information, the area of the candidate face, the image boundary location information, and the target face area includes:
[0132] Based on the face location information and the image boundary location information, determine whether the candidate face region is located at the image boundary of the current frame image to obtain a location determination result. Determine whether the area of the candidate face is greater than a preset area to obtain an area determination result. Compare the area of the candidate face with the area of the target face to obtain an area comparison result. Based on the location determination result, the area determination result, and the area comparison result, determine whether the candidate face region meets the preset detection conditions.
[0133] In the second embodiment, by acquiring the face position information and the area of the candidate face region, determining the image boundary position information and the target face area based on the current frame image, and judging whether the candidate face region meets the preset detection conditions based on the face position information, the area of the candidate face, the image boundary position information, and the target face area, it is possible to quickly and accurately judge whether the candidate face region meets the preset detection conditions.
[0134] In the second embodiment, after step S40, the method further includes:
[0135] Step S50: Determine the target face information based on the face region of the previous frame and the face region of the current frame.
[0136] It should be noted that the target facial information can be facial information used for facial recognition, and this embodiment does not limit it.
[0137] It is understandable that determining the target face information based on the face region of the previous frame and the face region of the current frame can be achieved by aggregating the information of the face region of the previous frame and the face region of the current frame, obtaining the aggregation result, and then determining the target face information based on the aggregation result.
[0138] Step S60: Perform face recognition based on the target face information using a preset face recognition model to obtain the face recognition result.
[0139] It should be noted that the preset face recognition model can be a face recognition model pre-set by the user, such as ResNet, SE-resNet, and VGG model. In this embodiment, VGG model is used as an example for explanation.
[0140] In the second embodiment, by determining the target face information based on the face region of the previous frame and the face region of the current frame, and performing face recognition based on the target face information using a preset face recognition model, the face recognition result can be obtained, thereby improving the accuracy of face recognition.
[0141] Reference Figure 4 , Figure 4 This is a flowchart illustrating the third embodiment of the face region selection method of the present invention, based on the above. Figure 3 The second embodiment shown presents a third embodiment of the face region selection method of the present invention.
[0142] In the third embodiment, step S302 includes:
[0143] Step S3021: Perform boundary detection on the current frame image to obtain image boundary position information.
[0144] It should be noted that the image boundary position information can be the top, bottom, left, and right boundary information of the current frame image, and this embodiment does not limit it.
[0145] It should be understood that performing boundary detection on the current frame image to obtain image boundary position information can be achieved by scanning the current frame image, obtaining the scanning results, and determining the image boundary position information of the current frame image based on the scanning results.
[0146] Step S3022: Analyze the current frame image using a preset neural network model to obtain the target face area of the current frame image.
[0147] It should be noted that the target face region can be the largest face region in the current frame image, but this embodiment does not impose any restrictions on this.
[0148] Furthermore, considering practical applications, directly analyzing the current frame image through a preset neural network model to obtain the target face area of the current frame image will inevitably lead to low accuracy. To overcome this deficiency, step S3023 includes:
[0149] The initial face region of the current frame image is obtained by analyzing the current frame image using a preset neural network model.
[0150] Obtain the initial face area of the initial face region, and sort the initial face regions according to the initial face area to obtain the sorting result;
[0151] The initial face region is filtered according to the sorting result to obtain the target face region;
[0152] Find the target face area corresponding to the target face region within the initial face area.
[0153] It should be noted that the preset neural network model can be a pre-set neural network, such as a convolutional neural network; the initial face region can be a region in the current frame image where a face exists, and this embodiment does not impose any restrictions on this.
[0154] It should be understood that sorting the initial face regions based on their initial face area can yield a sorting result that is based on the size of the initial face area. For example, sorting the initial face regions in descending order of their initial face area will yield a sorting result.
[0155] Understandably, the initial face region is filtered based on the sorting results to obtain the target face region. This means that the initial face region with the highest sorting value is selected as the target face region, which is the initial face region with the largest area.
[0156] In the third embodiment, the current frame image is processed by grayscale to obtain a grayscale image of the current frame image. The image boundary position information of the current frame image is determined based on the grayscale image. The current frame image is analyzed by a preset neural network model to obtain the target face area of the current frame image, thereby improving the reliability of the image boundary position information and the target face area.
[0157] In the third embodiment, step S303 includes:
[0158] Step S3031: Determine whether the candidate face region is located on the image boundary of the current frame image based on the face position information and the image boundary position information, and obtain the position determination result.
[0159] It should be understood that, based on the face location information and the image boundary location information, it is determined whether the candidate face region is located on the image boundary of the current frame image. The location determination result can be obtained by matching the face location information with the image boundary location information. When the match is successful, it means that the candidate face region is located on the image boundary of the current frame image.
[0160] Step S3032: Determine whether the area of the candidate face is greater than a preset area, and obtain the area determination result.
[0161] It should be noted that the preset area can be an area value set by the user beforehand.
[0162] It should be understood that, in order to avoid the problem that the image size of the candidate face region differs too much from that of the face region in the previous frame, it is necessary to determine whether the area of the candidate face is larger than the preset area.
[0163] Step S3033: Compare the area of the candidate face with the area of the target face to obtain the area comparison result.
[0164] It should be understood that comparing the area of the candidate face with the area of the target face to obtain the area comparison result can be done by determining the area of the face to be compared based on the preset score and the area of the target face, and judging whether the area of the candidate face is greater than the area of the face to be compared, thus obtaining the area comparison result.
[0165] In practical implementation, for example, it can be determined whether the area of the candidate face is greater than one-third of the area of the target face to obtain the area comparison result.
[0166] Furthermore, considering that in practical applications, the target face region may not be located in the center of the image, relying solely on the user-preset score for judgment will inevitably lead to inaccurate results. To overcome this deficiency, step S3033 includes:
[0167] Obtain the location information of the target face region and find the weight value corresponding to the location information of the target face region;
[0168] The area of the face to be compared is determined based on the weight value and the target face area.
[0169] Determine whether the area of the candidate face is greater than the area of the face to be compared, and obtain the area comparison result.
[0170] It should be noted that the location information can be whether the target face region is located in the middle region, corner region, or edge region of the current frame image, etc., and this embodiment does not limit this.
[0171] It should be understood that finding the weight value corresponding to the location information of the target face region can be done by looking up the weight value corresponding to the location information of the target face region in a preset mapping table. The preset mapping table contains the correspondence between the location information of the target face region and the weight value. The correspondence between the location information of the target face region and the weight value can be preset by the user, and this embodiment does not limit this.
[0172] In specific implementations, for example, if the largest face region in the current frame image is located in the middle region of the current frame image, a weight value of 0.33 can be set; if the largest face region in the current frame image is located in the corner region of the current frame image, a weight value of 0.5 can be set.
[0173] It is understandable that determining the area of the face to be compared based on the weight value and the target face area can be achieved by multiplying the weight value by the target face area to obtain the area of the face to be compared.
[0174] Step S3034: Determine whether the candidate face region meets the preset detection conditions based on the position judgment result, the area judgment result, and the area comparison result.
[0175] It should be noted that the preset detection conditions can be user-defined restrictions, and this embodiment does not impose any restrictions on them.
[0176] It should be understood that determining whether the candidate face region meets the preset detection conditions based on the position judgment result, area judgment result, and area comparison result can be as follows: when the candidate face region is not located at the image boundary of the current frame image, the area of the candidate face is greater than the preset area, and the area of the candidate face is greater than the area of the face to be compared, the candidate face region is determined to meet the preset detection conditions; when any of the above conditions are not met, the candidate face region is determined not to meet the preset detection conditions.
[0177] Furthermore, to improve the reliability of the face region in the current frame, after step S3034, the method further includes:
[0178] When the candidate face region does not meet the preset detection conditions, the target face region is selected as the current frame face region of the current frame image.
[0179] It should be understood that when the candidate face region does not meet the preset detection conditions, it means that the face region corresponding to the face region in the previous frame does not meet the preset detection conditions in the current frame image. In this case, the face region with the largest area in the current frame image should be taken as the current frame face region selected by the current frame image, that is, the target face region should be taken as the current frame face region selected by the current frame image.
[0180] In the third embodiment, by determining whether the candidate face region is located at the image boundary of the current frame image based on the face position information and the image boundary position information, a position determination result is obtained; by determining whether the area of the candidate face is greater than a preset area, an area determination result is obtained; by comparing the area of the candidate face with the area of the target face, an area comparison result is obtained; and by determining whether the candidate face region meets the preset detection conditions based on the position determination result, the area determination result, and the area comparison result, the accuracy of the determination result can be improved.
[0181] Furthermore, this embodiment of the invention also proposes a storage medium storing a face region selection program, which, when executed by a processor, implements the steps of the face region selection method described above.
[0182] In addition, refer to Figure 5 The present invention also proposes a face region selection device, which includes: an acquisition module 10, an extraction module 20, a judgment module 30, and a selection module 40;
[0183] The acquisition module 10 is used to acquire the current frame image detected by the image sensor and to acquire the selected face region from the previous frame image.
[0184] It should be noted that the image sensor can be a device that has established a communication connection with the face region selection device in advance; the current frame image can be the image corresponding to the video frame at the current moment; the face region selected in the previous frame image can be the face region with the largest area determined based on the previous frame image.
[0185] It is understood that obtaining the selected face region from the previous frame image can be done by reading the face region corresponding to the previous frame image from a preset storage area. The preset storage area can be a pre-set storage area used to store the face region with the largest area. This embodiment does not limit this.
[0186] The extraction module 20 is used to extract a candidate face region in the current frame image that matches the face region in the previous frame.
[0187] It should be noted that the candidate face region can be the face region corresponding to the face region in the previous frame in the current frame image.
[0188] It should be understood that extracting a candidate face region that matches the face region of the previous frame in the current frame image can be done by performing feature extraction on the current frame image to obtain the features of the current frame image, performing feature extraction on the face region of the previous frame to obtain the features of the face region of the previous frame, matching the features of the current frame image with the features of the face region of the previous frame to obtain the matching result, and extracting the candidate face region from the current frame image based on the matching result.
[0189] Furthermore, considering practical applications, matching the features of the current frame image with the facial region features of the previous frame would inevitably lead to too many objects involved in the matching process and excessive computation. To overcome this drawback, the step of extracting the candidate facial region that matches the facial region of the previous frame from the current frame image includes:
[0190] The current frame image is analyzed by a preset neural network model to obtain the initial face region of the current frame image. The initial face region is then matched with the face region of the previous frame, and the successfully matched initial face region is taken as the candidate face region.
[0191] The judgment module 30 is used to determine whether the candidate face region meets the preset detection conditions based on the candidate face region and the current frame image.
[0192] It should be noted that the preset detection conditions can be user-defined restrictions, and this embodiment does not impose any restrictions on them.
[0193] It should be understood that determining whether a candidate face region meets the preset detection conditions based on the candidate face region and the current frame image can be done by comparing the candidate face region with the current frame image, obtaining the comparison result, and then determining whether the candidate face region meets the preset detection conditions based on the comparison result.
[0194] Furthermore, in order to quickly and accurately determine whether the candidate face region meets the preset detection conditions, the step of determining whether the candidate face region meets the preset detection conditions based on the candidate face region and the current frame image includes:
[0195] The face location information and face area of the candidate face region are obtained. The image boundary location information and target face area are determined based on the current frame image. The candidate face region is judged to meet the preset detection conditions based on the face location information, the face area of the candidate face, the image boundary location information, and the target face area.
[0196] The selection module 40 is used to select the candidate face region as the current frame face region selected by the current frame image when the candidate face region meets the preset detection conditions.
[0197] It should be noted that the face region selected in the current frame image can be any region selected in the current frame image for image recognition.
[0198] It should be understood that when the candidate face region meets the preset detection conditions, it means that the face region corresponding to the face region of the previous frame in the current frame image meets the preset detection conditions. At this time, the face region corresponding to the face region of the previous frame in the current frame image can be directly used as the current frame face region selected for the current frame image for subsequent image recognition processing.
[0199] In this embodiment, the current frame image detected by the image sensor is acquired, and the selected face region from the previous frame image is acquired. A candidate face region matching the face region from the previous frame is extracted from the current frame image. Based on the candidate face region and the current frame image, it is determined whether the candidate face region meets preset detection conditions. If the candidate face region meets the preset detection conditions, it is used as the selected face region for the current frame image. Compared to existing methods that compare the size of all face regions in a real-time image and use the largest face region as the face recognition region, this embodiment overcomes the shortcomings of existing technologies where the face recognition region constantly changes, reducing face recognition efficiency. This optimizes the face region selection process.
[0200] Other embodiments or specific implementations of the face region selection device described in this invention can be found in the above-described method embodiments, and will not be repeated here.
[0201] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0202] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments. In the unit claims listing several devices, several of these devices may be embodied by the same hardware item. The use of the terms first, second, and third, etc., does not indicate any order and can be interpreted as names.
[0203] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0204] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A face region selection method, characterized in that, The face region selection method comprises the following steps: obtaining a current frame image detected by an image sensor, and obtaining a previous frame face region selected from a previous frame image; extracting a candidate face region matched with the previous frame face region in the current frame image; determining whether the candidate face region meets a preset detection condition according to the candidate face region and the current frame image, wherein the preset detection condition comprises whether the candidate face region is located at an image boundary of the current frame image, whether a candidate face area of the candidate face region is greater than a preset area, and a comparison result of the candidate face area and a target face area; when the candidate face region meets the preset detection condition, taking the candidate face region as a current frame face region selected from the current frame image; wherein, the comparison of the candidate face area and the target face area obtains an area comparison result, comprising: obtaining position information of the target face region, and searching for a weight value corresponding to the position information of the target face region; determining a comparison face area according to the weight value and the target face area; determining whether the candidate face area is greater than the comparison face area to obtain the area comparison result.
2. The face region selection method of claim 1, wherein, The step of determining whether the candidate face region meets the preset detection condition according to the candidate face region and the current frame image specifically comprises: obtaining face position information of the candidate face region and a candidate face area; determining image boundary position information and a target face area according to the current frame image; determining whether the candidate face region meets the preset detection condition according to the face position information, the candidate face area, the image boundary position information and the target face area.
3. The face region selection method of claim 2, wherein, The step of determining image boundary position information and a target face area according to the current frame image specifically comprises: performing boundary detection on the current frame image to obtain image boundary position information; analyzing the current frame image by a preset neural network model to obtain a target face area of the current frame image.
4. The face region selection method of claim 3, wherein, The step of analyzing the current frame image by a preset neural network model to obtain a target face area of the current frame image specifically comprises: analyzing the current frame image by a preset neural network model to obtain an initial face region of the current frame image; obtaining an initial face area of the initial face region, and sorting the initial face region according to the initial face area to obtain a sorting result; screening the initial face region according to the sorting result to obtain a target face region; searching for a target face area corresponding to the target face region in the initial face area.
5. The face region selection method of claim 4, wherein, The step of determining whether the candidate face region meets the preset detection condition according to the face position information, the candidate face area, the image boundary position information and the target face area specifically comprises: determining whether the candidate face region is located at an image boundary of the current frame image according to the face position information and the image boundary position information to obtain a position determination result; determining whether the area of the candidate face is greater than a preset area to obtain an area determination result; comparing the area of the candidate face with the area of the target face to obtain an area comparison result; determining whether the candidate face region satisfies a preset detection condition according to the position determination result, the area determination result, and the area comparison result.
6. The face region selection method of claim 5, wherein, After the step of determining whether the candidate face region satisfies a preset detection condition according to the position determination result, the area determination result, and the area comparison result, the face region selection method further includes: when the candidate face region does not satisfy the preset detection condition, taking the target face region as a current frame face region selected from the current frame image.
7. The method of claim 1-6, wherein, The step of extracting a candidate face region matching the previous frame face region in the current frame image specifically includes: analyzing the current frame image by using a preset neural network model to obtain an initial face region of the current frame image; matching the initial face region with the previous frame face region, and taking the initial face region matched successfully as a candidate face region.
8. The face region selection method of claim 7, wherein, The step of matching the initial face region with the previous frame face region, and taking the initial face region matched successfully as a candidate face region specifically includes: performing gray processing on the initial face region and the previous frame face region to obtain an initial face region gray value and a previous frame face region gray value; determining whether the initial face region matches the previous frame face region according to the initial face region gray value and the previous frame face region gray value; when the matching result is matching success, taking the initial face region matched successfully as a candidate face region.
9. The method of claim 1-6, wherein, After the step of taking the candidate face region as a current frame face region selected from the current frame image when the candidate face region satisfies the preset detection condition, the face region selection method further includes: determining target face information according to the previous frame face region and the current frame face region; performing face recognition by using a preset face recognition model according to the target face information to obtain a face recognition result.
10. A face region selection device, characterized by, The face region selection device includes a memory, a processor, and a face region selection program stored on the memory and executable on the processor, and the face region selection program, when executed by the processor, implements the steps of the face region selection method according to any one of claims 1 to 9.
11. A storage medium, characterized by The storage medium stores a face region selection program, and the face region selection program, when executed by the processor, implements the steps of the face region selection method according to any one of claims 1 to 9.
12. A face region selection apparatus characterized by comprising: The face region selection apparatus includes an acquisition module, an extraction module, a determination module, and a selection module. The acquisition module is configured to acquire a current frame image detected by an image sensor, and acquire a previous frame face region selected from a previous frame image. The extraction module is configured to extract a candidate face region matching the previous frame face region in the current frame image. The determination module is configured to determine whether the candidate face region satisfies a preset detection condition according to a position determination result, an area determination result, and an area comparison result. The selection module is configured to take the candidate face region as a current frame face region selected from the current frame image when the candidate face region satisfies the preset detection condition. The judgment module is configured to judge whether the candidate face region meets a preset detection condition according to the candidate face region and the current frame image, wherein the preset detection condition comprises whether the candidate face region is located at an image boundary of the current frame image, whether a candidate face area of the candidate face region is greater than a preset area, and a comparison result of the candidate face area and a target face area. The selection module is configured to select the candidate face region as a current frame face region of the current frame image when the candidate face region meets the preset detection condition. The judgment module is further configured to acquire position information of the target face region, and find a weight value corresponding to the position information of the target face region; determine a comparison face area according to the weight value and the target face area; and judge whether the candidate face area is greater than the comparison face area to obtain an area comparison result.
13. The face region selection apparatus according to claim 12, wherein The judgment module is further configured to acquire face position information and a candidate face area of the candidate face region. The judgment module is further configured to determine image boundary position information and a target face area according to the current frame image. The judgment module is further configured to judge whether the candidate face region meets the preset detection condition according to the face position information, the candidate face area, the image boundary position information, and the target face area.
14. The face region selection apparatus according to claim 13, wherein The judgment module is further configured to perform boundary detection on the current frame image to obtain image boundary position information. The judgment module is further configured to analyze the current frame image by using a preset neural network model to obtain a target face area of the current frame image.
15. The face region selection apparatus according to claim 14, wherein The judgment module is further configured to analyze the current frame image by using a preset neural network model to obtain an initial face region of the current frame image. The judgment module is further configured to acquire an initial face area of the initial face region, and sort the initial face region according to the initial face area to obtain a sorting result. The judgment module is further configured to screen the initial face region according to the sorting result to obtain a target face region. The judgment module is further configured to find a target face area corresponding to the target face region in the initial face area.
16. The face region selecting apparatus of claim 15, wherein The judgment module is further configured to judge whether the candidate face region is located at the image boundary of the current frame image according to the face position information and the image boundary position information to obtain a position judgment result. The judgment module is further configured to judge whether the candidate face area is greater than a preset area to obtain an area judgment result. The judgment module is further configured to compare the candidate face area with the target face area to obtain an area comparison result. The judgment module is further configured to judge whether the candidate face region meets the preset detection condition according to the position judgment result, the area judgment result, and the area comparison result.
17. The face region selecting apparatus of claim 16, wherein The face region selection device further comprises a determination module. The determination module is configured to take the target face region as a current frame face region selected from the current frame image when the candidate face region does not satisfy a preset detection condition.
18. The face region selection apparatus according to any one of claims 12 to 17, wherein The extraction module is further configured to analyze the current frame image by using a preset neural network model to obtain an initial face region of the current frame image. The extraction module is further configured to match the initial face region with the previous frame face region, and take the initial face region that is successfully matched as a candidate face region.
Citation Information
Patent Citations
Human face recognition method and device
CN106295468A
Face position tracking method and device and electronic equipment
CN106709932A