Face recognition method and device, equipment and storage medium
By obtaining video verification tokens and anti-network attack control tokens in parallel, and creating anti-network attack verification environments in H5 and applet environments, it solves the problem of slow face recognition authentication and vulnerability to network attacks, and achieves rapid and A safe authentication process.
Patent Information
- Application Number
- CN202411385446.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-09-30
AI Technical Summary
In H5 and applet environments, facial recognition authentication is slow and vulnerable to cyber attacks, resulting in poor user experience.
The video verification token and anti-network attack control token are obtained simultaneously in parallel processing. After successful acquisition, it creates an anti-network attack verification environment through serial processing, and face recognition detection is performed in this environment.
Improve the speed and security of facial recognition authentication, prevent network attacks, and improve user experience.
Smart Images

Figure CN119254496A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of face recognition technology, and in particular to face recognition methods, devices, equipment and storage media. Background Art
[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, it is accompanied by many challenges in the field of online face recognition, such as slow authentication, vulnerability to network attacks, and poor user experience. Especially in the H5 and mini-program environments, how to quickly complete face recognition verification while ensuring data security has become a key issue that needs to be solved urgently.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of this application is to provide a face recognition method, device, equipment and storage medium, aiming to solve the technical problems in the prior art of slow authentication speed and vulnerability to network attacks when performing face recognition in H5 and mini-program environments.
[0005] To achieve the above purpose, the present application proposes a face recognition method, which comprises:
[0006] A parallel processing method is used to simultaneously obtain a video verification token and an anti-network attack control token;
[0007] When the acquisition is successful, based on the video verification token and the anti-network attack control token, an anti-network attack verification environment is created by serial processing;
[0008] In the anti-network attack verification environment, face recognition detection is performed on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified.
[0009] In one embodiment, when the acquisition is successful, the step of creating an anti-network attack verification environment by serial processing based on the video verification token and the anti-network attack control token includes:
[0010] When the acquisition is successful, the preset verification environment creation function is called in a serial processing manner to create a security verification room;
[0011] Join the security verification room based on the video verification token and the anti-network attack control token to create an anti-network attack verification environment.
[0012] In one embodiment, the step of performing face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified in the anti-network attack verification environment includes:
[0013] In the anti-network attack verification environment, real-time audio and video streams corresponding to the user to be identified are obtained in real time through the media device component and the environment component;
[0014] In the process of acquiring the real-time audio and video stream, real-time action reasoning is performed through a preset communication method;
[0015] Determine the action to be verified corresponding to the user to be identified based on the action reasoning result;
[0016] Perform face recognition detection on the user to be identified based on the action to be verified.
[0017] In one embodiment, the step of performing face recognition detection on the user to be identified based on the action to be verified includes:
[0018] Collecting the image to be detected corresponding to the user to be identified in real time;
[0019] Adjusting the image background color of the image to be detected based on a color transformation sequence by using a preset glare model to generate a glare effect corresponding to the image to be detected;
[0020] Performing reasoning based on the glare effect through the preset glare model to obtain a reasoning result;
[0021] Based on the inference result and the action to be verified, face recognition detection is performed on the user to be identified.
[0022] In one embodiment, the step of performing face recognition detection on the user to be identified based on the inference result and the action to be verified includes:
[0023] Determining whether there is a real life feature in the image to be detected based on the inference result;
[0024] If so, obtaining the current execution action of the user to be identified in the image to be detected based on the feedback of the action to be verified;
[0025] The currently executed action is compared with the action to be verified to perform face recognition detection on the user to be identified.
[0026] In one embodiment, the method further comprises:
[0027] When a network connection anomaly is detected, a network connection retry request is triggered;
[0028] Get the current number of network connection retries in real time through the retry counter;
[0029] Determine whether the current network connection retry count exceeds a preset retry count threshold;
[0030] If yes, the current display page is switched to the network connection abnormality page.
[0031] In one embodiment, before the step of simultaneously acquiring the video verification token and the anti-network attack control token in a parallel processing manner, the method further includes:
[0032] Determine the task running environment corresponding to the current face recognition task according to the preset identification information;
[0033] If yes, the step of switching the current display page to the network connection abnormality page includes:
[0034] If yes, determining a page switching strategy based on the task running environment;
[0035] The current display page is switched to the network connection abnormality page based on the page switching strategy.
[0036] In addition, to achieve the above purpose, the present application also proposes a face recognition device, the device comprising:
[0037] A token acquisition module, used to simultaneously acquire a video verification token and an anti-network attack control token in a parallel processing manner;
[0038] A verification environment creation module, used to create an anti-network attack verification environment through serial processing based on the video verification token and the anti-network attack control token when the acquisition is successful;
[0039] The face detection module is used to perform face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified in the anti-network attack verification environment.
[0040] In addition, to achieve the above-mentioned purpose, the present application also proposes a face recognition device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the face recognition method 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 a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the face recognition method described above are implemented.
[0042] The present application provides a face recognition method, which discloses the use of parallel processing to simultaneously obtain a video verification token and an anti-network attack control token; when the acquisition is successful, an anti-network attack verification environment is created through a serial processing method based on the video verification token and the anti-network attack control token; in the anti-network attack verification environment, face recognition detection is performed on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified; because the present invention creates an anti-network attack verification environment based on the video verification token and the anti-network attack control token and through a serial processing method when the video verification token and the anti-network attack control token are successfully acquired, face recognition detection can be performed in the anti-network attack verification environment, thereby solving the technical problems in the prior art of slow authentication speed and vulnerability to network attacks when performing face recognition in H5 and mini-program environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0045] Figure 1 A schematic diagram of a flow chart provided for the first embodiment of the face recognition method of the present application;
[0046] Figure 2 A schematic diagram of the flow chart provided for the second embodiment of the face recognition method of the present application;
[0047] Figure 3 This is a schematic diagram of the overall process of the face recognition method of the present application;
[0048] Figure 4 A flowchart of the third embodiment of the face recognition method of the present application is provided;
[0049] Figure 5 This is a schematic diagram of the module structure of the face recognition device according to an embodiment of the present application;
[0050] Figure 6 Schematic diagram of the device structure of the hardware operating environment involved in the face recognition method in the embodiment of the present application.
[0051] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0053] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0054] The main solution of the embodiment of the present application is: using parallel processing to simultaneously obtain the video verification token and the anti-network attack control token; when the acquisition is successful, based on the video verification token and the anti-network attack control token, create an anti-network attack verification environment through serial processing; in the anti-network attack verification environment, perform face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified.
[0055] Due to the many challenges faced by existing technologies in the field of online face recognition in H5 and mini-program environments, such as slow authentication, vulnerability to network attacks, and poor user experience.
[0056] The present application provides a solution, which can create an anti-network attack verification environment based on the video verification token and the anti-network attack control token and through serial processing when the video verification token and the anti-network attack control token are successfully obtained, so that face recognition detection can be performed in the anti-network attack verification environment, thereby solving the technical problems in the prior art that the authentication speed is slow and vulnerable to network attacks when performing face recognition in H5 and mini-program environments.
[0057] It should be noted that the execution subject of this 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 capable of realizing the above functions, a face recognition device, etc. The following takes the face recognition device as an example (hereinafter referred to as the device) to illustrate this embodiment and the following embodiments.
[0058] Based on this, the present application embodiment provides a face recognition method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the face recognition method of the present application.
[0059] In this embodiment, the face recognition method includes steps S10 to S30:
[0060] Step S10: Acquire the video verification token and the anti-network attack control token simultaneously by parallel processing.
[0061] It should be understood that the above parallel processing method can be a method of simultaneously executing the operations of obtaining a video verification token and an anti-network attack control token. Among them, the video verification token can be a token used to authorize a device to obtain or access a video; the anti-network attack control token can be a token used to authorize a device to perform scene control. In this embodiment, a strict anti-Hack strategy can be implemented through the obtained anti-network attack control token sceneControlToken to prevent external malicious intrusion.
[0062] In this embodiment, when the application in the device is started, it is initialized after the component is mounted to perform necessary parameter preprocessing, including user tracking and operating environment (such as H5 environment, mini-program environment, etc., which are not limited in this embodiment). Then, the getVideoHackToken and getSceneControlToken requests can be executed in parallel to obtain the video verification token and the anti-network attack control token at the same time, thereby speeding up the initialization process and laying the foundation for the experience of opening in seconds. By obtaining the video verification token and the anti-network attack control token in parallel, this embodiment can greatly shorten the waiting time from system startup to verification readiness, thereby improving the authentication speed of subsequent face recognition.
[0063] Step S20: When the acquisition is successful, an anti-network attack verification environment is created through serial processing based on the video verification token and the anti-network attack control token.
[0064] It can be understood that the above serial processing method can be a method in which the operation of creating an environment is performed after the operation of obtaining the video verification token and the anti-network attack control token is performed.
[0065] It should be noted that the above-mentioned anti-network attack verification environment can be a safe verification environment, which can prevent network attacks. In this embodiment, by performing face recognition verification in the anti-network attack verification environment, hack attacks can be prevented during the verification process, thereby ensuring the security of face recognition.
[0066] It should be noted that in this embodiment, after obtaining the video verification token and the anti-network attack control token in parallel, the operation of creating the anti-network attack verification environment is performed serially, so that the verification environment can be safely established using the token, ensuring the security of the verification environment, and at the same time ensuring that the verification process is carried out after all prerequisites are met, preventing the potential security risks caused by parallel operations, and taking into account the efficiency and security of face recognition. This solution combines parallel and serial processing mechanisms to achieve a balance between process optimization and effective resource utilization, ensuring both rapid response and maintaining system security.
[0067] Specifically, the step S20 includes: when the acquisition is successful, calling a preset verification environment creation function through serial processing to create a security verification room; joining the security verification room based on the video verification token and the anti-network attack control token to create an anti-network attack verification environment.
[0068] It should be understood that the above-mentioned preset verification environment creation function may be a function for creating a room for security verification, and the verification environment creation function in this embodiment may be a createVideoHackRoom function.
[0069] In this embodiment, using asynchronous programming technology, the device can simultaneously initiate getVideoHackToken and getSceneControlToken requests to obtain the video verification token and the anti-network attack control token at the same time. These two operations are performed in parallel, greatly reducing the waiting time. Once the token is successfully acquired, the createVideoHackRoom function can be called immediately to create a secure verification room and build an anti-Hack verification environment, that is, the above-mentioned anti-network attack verification environment. This stage realizes the foundation of the second-opening experience, ensuring that users can quickly enter the verification process with almost no perception.
[0070] Step S30: In the anti-network attack verification environment, face recognition detection is performed on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified.
[0071] It is understandable that the user to be identified is the user for face recognition this time. After the anti-network attack verification environment is created, the device can capture the audio and video stream corresponding to the user to be identified in real time in the anti-network attack verification environment, and perform face recognition on the user based on the audio and video stream in the anti-network attack verification environment. At this time, the user face recognition verification process is carried out in a strictly controlled environment, which improves the security level of anti-hack.
[0072] The present embodiment provides a face recognition method, which discloses the use of parallel processing to simultaneously acquire a video verification token and an anti-network attack control token; when the acquisition is successful, an anti-network attack verification environment is created through serial processing based on the video verification token and the anti-network attack control token; in the anti-network attack verification environment, face recognition detection is performed on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified; because the present embodiment creates an anti-network attack verification environment based on the video verification token and the anti-network attack control token and through serial processing when the video verification token and the anti-network attack control token are successfully acquired, face recognition detection can be performed in the anti-network attack verification environment, thereby solving the technical problems in the prior art of slow authentication speed and vulnerability to network attacks when performing face recognition in H5 and mini-program environments.
[0073] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 2 , Figure 2 This is a flow chart of the second embodiment of the face recognition method provided by the present application.
[0074] In this embodiment, step S30 includes steps S301 to S304:
[0075] Step S301: In the anti-network attack verification environment, the real-time audio and video stream corresponding to the user to be identified is obtained in real time through the media device component and the environment component.
[0076] It should be noted that the above media device component may be a component for managing media devices, and in this embodiment, the device may manage camera resources by calling the media device component, thereby capturing video streams in real time. The above environment component may be a component for managing a 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 user to be identified collected in real time by the camera.
[0078] Step S302: In the process of acquiring the real-time audio and video stream, real-time action reasoning is performed through a preset communication method.
[0079] In this 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 and exchange data on this connection.
[0080] Step S303: Determine the action to be verified corresponding to the user to be identified based on the action reasoning result.
[0081] It should be noted that the above-mentioned action to be verified may be an action used to verify whether the user to be identified is alive, such as blinking, shaking head, etc., and this embodiment does not impose any limitation on this.
[0082] In actual 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 user to be identified. In this process, the device can dynamically adjust the video quality to adapt to different network conditions to ensure the smoothness and stability of video stream transmission. At the same time, Websocket communication can be used for real-time action reasoning to guide the user to be identified to complete liveness verification actions, such as blinking and shaking his head, to enhance the accuracy and security of recognition.
[0083] Step S304: performing face recognition detection on the user to be identified based on the action to be verified.
[0084] Furthermore, the step S304 includes:
[0085] Step S304a: collecting the image to be detected corresponding to the user to be identified in real time.
[0086] It can be understood that the above-mentioned image to be detected can be a frame of image in the real-time audio and video stream corresponding to the identified user, and the image to be detected can be used to perform liveness detection on the user to be identified.
[0087] Step S304b: adjusting the image background color of the image to be detected based on a color transformation sequence by using a preset glare model to generate a glare effect corresponding to the image to be detected.
[0088] It should be noted that the above-mentioned preset glare model can be a model for evaluating the degree of glare of a light source. This embodiment can distinguish real human faces from non-biological objects (such as photos, 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 light of a specific wavelength, these characteristics are relatively stable under various lighting conditions, so that it can still work effectively under different lighting conditions. When the light source changes, the model can adjust its analysis threshold to adapt to the changes in ambient light, so that liveness detection can be accurately performed under any lighting conditions.
[0089] It should be noted that the color change sequence may be a sequence of changing the color of the picture by a preset glare model. In this embodiment, the color change sequence of the preset glare model may be predefined by code so that the glare model can change the color of the image background or a specific area according to the color change sequence.
[0090] In practical applications, the preset glare model can change the background color of the image to be detected in sequence based on a predefined color change sequence, and switch to the next color after each color lasts for a period of time, thereby creating a visual glare effect for the image to be detected to stimulate different types of reflections, thereby helping the model to distinguish between authenticity.
[0091] Step S304c: performing reasoning based on the glare effect using the preset glare model to obtain a reasoning result.
[0092] It should be noted that, in the process of background color change of the image to be detected, the preset glare model can be inferred 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 liveness detection. Specifically, the inference result is a string code, such as '9999' indicates success, while other codes (such as '0001', '0008', '0009') represent various exceptions or errors.
[0093] Step S304d: performing face recognition detection on the user to be identified based on the inference result and the action to be verified.
[0094] In this embodiment, the device can perform liveness detection on the user based on the inference result and the action to be verified performed by the user. If the inference result indicates the existence of real life characteristics (such as the code returns 9999), the system will consider the liveness detection successful; otherwise, if the inference result points to an abnormality (such as an unexpected code value), it will be considered a failure.
[0095] In this embodiment, the device can use Websocket communication to perform glare inference to ensure accurate recognition under complex lighting conditions. Specifically, the device can dynamically adjust the prompt information according to the inference result. If successful, the process continues. If failed, a Toast prompts the user to re-verify and records the error log to provide data support for subsequent analysis and optimization.
[0096] Specifically, the step S304d includes: judging whether there are real life features in the image to be detected based on the reasoning result; if so, obtaining the current execution action of the user to be identified in the image to be detected based on the feedback of the action to be verified; comparing the current execution action with the action to be verified to perform face recognition detection on the user to be identified.
[0097] It is understandable that the above-mentioned currently executed action can be an action executed according to the prompt of the action to be verified. In this embodiment, depending on the reasoning results, the device can update the prompt information (such as action prompts actionTips) on the user interface through code. For example, when the model successfully recognizes the life feature for the first time, a prompt will be displayed to let the user prepare for the next action step. After seeing the prompt information, the user to be identified can perform the action to be verified. At this time, the device can obtain the current execution action of the user to be identified, and compare the current execution action with the action to be verified. If the current execution 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 execution 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 an unexpected result is encountered during the reasoning process of the preset glare model, the device can notify the user of the verification failure through a Toast message and suggest that the user try again, thereby improving instant feedback to guide the user on how to continue the operation. Among them, a Toast message is a small pop-up window that displays brief information in a mobile application or web page. It is usually used to convey important information to the user, such as successful operation, error prompts, etc. In addition, in some cases, such as an error in the reasoning process, it will trigger a system retry, reinitialize the glare liveness detection process, and give the user a chance to verify again.
[0099] In this embodiment, through the tracking toolkit, the system collects key event data, such as the success, failure, timeout and other status of liveness verification, as well as user behavior data, to provide a basis for system performance monitoring and continuous optimization. In certain cases (such as verification failure), the system automatically triggers the retry method and prepares to restart the verification process.
[0100] In the specific implementation, refer to Figure 3 , Figure 3 FIG. 1 is a schematic diagram of the overall flow of the face recognition method of this application. Figure 3As shown in the figure, 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 anti-network attack control token. After obtaining the tokens in parallel, the createVideoHackRoom operation can be executed in series to securely establish the verification environment using the tokens, ensuring that the verification process is carried out after all prerequisites are met, taking into account both efficiency and security. Then, the device can execute the MediaDevice.create, Room.create, and initWebsocket operations in parallel to implement the SDK initialization device module, SDK initialization room, and establishment of Websocket connection. After that, the device can efficiently manage camera resources through components such as MediaDevice and Room, and capture video streams in real time to perform liveness detection on the user to be identified. In this process, the system dynamically adjusts the video quality to adapt to different network conditions to ensure the smoothness and stability of video stream transmission. At the same time, Websocket communication is used for real-time action reasoning to guide users to complete liveness verification actions, such as blinking and shaking their heads, to enhance the accuracy and security of recognition. In addition, glare model reasoning can be introduced in this solution to adapt to various lighting conditions, dynamically adjust the interactive prompts based on the reasoning results, 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 an anti-network attack 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; in the process of obtaining the real-time audio and video streams, real-time action reasoning is performed through a preset communication method; based on the action reasoning result, the action to be verified corresponding to the user to be identified is determined; based on the action to be verified, face recognition detection is performed on the user to be identified, thereby ensuring the accuracy and security of face recognition.
[0102] Based on the first embodiment and / or the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 4 , Figure 4 This is a flow chart of the third embodiment of the face recognition method provided by the present application.
[0103] In this embodiment, the face recognition method further includes steps S100 to S400:
[0104] Step S100: When a network connection abnormality is detected, a network connection retry request is triggered.
[0105] It should be noted that the above-mentioned network connection retry request can be a request for instructing the device to reconnect to the network. In the WebSocket communication of this embodiment, the device can monitor the network status and data transmission in real time. Once an abnormal event occurs, the error handling logic is immediately triggered, such as retrying or notifying the user, to ensure the continuity and stability of the verification process. In this embodiment, through the automated error detection and processing logic, it can dynamically adapt to changes in the network environment, monitor the network status in real time, automatically perform retries or adopt preset strategies to ensure the continuity of the process.
[0106] Step S200: obtaining the current network connection retry times in real time through a retry counter.
[0107] It is understandable that the retry counter may be a counter for counting the number of network connection retries. Accordingly, the current network connection retry number may be the number of network reconnections performed by the current device obtained by counting the number of network retry attempts of 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 above-mentioned preset retry number threshold may be a preset maximum allowed retry number.
[0110] In practical applications, when encountering certain specific errors, such as receiving an abnormal RTMP connection error code, it usually indicates that there is a problem with the RTMP connection, which may be caused by network instability, 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 number of retries (i.e., the above-mentioned preset number of retries threshold) is exceeded before each retry, and then setTimeout or other asynchronous functions are used to delay the retry to avoid continuously initiating requests at the same time point, which helps to reduce server pressure and improve success rate. Finally, in the retry logic, the filtering of error codes is also considered, that is, only recoverable errors are retried, and failure is directly returned for permanent errors. In addition, the removeAllTimer method can be used in this embodiment to clear all timers and intervals to avoid memory leaks and unnecessary background activities. This is especially important when components are uninstalled or routes leave, to ensure that all resources are properly released. At the same time, the process can also be controlled by state variables and conditional statements to ensure that only one state is processed at the same time to avoid concurrent state conflicts.
[0111] Step S400: If yes, switch the current display page to the network connection abnormality page.
[0112] It should be noted that the above network connection abnormality page may be a page showing prompt information of network connection abnormality. In actual application, if the network reconnection operation of the device fails, the currently displayed page may be switched to the network connection abnormality page to provide abnormal prompt.
[0113] Furthermore, before 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 above-mentioned preset identification information can be an identifier for identifying the current task running environment; the above-mentioned task running environment is the environment for running the current face recognition task. The task running environment in this embodiment may include an H5 environment and a mini-program environment. In this embodiment, the preset identification information can be set to isXCX to determine whether the current task running environment is a mini-program environment through isXCX. Specifically, the query parameters in the URL can be read through the getQueryString('isXCX') function. If the parameter isXCX exists and the value is true, the current environment is determined to be a mini-program Webview environment; if the parameter isXCX exists and the value is false, the current environment is determined to be 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 current display page to a network connection abnormality page based on the page switching strategy.
[0116] It should be understood that the page switching strategy is the strategy used when switching the currently displayed page. In this embodiment, for the H5 environment, 'window.location.replace' can be used to jump or roll back the page; for the mini program environment, 'wx.miniProgram.navigateBack' can be used to jump or roll back the page. In actual applications, in the H5 environment, error handling may cause the page to jump to another URL, which can use 'window.location.replace'; however, in the mini program environment, use wx.miniProgram.navigateBack' or send a message to the mini program main process 'wx.miniProgram.postMessage'.
[0117] In this embodiment, a real-time user interface can be designed in the device, including action instructions, status prompts and progress bars, to ensure that the user can clearly understand the verification progress. The progress is automatically updated by the real-time progress bar method, and positive feedback can be given to the user even during a long wait, thereby optimizing the user experience. At the same time, through the real-time interactive feedback mechanism, the user can grasp the verification status throughout the process, and positive feedback can be provided even when the network is unstable.
[0118] In addition, this solution can also design an environment adaptation module to identify the operating environment based on the isXCX flag, dynamically adjust the strategy to adapt to the H5 or mini program Webview environment, and ensure the correct execution of the face recognition process and experience consistency. Specifically, for browser compatibility: H5 pages need to consider the support of multiple browsers, including Chrome, Firefox, Safari, etc.; while mini programs do not need to consider other browser compatibility issues. For API call differences: H5 pages use standard Web APIs, such as fetch, localStorage, etc.; while mini programs have their own set of APIs, such as: wx.miniProgram.postMessage and wx.miniProgram.navigateBack, for message delivery and page jumps; for API exclusivity: mini programs use proprietary APIs, such as the 'wx.*' series of functions, which provide functions that are deeply integrated with the WeChat platform, such as positioning, opening the camera, etc. For life cycle management: mini programs 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 opening H5 in the mini program webview is different from that of opening H5 in ordinary browsers, and performance optimization needs to be carried out according to its characteristics, such as communicating between WebView and mini program through postMessage and onmessage to avoid performance loss caused by frequent communication. 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 this embodiment, a unified API call adaptation layer can be constructed to dynamically call appropriate API interfaces according to different platforms, covering functions such as user authorization, video stream processing, and network communication, to achieve seamless cross-platform functional docking. At the same time, a data reporting and monitoring module can be set up to uniformly collect user behavior, verification results, and system performance data across platforms to ensure service quality and security 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, this solution implements unified security protection measures in the H5 and mini-program environments, including data encryption, interface access control, and exception handling, to ensure that user privacy and the overall security of the system are not affected by the platform.
[0120] In this embodiment, it is disclosed that when a network connection abnormality 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 determined whether the current network connection retry number exceeds a preset retry number threshold; if so, the current display page is switched to a network connection abnormality page, so that a retry can be triggered when an abnormal event occurs, thereby ensuring the continuity and stability of the verification process.
[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. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0122] This application also provides a face recognition device, please refer to Figure 5 , the face recognition device comprises:
[0123] The token acquisition module 10 is used to simultaneously acquire the video verification token and the anti-network attack control token in a parallel processing manner;
[0124] A verification environment creation module 20, for creating an anti-network attack verification environment by serial processing based on the video verification token and the anti-network attack control token when the acquisition is successful;
[0125] The face detection module 30 is used to perform face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified in the anti-network attack verification environment.
[0126] The face recognition device provided by this application adopts the face recognition method in the above embodiment, which can solve the technical problems of slow authentication speed and vulnerability to network attacks when performing face recognition in H5 and mini-program environments in the prior art. Compared with the prior art, the beneficial effects of the face recognition device provided by this application are the same as the beneficial effects of the face recognition method provided by the above embodiment, and the other technical features of the face recognition device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0127] The present application provides a face recognition device, which includes: at least one processor; and a memory communicatively connected to 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 so that the at least one processor can execute the face recognition method in the above-mentioned embodiment 1.
[0128] Reference below Figure 6 , which shows a schematic diagram of the structure of a face recognition device suitable for implementing the embodiment of the present application. The face recognition device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The facial recognition device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0129] like Figure 6As shown, the face recognition device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the face recognition device are also stored. The processing device 1001, ROM1002, and RAM1004 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: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a 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 figure shows a face recognition device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided instead.
[0130] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0131] The face recognition device provided by the present application adopts the face recognition method in the above embodiment to solve the technical problem of face recognition. Compared with the prior art, the beneficial effects of the face recognition device provided by the present application are the same as the beneficial effects of the face recognition method provided by the above embodiment, and the other technical features in the face recognition device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0132] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0133] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0134] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the face recognition method in the above-mentioned embodiment.
[0135] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more 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 this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0136] The computer-readable storage medium may be included in the face recognition device; or may exist independently without being assembled into the face recognition device.
[0137] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the face recognition device, the face recognition device: adopts a parallel processing method to simultaneously obtain a video verification token and an anti-network attack control token; when the acquisition is successful, creates an anti-network attack verification environment through a serial processing method based on the video verification token and the anti-network attack control token; in the anti-network attack verification environment, performs face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified.
[0138] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may 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 may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0139] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0140] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[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-mentioned face recognition method, and can solve the technical problems of slow authentication speed and vulnerability to network attacks when performing face recognition in H5 and mini-program environments in the prior art. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the face recognition method provided by the above-mentioned embodiment, and will not be repeated here.
Claims
1. A face recognition method, characterized in that: The method includes: A parallel processing method is used to simultaneously obtain a video verification token and an anti-network attack control token; When the acquisition is successful, based on the video verification token and the anti-network attack control token, an anti-network attack verification environment is created by serial processing; In the anti-network attack verification environment, face recognition detection is performed on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified.
2. The method according to claim 1, characterized in that When the acquisition is successful, the step of creating an anti-network attack verification environment by serial processing based on the video verification token and the anti-network attack control token includes: When the acquisition is successful, the preset verification environment creation function is called in a serial processing manner to create a security verification room; Join the security verification room based on the video verification token and the anti-network attack control token to create an anti-network attack verification environment.
3. The method according to claim 1, characterized in that The step of performing face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified in the anti-network attack verification environment includes: In the anti-network attack verification environment, real-time audio and video streams corresponding to the user to be identified are obtained in real time through the media device component and the environment component; In the process of acquiring the real-time audio and video stream, real-time action reasoning is performed through a preset communication method; Determine the action to be verified corresponding to the user to be identified based on the action reasoning result; Perform face recognition detection on the user to be identified based on the action to be verified.
4. The method according to claim 3, characterized in that The step of performing face recognition detection on the user to be identified based on the action to be verified includes: Collecting the image to be detected corresponding to the user to be identified in real time; Adjusting the image background color of the image to be detected based on a color transformation sequence by using a preset glare model to generate a glare effect corresponding to the image to be detected; Performing reasoning based on the glare effect through the preset glare model to obtain a reasoning result; Based on the inference result and the action to be verified, face recognition detection is performed on the user to be identified.
5. The method according to claim 4, characterized in that The step of performing face recognition detection on the user to be identified based on the inference result and the action to be verified includes: Determining whether there is a real life feature in the image to be detected based on the inference result; If so, obtaining the current execution action of the user to be identified in the image to be detected based on the feedback of the action to be verified; The currently executed action is compared with the action to be verified to perform face recognition detection on the user to be identified.
6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: When a network connection anomaly is detected, a network connection retry request is triggered; Get the current number of network connection retries in real time through the retry counter; Determine whether the current network connection retry count exceeds a preset retry count threshold; If yes, the current display page is switched to the network connection abnormality page.
7. The method according to claim 6, characterized in that Before the step of simultaneously acquiring the video verification token and the anti-network attack control token in a parallel processing manner, the method further includes: Determine the task running environment corresponding to the current face recognition task according to the preset identification information; If yes, the step of switching the current display page to the network connection abnormality page includes: If yes, determining a page switching strategy based on the task running environment; The current display page is switched to the network connection abnormality page based on the page switching strategy.
8. A face recognition device, characterized in that: The device comprises: A token acquisition module, used to simultaneously acquire a video verification token and an anti-network attack control token in a parallel processing manner; A verification environment creation module, used to create an anti-network attack verification environment through serial processing based on the video verification token and the anti-network attack control token when the acquisition is successful; The face detection module is used to perform face recognition detection on the user to be identified based on the real-time audio and video stream corresponding to the user to be identified in the anti-network attack verification environment.
9. A face recognition device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the face recognition method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the face recognition method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Information processing method and device for face recognition, and terminal equipment
CN108595928A
Face recognition method and device, mobile terminal and storage medium
CN108596061A
Audio-video playing event tracking method and device
CN108966041A
Voiceprint and face recognition verification system and method based on trusted execution environment
CN112491844A
Page request processing method and device
CN112751878A
