Face recognition method, device and equipment and storage medium
By acquiring tokens in parallel and performing face recognition detection in a network attack-proof verification environment, the problems of slow face recognition speed and vulnerability to attacks in H5 and mini-program environments are solved, achieving fast and secure face recognition.
Patent Information
- Application Number
- CN202411385446.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-09-30
AI Technical Summary
When performing facial recognition in H5 and mini-program environments, the authentication speed is slow and vulnerable to network attacks, resulting in a poor user experience.
The system simultaneously acquires video verification tokens and anti-network attack control tokens using a parallel processing approach. Upon successful acquisition, it creates an anti-network attack verification environment through a serial processing approach and performs face recognition detection within this environment, utilizing real-time audio and video streams and a glare model for liveness detection.
It improves the speed of facial recognition authentication, enhances security, prevents cyberattacks, and improves the user experience.
Smart Images

Figure CN119254496B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of face recognition, and particularly relates to a face recognition method and device, equipment and a storage medium. BACKGROUND
[0002] With the continuous evolution of Internet technology, H5 (HyperText Markup Language 5) technology has become the preferred development tool for many online services due to its cross-platform and convenience. However, along with this comes many challenges in the field of online face recognition, such as slow authentication speed, vulnerability to network attacks, and poor user experience. In particular, in the H5 and applet environment, how to quickly complete face recognition verification while ensuring data security has become a key problem that needs to be solved.
[0003] The above content is only used to assist in understanding the technical solutions of the present application and does not represent the acknowledgement of the above content as prior art. SUMMARY
[0004] The main purpose of the present application is to provide a face recognition method, device, equipment and storage medium, which aims to solve the technical problems of slow authentication speed and vulnerability to network attacks in the prior art when face recognition is performed in the H5 and applet environment.
[0005] To achieve the above purpose, the present application provides a face recognition method, which comprises:
[0006] Simultaneously acquiring a video verification token and a network attack prevention control token by using a parallel processing mode;
[0007] When acquisition is successful, creating a network attack prevention verification environment by using a serial processing mode based on the video verification token and the network attack prevention control token;
[0008] In the network attack prevention verification environment, performing face recognition detection on a to-be-recognized user based on a real-time audio and video stream corresponding to the to-be-recognized user.
[0009] In an embodiment, the step of creating a network attack prevention verification environment by using a serial processing mode based on the video verification token and the network attack prevention control token when acquisition is successful comprises:
[0010] When acquisition is successful, creating a secure verification room by using a serial processing mode to call a preset verification environment creation function;
[0011] Joining the secure verification room based on the video verification token and the network attack prevention control token to create a network attack prevention verification environment.
[0012] In an embodiment, the step of performing face recognition detection on the to-be-identified user based on the real-time audio and video stream corresponding to the to-be-identified user in the anti-network attack verification environment comprises:
[0013] In the anti-network attack verification environment, the real-time audio and video stream corresponding to the to-be-identified user is obtained in real time through a media device component and an environment component;
[0014] In the process of obtaining the real-time audio and video stream, real-time action inference is performed through a preset communication mode;
[0015] Based on the action inference result, the to-be-verified action corresponding to the to-be-identified user is determined;
[0016] Based on the to-be-verified action, face recognition detection is performed on the to-be-identified user.
[0017] In an embodiment, the step of performing face recognition detection on the to-be-identified user based on the to-be-verified action comprises:
[0018] Real-time collection of a to-be-detected image corresponding to the to-be-identified user is performed;
[0019] Adjusting the image background color of the to-be-detected image based on a color transformation sequence through a preset glare model to generate a glare effect corresponding to the to-be-detected image;
[0020] Inference is performed based on the glare effect through the preset glare model to obtain an inference result;
[0021] Based on the inference result and the to-be-verified action, face recognition detection is performed on the to-be-identified user.
[0022] In an embodiment, the step of performing face recognition detection on the to-be-identified user based on the inference result and the to-be-verified action comprises:
[0023] Based on the inference result, it is determined whether there is a real life feature in the to-be-detected image;
[0024] If there is, the current execution action of the to-be-identified user in the to-be-detected image based on the to-be-verified action is obtained;
[0025] The current execution action is compared with the to-be-verified action to perform face recognition detection on the to-be-identified user.
[0026] In an embodiment, the method further comprises:
[0027] When a network connection exception is detected, a network connection retry request is triggered;
[0028] The current network connection retry count is obtained in real time through a retry counter;
[0029] It is determined whether the current network connection retry count exceeds a preset retry count threshold;
[0030] If yes, the current display page is switched to a network connection exception page.
[0031] In an embodiment, before the step of simultaneously obtaining the video verification token and the network attack prevention control token in a parallel processing manner, the method further comprises:
[0032] According to the preset identification information, a task running environment corresponding to the current face recognition task is determined;
[0033] If yes, the current display page is switched to a network connection exception page.
[0034] If yes, a page switching strategy is determined based on the task running environment;
[0035] The current display page is switched to the network connection exception page based on the page switching strategy.
[0036] In addition, to achieve the above-mentioned purpose, the present application also proposes a face recognition device, which comprises:
[0037] The token obtaining module is configured to simultaneously obtain the video verification token and the network attack prevention control token in a parallel processing manner;
[0038] The verification environment creating module is configured to, when the obtaining is successful, create a network attack prevention verification environment through a serial processing manner based on the video verification token and the network attack prevention control token;
[0039] The face detection module is configured to perform face recognition detection on a to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user in the network attack prevention verification environment.
[0040] In addition, to achieve the above-mentioned purpose, the present application also proposes a face recognition device, which comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the face recognition method as described above.
[0041] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and the storage medium stores a computer program, the computer program being executed by a processor to implement the steps of the face recognition method as described above.
[0042] The application provides a face recognition method, and discloses that a video verification token and a network attack prevention control token are acquired simultaneously in a parallel processing mode; when the acquisition is successful, a network attack prevention verification environment is created based on the video verification token and the network attack prevention control token through a serial processing mode; in the network attack prevention verification environment, a face recognition detection is performed on a to-be-recognized user based on a real-time audio and video stream corresponding to the to-be-recognized user. BRIEF DESCRIPTION OF DRAWINGS
[0043] The drawings incorporated into the specification and constituting a part of the specification show embodiments consistent with the application and, together with the specification, serve to explain the principles of the application.
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the drawings required to be used in the embodiments or the prior art description will be briefly introduced as follows. Obviously, for those skilled in the art, other drawings can also be obtained based on these drawings without creative labor.
[0045] Figure 1 A flowchart is provided for the face recognition method embodiment one of the application;
[0046] Figure 2 A flowchart is provided for the face recognition method embodiment two of the application;
[0047] Figure 3 A flowchart is provided for the face recognition method embodiment three of the application;
[0048] Figure 4 A flowchart is provided for the face recognition method embodiment three of the application;
[0049] Figure 5 A module structure diagram of the face recognition device of the embodiment of the application is provided;
[0050] Figure 6 A device structure diagram of the hardware running environment involved in the face recognition method in the embodiment of the application is provided.
[0051] The purpose implementation, functional features and advantages of the application will be further described with reference to the embodiments and the drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are merely intended to explain the technical solutions of the present application, and are not intended to limit the present application.
[0053] In order to better understand the technical solutions of the present application, the following will be described in detail in conjunction with the accompanying drawings and specific embodiments.
[0054] The main solution of the embodiment of the present application is: using parallel processing to simultaneously obtain a video verification token and a network attack prevention control token; when obtaining is successful, creating a network attack prevention verification environment based on the video verification token and the network attack prevention control token through serial processing; in the network attack prevention verification environment, performing face recognition detection on a to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user.
[0055] The prior art faces many challenges in the field of online face recognition in H5 and applet environments, such as slow authentication speed, vulnerability to network attacks, and poor user experience.
[0056] The present application provides a solution that can create a network attack prevention verification environment based on a video verification token and a network attack prevention control token through serial processing when the video verification token and the network attack prevention control token are successfully obtained, so that face recognition detection can be performed in the network attack prevention verification environment, thereby solving the technical problems of slow authentication speed and vulnerability to network attacks when performing face recognition in H5 and applet environments in the prior art.
[0057] It should be noted that the execution subject of the present embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device, a face recognition device, etc. that can realize the above functions. The present embodiment and the following embodiments will be described below with the face recognition device as an example (hereinafter referred to as the device).
[0058] Based on this, the present embodiment provides a face recognition method, which refers to Figure 1 , Figure 1 The flowchart of the first embodiment of the face recognition method of the present application.
[0059] In the present embodiment, the face recognition method comprises steps S10-S30:
[0060] Step S10: using parallel processing to simultaneously obtain a video verification token and a network attack prevention control token.
[0061] It should be understood that the above parallel processing manner can be a manner of simultaneously performing the operations of obtaining the video verification token and the network attack prevention control token. The video verification token can be a token for authorizing the device to obtain or access a video, and the network attack prevention control token can be a token for authorizing the device to perform scene control. In this embodiment, a strict anti-hack strategy can be implemented by the obtained network attack prevention control token sceneControlToken to prevent external malicious intrusion.
[0062] In this embodiment, when the application in the device is started, initialization is performed after component mounting is completed to perform necessary parameter preprocessing, including user burying point tracking and running environment (such as an H5 environment, a mini-program environment, etc., which are not limited in this embodiment) judgment. Then, the getVideoHackToken and getSceneControlToken requests can be performed in parallel to simultaneously obtain the video verification token and the network attack prevention control token, so as to accelerate the initialization process and lay the foundation for the second-opening experience. In this embodiment, by obtaining the video verification token and the network attack prevention control token in parallel, the waiting time from system startup to verification preparation can be greatly shortened, and the subsequent face recognition authentication speed can be improved.
[0063] Step S20: When the obtaining is successful, a network attack prevention verification environment is created through a serial processing manner based on the video verification token and the network attack prevention control token.
[0064] It can be understood that the above serial processing manner can be a manner of performing the operation of creating an environment after performing the operations of obtaining the video verification token and the network attack prevention control token.
[0065] It should be noted that the above network attack prevention verification environment can be a secure verification environment, and the verification environment can prevent network attacks. In this embodiment, by performing face recognition verification in the network attack prevention verification environment, Hack attacks during the verification process can be prevented, and the security of face recognition is ensured.
[0066] It should be noted that in this embodiment, after obtaining the video verification token and the network attack prevention control token in parallel, the operation of creating the network attack prevention verification environment is performed in series, so that the verification environment can be safely established by using the token, the security of the verification environment is ensured, the verification process is ensured to be performed after all prerequisite conditions are met, security risks that can be caused by parallel operations are prevented, the efficiency and security of face recognition are taken into account. This scheme balances the process optimization and effective use of resources, ensures fast response, and maintains system security.
[0067] Specifically, the step S20 comprises: when the acquisition is successful, creating a secure verification room by calling a preset verification environment creation function in a serial processing mode; and joining the secure verification room based on the video verification token and the network attack prevention control token to create a network attack prevention verification environment.
[0068] It should be understood that the preset verification environment creation function described above can be a function for creating a room for secure verification, and the verification environment creation function in the embodiment can be a createVideoHackRoom function.
[0069] In the embodiment, the getVideoHackToken and getSceneControlToken requests are initiated simultaneously by using an asynchronous programming technique, so that the video verification token and the network attack prevention control token are acquired simultaneously, and the two operations are executed in parallel, thereby greatly reducing the waiting time. Once the tokens are acquired successfully, the createVideoHackRoom function can be called immediately to create a secure verification room and build a Hack-prevention verification environment, i.e., the network attack prevention verification environment. This phase realizes the basis of the second-opening experience and ensures that the user enters the verification process quickly with almost no perception.
[0070] Step S30: In the network attack prevention verification environment, performing face recognition detection on the to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user.
[0071] It can be understood that the to-be-identified user is the user for face recognition this time. After the network attack prevention verification environment is created, the device can capture the audio and video stream corresponding to the to-be-identified user in the network attack prevention verification environment, and perform face recognition on the user based on the audio and video stream in the network attack prevention verification environment. At this time, the face recognition verification process of the user is performed in a strictly controlled environment, which improves the security level of Hack prevention.
[0072] The embodiment provides a face recognition method, which discloses that the video verification token and the network attack prevention control token are acquired simultaneously in a parallel processing mode; when the acquisition is successful, the network attack prevention verification environment is created based on the video verification token and the network attack prevention control token in a serial processing mode; and in the network attack prevention verification environment, face recognition detection is performed on the to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user. Since the network attack prevention verification environment is created based on the video verification token and the network attack prevention control token in a serial processing mode when the video verification token and the network attack prevention control token are acquired successfully, face recognition detection can be performed in the network attack prevention verification environment, thereby solving the technical problems of slow authentication speed and vulnerability to network attacks in the prior art when face recognition is performed in an H5 and applet environment.
[0073] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as the above-mentioned embodiment one can be referred to the above introduction, and the subsequent will not be described in detail. On this basis, please refer to Figure 2 , Figure 2 The flowchart provided by the second embodiment of the face recognition method of the present application.
[0074] In the present embodiment, step S30 includes steps S301-S304:
[0075] Step S301: In the anti-network attack verification environment, the real-time audio and video stream corresponding to the to-be-identified user is acquired in real time through the media device component and the environment component.
[0076] It should be noted that the above-mentioned media device component can be a component for managing media devices, and in the present embodiment, the device can manage the camera resource by calling the media device component, so that the video stream can be captured in real time. The above-mentioned environment component can be a component for managing the security verification environment.
[0077] It can be understood that the above-mentioned real-time audio and video stream can be the audio and video stream of the to-be-identified user collected by the camera in real time.
[0078] Step S302: In the process of acquiring the real-time audio and video stream, real-time action inference is performed through a preset communication mode.
[0079] In the present embodiment, the preset communication mode can be Websocket communication, wherein Websocket is a protocol for full-duplex communication on a single TCP connection, which allows the server to actively push data to the client. In the Websocket API, the client can establish a connection with the server side, and exchange data on this connection.
[0080] Step S303: Determine the to-be-verified action corresponding to the to-be-identified user based on the action inference result.
[0081] It should be noted that the above-mentioned to-be-verified action can be an action for verifying whether the to-be-identified user is a living body, such as blinking, shaking head, etc., which is not limited in the present embodiment.
[0082] In practical applications, the device can efficiently manage camera resources through the media device component MediaDevice and the environment component Room, capture video streams in real time, and perform liveness detection on the to-be-identified user. In this process, the device can dynamically adjust the video quality to adapt to different network conditions, ensuring the smoothness and stability of video stream transmission. At the same time, real-time action inference can be performed using Websocket communication to guide the to-be-identified user to complete liveness verification actions such as blinking and shaking their head, thereby enhancing the accuracy and security of identification.
[0083] Step S304: performing face recognition detection on the to-be-identified user based on the to-be-verified action.
[0084] Further, the step S304 includes:
[0085] Step S304a: collecting a to-be-detected image corresponding to the to-be-identified user in real time.
[0086] It can be understood that the to-be-detected image can be an image in a real-time audio and video stream corresponding to the to-be-identified user, and the to-be-detected image can be used for liveness detection on the to-be-identified user.
[0087] Step S304b: adjusting the image background color of the to-be-detected image based on a color transformation sequence through a preset glare model to generate a glare effect corresponding to the to-be-detected image.
[0088] It should be noted that the preset glare model can be a model for evaluating the degree of glare of a light source. The present embodiment can distinguish real human faces from non-biological objects (such as photos and videos) by analyzing the reflection pattern and intensity in the image through the preset glare model. Since this technology relies on the reflection characteristics of the human eye and skin to specific wavelengths of light, these characteristics are relatively stable under various lighting conditions, so it can still work effectively under different lighting conditions. When the light source changes, the model can adjust its analysis threshold to adapt to changes in ambient light, so it can accurately perform liveness detection under any lighting conditions.
[0089] It should be noted that the color transformation sequence can be a sequence of color changes of the preset glare model. In the present embodiment, the color transformation sequence of the preset glare model can be defined by code in advance, so that the glare model can change the color of the image background or a specific region according to the color transformation sequence.
[0090] In practical applications, the preset glare model can sequentially change the background color of the to-be-detected image based on a pre-defined color transformation sequence, and switch to the next color after each color lasts for a period of time, thereby creating a visual glare effect for the to-be-detected image to stimulate different types of reflections, thereby helping the model to distinguish between true and false.
[0091] Step S304c: obtaining an inference result by inferring based on the glare effect through the preset glare model.
[0092] It should be noted that in the process of background color transformation of the to-be-detected image, the preset glare model can infer based on the glare reaction of the current frame to obtain an inference result. In this embodiment, the inference result refers to the conclusion drawn by the model based on the image data of the current frame, which indicates whether the current frame meets the requirements of live detection. Specifically, the inference result is a string code, such as '9999' indicating success, and other codes (such as '0001', '0008', '0009') representing various abnormalities or errors.
[0093] Step S304d: performing face recognition detection on the to-be-identified user based on the inference result and the to-be-verified action.
[0094] In this embodiment, the device can perform live detection on the user based on the inference result and the to-be-verified action performed by the user. If the inference result indicates the presence of real life characteristics (such as code returning 9999), the system considers the live detection successful; otherwise, if the inference result points to an abnormality (such as an unexpected code value), it is considered a failure.
[0095] In this embodiment, the device can use Websocket communication for glare inference to ensure accurate recognition under complex lighting conditions. Specifically, the device can dynamically adjust the prompt information according to the inference result, such as continuing the process if successful, or prompting the user to re-verify through Toast if failed, and recording error logs to provide data support for subsequent analysis and optimization.
[0096] Specifically, the step S304d includes: determining whether there is a real life characteristic in the to-be-detected image based on the inference result; if there is, obtaining a current execution action of the to-be-identified user in the to-be-detected image based on the feedback of the to-be-verified action; and comparing the current execution action with the to-be-verified action to perform face recognition detection on the to-be-identified user.
[0097] It is understood that the aforementioned currently executed action can be an action performed based on the prompt of the action to be verified. In this embodiment, depending on the inference result, the device can update the prompt information (such as action tips) on the user interface through code. For example, when the model successfully identifies a vital sign for the first time, it will display a prompt to allow the user to prepare for the next action steps. After seeing the prompt information, the user to be identified can execute the action to be verified. At this time, the device can obtain the user's currently executed action and compare it with the action to be verified. If the current executed action is the same as the action to be verified, it means that the liveness detection of the user to be identified has passed; if the current executed action is different from the action to be verified, it means that the liveness detection of the user to be identified has failed.
[0098] It should be noted that if the preset glare model encounters unexpected results during inference, the device can notify the user of verification failure via a Toast message and suggest that the user try again, thereby improving immediate feedback and guiding the user on how to continue. A Toast message is a small pop-up window that displays brief information in mobile applications or web pages; it is typically used to convey important information to the user, such as successful operation or error messages. Furthermore, in some cases, such as when an error occurs during inference, the system will retry, reinitializing the glare liveness detection process and giving the user another chance to verify.
[0099] In this embodiment, the system collects key event data, such as the success, failure, and timeout status of liveness verification, as well as user behavior data, through a data tracking toolkit, providing a basis for system performance monitoring and continuous optimization. Under specific circumstances (such as verification failure), the system automatically triggers a retry method to prepare to restart the verification process.
[0100] In the specific implementation, refer to Figure 3 , Figure 3 This is a schematic diagram of the overall process of the applicant's face recognition method. Figure 3As shown, after the application in the device is started, the getVideoHackToken and getSceneControlToken requests can be executed in parallel to obtain the video verification token and the network attack prevention control token. After the tokens are obtained in parallel, the createVideoHackRoom operation can be executed in series to securely establish a verification environment using the tokens, ensuring that the verification process is performed after all prerequisites are complete, balancing efficiency and security. Then, the device can execute the MediaDevice.create, Room.create, and initWebsocket operations in parallel to initialize the SDK device module, initialize the SDK room, and establish a WebSocket connection. Thereafter, the device can efficiently manage camera resources through components such as MediaDevice and Room, and capture video streams in real time to perform live detection on the user to be identified. During this process, the system dynamically adjusts video quality to adapt to different network conditions, ensuring the smoothness and stability of video stream transmission. At the same time, real-time action reasoning is performed using WebSocket communication to guide the user to complete live verification actions such as blinking and shaking, enhancing the accuracy and security of identification. In addition, a glare model reasoning can be introduced in this scheme to adapt to various lighting conditions, dynamically adjust the interaction prompt based on the reasoning result, and prompt the user to retry through Toast when necessary, and record error logs for analysis and optimization.
[0101] In this embodiment, it is disclosed that in the network attack prevention verification environment, real-time audio and video streams corresponding to the user to be identified are obtained in real time through media device components and environment components; during the process of obtaining real-time audio and video streams, real-time action reasoning is performed through a preset communication method; the action to be verified corresponding to the user to be identified is determined based on the action reasoning result; and face recognition detection is performed on the user to be identified based on the action to be verified, so as to ensure the accuracy and security of face recognition.
[0102] Based on the first and / or second embodiments of the present application, in the third embodiment of the present application, the same or similar contents as the above embodiments can refer to the above introduction, and will not be repeated hereinafter. On this basis, please refer to Figure 4 , Figure 4 The flowchart provided for the third embodiment of the face recognition method of the present application.
[0103] In this embodiment, the face recognition method further includes steps S100-S400:
[0104] Step S100: When detecting network connection abnormity, triggering network connection retry request.
[0105] It should be noted that the network connection retry request described above can be a request for instructing the device to perform network reconnection. In the WebSocket communication, the device can monitor the network state and data transmission in real time, and trigger error handling logic such as retry or notify the user as soon as an abnormal event is encountered, thereby ensuring the continuity and stability of the verification process. In this embodiment, through the automatic error detection and processing logic, the network environment can be dynamically adapted, the network state can be monitored in real time, and the retry or preset strategy can be automatically executed, thereby ensuring the continuity of the process.
[0106] Step S200: Real-time acquisition of the current network connection retry count by the retry counter.
[0107] It can be understood that the retry counter described above can be a counter for counting the number of retries of network connection. Correspondingly, the current network connection retry count described above can be the number of network reconnections performed by the current device as counted by the retry counter.
[0108] Step S300: Determine whether the current network connection retry count exceeds a preset retry count threshold.
[0109] It should be understood that the preset retry count threshold described above can be a maximum allowed retry count.
[0110] In actual application, when encountering some specific errors, such as receiving an RTMP connection abnormal error code, which usually indicates that the RTMP connection has a problem, which can be caused by unstable network, server failure or other communication problems. At this time, a retry mechanism can be added: first, define a retry counter retryCount, and check whether the maximum allowed retry count (i.e. the preset retry count threshold described above) is exceeded before each retry, then use setTimeout or other asynchronous functions to delay the retry, so as to avoid initiating requests continuously at the same time, which helps to reduce server pressure and improve success rate, finally, in the retry logic, the error code is also considered for filtering, that is, only the recoverable errors are retried, and the permanent errors are directly returned as failed. In addition, the removeAllTimer method can be used to clear all timers and intervals in this embodiment, so as to avoid memory leakage and unnecessary background activities. This is especially important when the component is unloaded or the route is left, so as to ensure that all resources are properly released. At the same time, state variables and conditional statements can also be used to control the process, so as to ensure that only one state is processed at the same time, thereby avoiding concurrent state conflicts.
[0111] Step S400: If yes, switch the current display page to the network connection abnormal page.
[0112] It should be noted that the network connection exception page can be a page displaying prompt information of network connection exception. In actual application, if the network reconnection operation of the device fails, the currently displayed page can be switched to the network connection exception page for abnormal prompt.
[0113] Further, before the step S10, the method further includes: determining a task running environment corresponding to the current face recognition task according to preset identification information.
[0114] It should be noted that the preset identification information can be identification for identifying the current task running environment; the task running environment is an environment for running the current face recognition task, and the task running environment in the embodiment can include an H5 environment and a small program environment. In the embodiment, the preset identification information can be set as isXCX to determine whether the current task running environment is a small program environment through isXCX. Specifically, the getQueryString('isXCX') function can be used to read the query parameter in the URL, if the parameter isXCX exists and the value is true, it is determined that the current environment is a small program Webview environment; if the parameter isXCX exists and the value is false, it is determined that the current environment is a normal H5 environment.
[0115] Correspondingly, the step S400 includes: if yes, determining a page switching strategy based on the task running environment; and switching the currently displayed page to a network connection exception page based on the page switching strategy.
[0116] It should be understood that the page switching strategy is a strategy adopted when the currently displayed page is switched. In the embodiment, for the H5 environment, 'window.location.replace' can be used for page jump or back; for the small program environment, 'wx.miniProgram.navigateBack' can be used for page jump or back. In actual application, in the H5 environment, error handling can cause the page to jump to another URL, which can use 'window.location.replace'; however, in the small program environment, 'wx.miniProgram.navigateBack' or 'wx.miniProgram.postMessage' is used to send a message to the main process of the small program.
[0117] In this embodiment, a real-time user interface can be designed in the device, including action instructions, state prompts and progress bars, to ensure that the user can clearly understand the verification progress. The progress is automatically updated through the real-time updating progress bar method, which can give the user positive feedback even in long waiting time, optimizing the user experience. At the same time, through the real-time interactive feedback mechanism, the user can master the verification state throughout the process, and positive feedback can be provided even when the network is unstable.
[0118] In addition, the present scheme can also design an environment adaptive module to identify the running environment according to the isXCX flag, dynamically adjust the strategy to adapt to the H5 or applet Webview environment, and ensure the correct execution and experience consistency of the face recognition process. Specifically, for browser compatibility: H5 pages need to consider the support of multiple browsers, including Chrome, Firefox, Safari, etc.; while applets do not need to consider other browser compatibility issues. For API calling differences: H5 pages use standard Web APIs such as fetch, localStorage, etc.; while applets have their own set of APIs, such as: wx.miniProgram.postMessage and wx.miniProgram.navigateBack, for message passing and page jumping; for API specificity: applets use proprietary APIs such as 'wx.*' series functions, which provide deep integration with WeChat platform functions such as positioning, opening the camera, etc. For life cycle management: applets have their own unique life cycle management mechanism, such as: 'onLoad', 'onReady', 'onHide', 'onUnload', etc. These life cycle functions can be used to perform initialization and cleanup operations in specific environments. For performance optimization: the rendering mechanism of applet webview opening H5 is different from that of ordinary browsers opening H5, and performance optimization needs to be done for its characteristics, such as communication between WebView and applets through postMessage and onmessage to avoid performance loss caused by frequent communication, etc. Therefore, when performing face recognition, the platform type can be identified through the initial environment detection step, and the initialization, face recognition logic, error handling and user feedback process suitable for the platform can be automatically executed.
[0119] In the embodiment, a unified API call adaptation layer can be constructed to dynamically call appropriate API interfaces according to different platforms, cover functions such as user authorization, video stream processing, network communication, and realize seamless docking of cross-platform functions. At the same time, a data reporting and monitoring module can be set up to collect user behavior, verification results and system performance data across platforms, guarantee service quality and safety, and promote continuous optimization of the system. In addition, a dynamic resource loading strategy can be implemented to load adaptive UI components and resources according to platform characteristics, optimize loading efficiency, and ensure the consistency of the interface on each platform. Among them, the scheme implements unified security protection measures in H5 and applet environments, including data encryption, interface access control and exception handling, to ensure that user privacy and overall system security are not affected by the platform.
[0120] In the embodiment, it is disclosed that when a network connection exception is detected, a network connection retry request is triggered; the current network connection retry number is obtained in real time through a retry counter; it is judged whether the current network connection retry number exceeds a preset retry number threshold; if yes, the current display page is switched to a network connection exception page, so that a retry can be triggered when an exception event is encountered, and the continuity and stability of the verification process are guaranteed.
[0121] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the face recognition method of the present application. Based on this technical concept, more forms of simple transformation are within the protection scope of the present application.
[0122] The present application also provides a face recognition device, please refer to Figure 5 , the face recognition device comprises:
[0123] The token acquisition module 10 is configured to acquire the video verification token and the network attack prevention control token simultaneously in a parallel processing manner;
[0124] The verification environment creation module 20 is configured to create a network attack prevention verification environment based on the video verification token and the network attack prevention control token in a serial processing manner when the acquisition is successful;
[0125] The face detection module 30 is configured to perform face recognition detection on the to-be-identified user based on the real-time audio and video stream corresponding to the to-be-identified user in the network attack prevention verification environment.
[0126] The face recognition device provided by the present application adopts the face recognition method in the above embodiments, and can solve the technical problems of slow authentication speed and vulnerability to network attacks when face recognition is performed in the H5 and applet environments in the prior art. Compared with the prior art, the face recognition device provided by the present application has the same beneficial effects as the face recognition method provided by the above embodiments, and other technical features in the face recognition device are the same as the features disclosed in the above embodiments, which will not be repeated here.
[0127] The present application provides a face recognition device, which comprises at least one processor and a memory connected with the at least one processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the face recognition method in Embodiment I.
[0128] Reference will be made to the following description Figure 6 , which shows a structural diagram of a face recognition device suitable for implementing the embodiments of the present application. The face recognition device in the embodiments of the present application can include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (Personal Digital Assistant), PADs (Portable Application Description), PMPs (Portable Media Player), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. Figure 6 The face recognition device shown is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.
[0129] As Figure 6As shown, the face recognition device can include a processing device 1001 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to programs stored in a read only memory (ROM) 1002 or loaded from a storage device 1003 into a random access memory (RAM) 1004. In the RAM 1004, various programs and data required for the operation of the face recognition device are also stored. The processing device 1001, the ROM 1002, and the RAM 1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; the storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the face recognition device to communicate with other devices wirelessly or by wire to exchange data. Although the face recognition device with various systems is shown in the figure, it should be understood that all the shown systems are not required to be implemented or possessed. More or less systems can be alternatively implemented or possessed.
[0130] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program codes for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network through the communication device, or installed from the storage device 1003, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the methods of the embodiments disclosed in the present application are performed.
[0131] The face recognition device provided in the present application adopts the face recognition method in the above-mentioned embodiments, and can solve the technical problem of face recognition. Compared with the prior art, the face recognition device provided in the present application has the same beneficial effects as the face recognition method provided in the above-mentioned embodiments, and other technical features in the face recognition device are the same as the features disclosed in the previous embodiment method, which will not be repeated here.
[0132] It should be understood that various aspects of the disclosure can be implemented in hardware, software, firmware, or combinations thereof, to achieve the various aspects of the disclosure. In the description above, specific features, structures, materials or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0133] The above description is merely illustrative of the application and is not intended to limit the scope of the application. Any modifications or equivalents of the application should be construed as falling within the scope of the application. The scope of the application should be determined by the appended claims.
[0134] The application provides a computer readable storage medium having computer readable program instructions (i.e., computer programs) stored thereon, the computer readable program instructions being used to perform the face recognition method in the above-described embodiments.
[0135] The computer readable storage medium provided by the application may, for example, be a U disk, but is not limited to an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination of the above. More specific examples of the computer readable storage medium can include, but are not limited to, an electric connection with one or more conductive wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present embodiment, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer readable storage medium can be transmitted by any suitable medium, including but not limited to an electric wire, an optical cable, an RF (Radio Frequency), etc., or any suitable combination of the above.
[0136] The above computer readable storage medium can be contained in a face recognition device; or can exist separately and not be assembled into a face recognition device.
[0137] The computer readable storage medium described above carries one or more programs, when the one or more programs are executed by the face recognition device, the face recognition device: adopts a parallel processing mode to simultaneously acquire a video verification token and a network attack prevention control token; when acquisition is successful, creates a network attack prevention verification environment based on the video verification token and the network attack prevention control token through a serial processing mode; and in the network attack prevention verification environment, performs face recognition detection on a to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user.
[0138] Computer program code for carrying out operations of the present application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0139] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present application. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flow diagrams, and combinations thereof, can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or combinations of special purpose hardware and computer instructions.
[0140] The modules involved in the embodiments of the present application can be implemented in a software manner or in a hardware manner. In some cases, the name of the module does not constitute a limitation on the module itself.
[0141] The readable storage medium provided by the present application is a computer readable storage medium, which stores computer readable program instructions (i.e. computer programs) for executing the above face recognition method, and can solve the technical problems of slow authentication speed and vulnerability to network attacks in the prior art when face recognition is performed in the H5 and applet environment. Compared with the prior art, the computer readable storage medium provided by the present application has the same beneficial effects as the face recognition method provided by the above embodiments, which will not be repeated here.
Claims
1. A face recognition method, characterized by, The method comprises: adopting a parallel processing mode to simultaneously acquire a video verification token and a network attack prevention control token; when acquisition is successful, creating a network attack prevention verification environment based on the video verification token and the network attack prevention control token through a serial processing mode; in the network attack prevention verification environment, performing face recognition detection on a to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user; the step of performing face recognition detection on the to-be-identified user based on the real-time audio and video stream corresponding to the to-be-identified user in the network attack prevention verification environment comprises: in the network attack prevention verification environment, acquiring a real-time audio and video stream corresponding to a to-be-identified user through a media device component and an environment component; in the process of acquiring the real-time audio and video stream, performing real-time action inference through a preset communication mode; determining a to-be-verified action corresponding to the to-be-identified user based on the action inference result, the to-be-verified action being an action for verifying whether the to-be-identified user is a living body; real-time collection of a to-be-detected image corresponding to the to-be-identified user; adjusting an image background color of the to-be-detected image based on a color transformation sequence through a preset glint model to generate a glint effect corresponding to the to-be-detected image, the preset glint model distinguishing a real human face from a non-biological object by analyzing reflection patterns and intensities in the to-be-detected image; performing inference based on the glint effect through the preset glint model to obtain an inference result, the inference result being used to indicate whether the to-be-detected image meets a living body detection requirement; performing face recognition detection on the to-be-identified user based on the inference result and the to-be-verified action.
2. The method of claim 1, wherein, the step of creating a network attack prevention verification environment based on the video verification token and the network attack prevention control token through a serial processing mode when acquisition is successful comprises: when acquisition is successful, creating a secure verification room through a serial processing mode by calling a preset verification environment creation function; joining the secure verification room based on the video verification token and the network attack prevention control token to create a network attack prevention verification environment.
3. The method of claim 2, wherein, the step of performing face recognition detection on the to-be-identified user based on the inference result and the to-be-verified action comprises: judging whether there is a real life feature in the to-be-detected image based on the inference result; if there is, acquiring a current execution action of the to-be-identified user in the to-be-detected image based on feedback of the to-be-verified action; comparing the current execution action with the to-be-verified action to perform face recognition detection on the to-be-identified user.
4. The method of any one of claims 1 to 3, wherein, The method further comprises: when a network connection exception is detected, triggering a network connection retry request; real-time acquisition of a current network connection retry number through a retry counter; judging whether the current network connection retry number exceeds a preset retry number threshold; if yes, switching a current display page to a network connection exception page.
5. The method of claim 4, wherein, before the step of adopting a parallel processing mode to simultaneously acquire a video verification token and a network attack prevention control token, the method further comprises: determining a task running environment corresponding to a current face recognition task according to preset identification information; If yes, the step of switching the current display page to the network connection exception page comprises: If yes, determining a page switching strategy based on the task running environment; Switching the current display page to the network connection exception page based on the page switching strategy.
6. A face recognition apparatus characterized by comprising: The device comprises: A token acquisition module configured to acquire a video verification token and a network attack prevention control token simultaneously in a parallel processing manner; An environment creation module configured to create a network attack prevention verification environment in a serial processing manner based on the video verification token and the network attack prevention control token when the acquisition is successful; A face detection module configured to perform face recognition detection on a to-be-identified user based on a real-time audio and video stream corresponding to the to-be-identified user in the network attack prevention verification environment; The face detection module is further configured to acquire the real-time audio and video stream corresponding to the to-be-identified user in the network attack prevention verification environment through a media device component and an environment component, perform real-time action inference through a preset communication manner during the acquisition of the real-time audio and video stream, determine a to-be-verified action corresponding to the to-be-identified user based on the action inference result, the to-be-verified action being an action for verifying whether the to-be-identified user is a living body, acquire a to-be-detected image corresponding to the to-be-identified user in real time, adjust an image background color of the to-be-detected image based on a color transformation sequence through a preset glint model to generate a glint effect corresponding to the to-be-detected image, the preset glint model distinguishing real human faces from non-biological objects by analyzing reflection patterns and intensities in the to-be-detected image, performing inference based on the glint effect through the preset glint model to obtain an inference result, the inference result being used to indicate whether the to-be-detected image meets a living body detection requirement, and performing face recognition detection on the to-be-identified user based on the inference result and the to-be-verified action.
7. A face recognition device, characterized by, The device comprises a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being configured to implement the steps of the face recognition method according to any one of claims 1 to 5.
8. A storage medium, characterized by The storage medium is a computer-readable storage medium, and the storage medium stores a computer program, the computer program being executable by a processor to implement the steps of the face recognition method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Face recognition method and device, mobile terminal and storage medium
CN108596061A
Page request processing method and device
CN112751878A
Face living body detection method and device and electronic equipment
CN115082995A
Network attack defense method, server and client
CN116155524A