A method, apparatus and device for determining a state of concentration
By optimizing attention assessment through multi-frame temporal correlation analysis and adaptive frame extraction mechanism, the problem of low accuracy in single-frame image assessment is solved, realizing stable and accurate assessment of learners' attention and intelligent intervention support in online education.
Patent Information
- Application Number
- CN202611407830.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-10
- Publication Date
- 2026-11-27
AI Technical Summary
Existing online education methods for assessing attention based on single-frame images are easily affected by factors such as fluctuations in image quality, changes in lighting, changes in head posture, and facial occlusion. This results in low assessment accuracy, a high misjudgment rate, and an inability to accurately determine the learner's sustained attention status and provide effective teaching intervention support.
By employing a temporal sliding window and an adaptive frame-sampling mechanism, and through multi-frame temporal correlation analysis, combined with the initial attention score and confidence level, the window length is dynamically adjusted to optimize the attention assessment results and improve the stability and accuracy of the assessment.
It enables stable and accurate assessment of learners' attention levels, reduces the misjudgment rate, and supports teachers in making effective adjustments to teaching strategies and intelligent interventions.
Smart Images

Figure CN123182145A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of online education technology, and in particular to a method, apparatus, and device for determining a state of focus. Background Technology
[0002] With the rapid development of internet and multimedia communication technologies, online education has become an important form of teaching. Online education breaks through the time and space limitations of classroom teaching, enabling the wider dissemination and sharing of teaching resources. Learners can access online classrooms anytime, anywhere via terminal devices. In recent years, the user base and coverage of online education have continued to expand, encompassing various application scenarios such as basic education, higher education, vocational training, and corporate training.
[0003] In online education, because teachers and learners are in different physical spaces, it is difficult for teachers to grasp learners' listening status and attention levels in a timely and intuitive manner. To address this, an image-based method for assessing learner focus has been proposed. The basic idea is to capture images of learners during class using terminal devices (such as cameras), and then use computer vision technology to process and analyze these images to identify attention-related characteristics such as facial orientation, gaze direction, and eye opening / closing, thereby evaluating learners' focus levels. This approach helps teachers remotely understand learners' listening status and provides data support for adjusting teaching strategies, thus attracting increasing attention in the field of online education.
[0004] The aforementioned method assesses learners' attention based on single-frame images. Specifically, it identifies attention-related features such as facial orientation, gaze direction, and eye opening / closing status within a single frame to evaluate learners' focus. However, since a single frame only reflects a momentary state, the analysis results are easily affected by factors such as image quality fluctuations, lighting changes, head posture changes, and facial occlusion. This leads to low accuracy in attention assessment, a high false positive rate, and reduces the accuracy and reliability of attention detection results. Summary of the Invention
[0005] This application provides a method for determining a state of focus, the method comprising: The current image of the target object is input into the attention detection model to obtain the initial attention score and initial confidence score of the target object. The initial attention score is used to characterize the degree of attention the target object pays to the preset content, and the initial confidence score is used to characterize the degree to which the target object is continuously detected. Based on the window length N of the time-series sliding window, and based on the initial focus score and the target focus scores of the N frames preceding the current image, the target focus score of the current image is determined. The focus state of the target object is determined based on the target focus score of the current image; The window length of the temporal sliding window is updated based on the attention state, target variance, and target confidence; wherein the target variance is determined based on the target attention score of the current image and the target attention scores of the N frames of images, and the target confidence is determined based on the initial confidence.
[0006] This application provides a device for determining a state of focus, the device comprising: The acquisition module is used to input the current image of the target object into the attention detection model to obtain the initial attention score and the initial confidence score of the target object; wherein, the initial attention score is used to characterize the degree of attention of the target object to the preset content, and the initial confidence score is used to characterize the degree to which the target object is continuously detected; The determination module is used to determine the target focus score of the current image based on the window length N of the time-series sliding window, the initial focus score, and the target focus scores of the N frames preceding the current image; and to determine the focus state of the target object based on the target focus score of the current image. An update module is used to update the window length of the temporal sliding window based on the focus state, target variance, and target confidence of the target object; wherein the target variance is determined based on the target focus score of the current image and the target focus scores of the N frames preceding the current image; wherein the target confidence is determined based on the initial confidence.
[0007] This application provides an electronic device, including: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor; the processor is configured to execute the machine-executable instructions to implement the attention state determination method of the above example of this application.
[0008] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the method for determining the attention state as described above in this application.
[0009] This application provides a machine-readable storage medium storing machine-executable instructions that can be executed by a processor; wherein the processor is configured to execute the machine-executable instructions to implement the method for determining the attention state as described in the above example of this application.
[0010] As can be seen from the above technical solutions, in this embodiment, the current image of the target object is input into the attention detection model to obtain the initial attention score and initial confidence level of the target object. Based on the window length N of the time-series sliding window, and based on the initial attention score and the target attention scores of the N frames preceding the current image, the target attention score of the current image is determined. The attention state of the target object is then determined based on the target attention score of the current image. In this way, the initial attention score of the current image is optimized based on the target attention scores of the N frames, and the attention state of the target object is determined based on the optimized target attention score. Thus, the attention of the target object is evaluated based on multiple frames. The evaluation results are less susceptible to interference from factors such as image quality fluctuations, lighting changes, head pose changes, and facial occlusion. The accuracy of attention evaluation is high, the false positive rate is low, and the accuracy and reliability of attention detection results are improved.
[0011] After obtaining the attention state based on the current image, the window length of the temporal sliding window can be updated based on the attention state, target variance, and target confidence. That is, after each image acquisition, the window length of the temporal sliding window is dynamically adjusted to match the attention state. After optimizing the initial attention score with reference to the window length of the temporal sliding window, the accuracy of attention assessment is further improved, achieving stability, accuracy, and operability of attention assessment. Attached Figure Description
[0012] Figure 1 This is a flowchart illustrating a method for determining a state of focus in one embodiment of this application. Figure 2 This is a flowchart illustrating a method for determining a state of focus in one embodiment of this application. Figure 3 This is a schematic diagram illustrating the correction of the initial focus score in one embodiment of this application; Figure 4 This is a schematic diagram of the state transition of the focus state in one embodiment of this application; Figure 5 This is a schematic diagram illustrating the dynamic adjustment of the frame skipping interval based on the focus state in one embodiment of this application; Figure 6 This is a schematic diagram of the hierarchical intervention triggering and anti-shake timing in one embodiment of this application; Figure 7 This is a schematic diagram of the structure of a multi-frame temporal correlation attention evaluation system according to one embodiment of this application; Figure 8 This is a schematic diagram of the structure of a focus state determination device in one embodiment of this application; Figure 9This is a hardware structure diagram of an electronic device according to one embodiment of this application. Detailed Implementation
[0013] This application proposes a method for determining attention state. This method can be applied to electronic devices, which can be terminal devices such as personal computers, laptops, tablets, and smartphones. See also... Figure 1 The diagram shown is a flowchart of the method, which may include: Step 101: Input the current image of the target object into the attention detection model to obtain the initial attention score and initial confidence of the target object; wherein, the initial attention score is used to characterize the degree of attention of the target object to the preset content, and the initial confidence is used to characterize the degree to which the target object is continuously detected.
[0014] Step 102: Based on the window length N of the time-series sliding window, and based on the initial focus score and the target focus scores of the N frames preceding the current image, determine the target focus score of the current image.
[0015] Step 103: Determine the focus state of the target object based on the target focus score of the current image.
[0016] Step 104: Update the window length of the time-series sliding window based on the focus state, target variance, and target confidence, so as to serve as the window length N corresponding to the next frame image when determining the target focus score based on the next frame image; wherein, the target variance is determined based on the target focus score of the current image and the target focus scores of N frames, and the target confidence is determined based on the initial confidence.
[0017] For example, the target focus score of the current image is determined based on the initial focus score and the target focus scores of the N preceding frames. This can include, but is not limited to, determining a consistency score based on the number of images of the same category and the window length N of the temporal sliding window. After inputting the current image into the focus detection model, the behavior category of the target object can also be obtained, and the number of images of the same category can be determined based on the number of images corresponding to that behavior category in the N frames. Then, candidate focus scores can be determined based on the consistency score and the initial focus score. Finally, a weighted average is performed on the candidate focus scores and the target focus scores of the N frames to obtain the target focus score of the current image.
[0018] For example, determining a candidate focus score based on a consistency score and an initial focus score may include: if the consistency score is not less than a first threshold, then the initial focus score is determined as a candidate focus score; if the consistency score is less than a second threshold, then the initial focus score is reduced to obtain a candidate focus score; wherein the first threshold is greater than the second threshold; if the consistency score is less than the first threshold but not less than the second threshold, then a weighted calculation is performed on the target focus score of the previous frame of the current image, the initial focus score, and the initial focus score of the next frame of the current image to obtain a candidate focus score.
[0019] For example, determining the focus state of a target object based on the target focus score of the current image may include: if the target focus score of the current image and K1 consecutive frames is greater than a first score, then the focus state is determined to be a focused state; if the target focus score of the current image and K2 consecutive frames is greater than a second score but not greater than the first score, then the focus state is determined to be a regression state; if the target focus score of the current image and K3 consecutive frames is greater than a third score but not greater than the second score, then the focus state is determined to be a distracted state; if the target focus score of the current image and K4 consecutive frames is not greater than the third score, then the focus state is determined to be a disengaged state; wherein K1 is not greater than K2, K2 is not greater than K3, and K3 is not greater than K4; wherein a focused state may indicate that the target object is within the detection area and attention is focused on preset content; a distracted state may indicate that the target object is within the detection area but attention is not focused on preset content; a regression state may indicate the transition process of the target object switching from a distracted state to a focused state; and a disengaged state may indicate that the target object is not within the detection area.
[0020] For example, the process of determining the target confidence based on the initial confidence may include: determining a consistency score based on the number of images in the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images in the same category is determined based on the number of images corresponding to the behavior category in N frames; normalizing the target variance to obtain the normalized variance, and determining the stability score based on the normalized variance; wherein the stability score is negatively correlated with the normalized variance; and performing a weighted calculation on the consistency score, stability score, and initial confidence to obtain the target confidence; wherein the weighting coefficient of the consistency score is greater than the weighting coefficient of the stability score, and the weighting coefficient of the consistency score is greater than the weighting coefficient of the initial confidence. The weighting coefficient of the stability score may be greater than the weighting coefficient of the initial confidence, or it may not be greater than the weighting coefficient of the initial confidence.
[0021] For example, updating the window length of a time-series sliding window based on focus state, target variance, and target confidence may include: determining a first frame-sampling interval based on focus state, a second frame-sampling interval based on target variance, and a third frame-sampling interval based on target confidence; wherein the first frame-sampling interval corresponding to the focus state is not less than the first frame-sampling interval corresponding to the regression state, the first frame-sampling interval corresponding to the regression state is not less than the first frame-sampling interval corresponding to the distraction state, and the first frame-sampling interval corresponding to the departure state is not less than the first frame-sampling interval corresponding to the focus state; wherein the second frame-sampling interval is negatively correlated with the target variance, and the third frame-sampling interval is positively correlated with the target confidence. The target frame-sampling interval is determined based on the first, second, and third frame-sampling intervals, and the window length of the time-series sliding window is updated based on the configured time length of the time-series sliding window and the target frame-sampling interval.
[0022] As can be seen from the above technical solutions, in this embodiment, the current image of the target object is input into the attention detection model to obtain the initial attention score and initial confidence level of the target object. Based on the window length N of the time-series sliding window, and based on the initial attention score and the target attention scores of the N frames preceding the current image, the target attention score of the current image is determined. The attention state of the target object is then determined based on the target attention score of the current image. In this way, the initial attention score of the current image is optimized based on the target attention scores of the N frames, and the attention state of the target object is determined based on the optimized target attention score. Thus, the attention of the target object is evaluated based on multiple frames. The evaluation results are less susceptible to interference from factors such as image quality fluctuations, lighting changes, head pose changes, and facial occlusion. The accuracy of attention evaluation is high, the false positive rate is low, and the accuracy and reliability of attention detection results are improved.
[0023] After obtaining the attention state based on the current image, the window length of the temporal sliding window can be updated based on the attention state, target variance, and target confidence. That is, after each image acquisition, the window length of the temporal sliding window is dynamically adjusted to match the attention state. After optimizing the initial attention score with reference to the window length of the temporal sliding window, the accuracy of attention assessment is further improved, achieving stability, accuracy, and operability of attention assessment.
[0024] The technical solutions described above in the embodiments of this application will be explained below in conjunction with specific application scenarios.
[0025] In online education, because teachers and learners are in different physical spaces, it is difficult for teachers to grasp learners' listening status and attention levels in a timely and intuitive manner. To address this, an image-based method for assessing learner focus has been proposed. The basic idea is to capture images of learners during class using terminal devices (such as cameras), and then use computer vision technology to process and analyze these images to identify attention-related characteristics such as facial orientation, gaze direction, and eye opening / closing, thereby evaluating learners' focus levels. This approach helps teachers remotely understand learners' listening status and provides data support for adjusting teaching strategies, thus attracting increasing attention in the field of online education.
[0026] The aforementioned method assesses learners' attention based on single-frame images. Specifically, it identifies attention-related features such as facial orientation, gaze direction, and eye opening / closing status within a single frame to evaluate learners' focus. However, since a single frame only reflects a momentary state, the analysis results are easily affected by factors such as image quality fluctuations, lighting changes, head posture changes, and facial occlusion. This leads to low accuracy in attention assessment, a high false positive rate, and reduces the accuracy and reliability of attention detection results.
[0027] There are drawbacks, such as independent judgment per frame and unstable attention assessment. For example, each frame is analyzed independently, with no correlation between frames. Due to inherent noise in the single-frame inference of the large visual model, the attention score of the same student may jump from 4 to 2 and then back to 5 in two consecutive frames due to factors such as changes in lighting, slight head movements, and randomness in model sampling, resulting in a flickering phenomenon. Teachers see the attention score line graph shaking violently and cannot determine whether the student is briefly looking down to write or is continuously distracted, seriously interfering with teaching decisions.
[0028] There is a limitation in distinguishing between instantaneous behavior and sustained states. For example, single-frame analysis cannot answer the question of whether a student's attention has been continuously wandering. For instance, if a student looks down for 3 seconds to pick up a pen, it might be judged as inattentiveness for 1-2 consecutive frames, but this is actually normal learning behavior; if a student leaves their seat for 60 seconds, a single frame cannot determine how long they have been away; if a student briefly turns their head to look out the window for 1 second and then returns, a single frame might misjudge this as wandering. Teachers need assessments of sustained states, such as when a student's attention has been wandering for more than 30 seconds, rather than instantaneous snapshots.
[0029] There is a lack of state transition semantics, which makes it unable to support intelligent intervention. For example, the analysis results of each frame are output independently, and there is no defined state transition logic of focus → distraction → return to focus. This makes it impossible to automatically determine the duration of distraction to trigger tiered interventions (such as issuing a reminder after 10 seconds of distraction, notifying the teacher after 30 seconds of distraction, and marking an abnormality after 60 seconds of distraction); it is impossible to identify return to focus events to close the triggered interventions, resulting in intervention redundancy; and it is impossible to generate reports that require temporal continuity, such as the focus change curve for the current lesson.
[0030] There is a defect that single-frame false detections cannot be automatically corrected. For example, the visual large model has a false detection rate of 5%-15% when analyzing a single frame (such as misjudging writing with the head down as being distracted, or thinking with the eyes closed as dozing off). Each false detection is directly transmitted to the front-end display and subsequent statistics, reducing the reliability of the system.
[0031] There is a contradiction between the frame skipping interval and the evaluation granularity. For example, using a fixed frame skipping interval of 2 seconds per frame cannot be dynamically adjusted according to the student's current state. When the student is focused, a frequency of 2 seconds per frame wastes reasoning resources; when the student is suspected of being distracted, a frequency of 2 seconds per frame is not dense enough and may miss key moments of state change.
[0032] In response to the above findings, this application proposes a method for assessing online classroom attention based on multi-frame temporal correlation. In the field of online education technology, this method can continuously assess and track the attention level of a target audience in an online classroom based on multi-frame temporal correlation analysis of real-time audio and video streams. In this embodiment, the target audience can be learners, such as students, and the type of target audience is not limited.
[0033] In this embodiment, by introducing a sliding window, state machine, adaptive frame extraction, and confidence correction mechanism, the independent snapshot of each frame is upgraded to continuous state tracking, achieving stability, accuracy, and operability in attention assessment. For example, a temporal sliding window aggregation module, an attention state machine module, an adaptive frame extraction scheduling module, and a cross-frame confidence correction module can be additionally deployed. These modules are executed in series within the analysis service, performing temporal correlation processing on the raw inference results of a single frame before outputting the final assessment.
[0034] This application proposes a method for determining attention state. This method can be applied to electronic devices, which can be terminal devices such as personal computers, laptops, tablets, and smartphones. See also... Figure 2 The diagram shown is a flowchart of the method, which may include: Step 201: Input the current image of the target object into the attention detection model to obtain the initial attention score, initial confidence score, and behavior category of the target object.
[0035] For example, the input to a focus detection model can be an image of a target object (such as a learner, such as a student), and the output can be an initial focus score, an initial confidence score, and a behavior category. The focus detection model can be a large visual model or other types of models; there are no restrictions, as long as it can output the initial focus score, initial confidence score, and behavior category.
[0036] Taking the visual big model as an example, the visual big model is a large model that can analyze images. Thus, after inputting the current image of the target object into the visual big model, the visual big model can analyze the current image and obtain the initial focus score, initial confidence score, and behavior category.
[0037] For example, the initial focus score is used to characterize the target object's level of attention to preset content, which refers to information that the target object should focus on in a specific scenario. For instance, in an online education scenario, the preset content could be the visual focus area (such as the screen display area) corresponding to classroom lecture content, electronic courseware, teaching videos, or teacher's audio explanations; in a human-computer interaction scenario, the preset content could be task-related information presented on the interactive interface. This embodiment does not limit the preset content.
[0038] Initial focus score is a quantitative indicator that directly reflects the degree of subjective attention a target subject pays to pre-defined content at a given moment or within a given time period. For example, the initial focus score can be a value within a specified range; a higher score indicates a higher level of attention, and a lower score indicates a lower level of attention. The specified range can be configured according to actual needs; for example, it can be a range from 0 to 1, or a range from 0 to 5, without restriction.
[0039] Taking a specified numerical range of 0 to 5 as an example, when the initial focus score is close to 5, it can be said that the target is in a state of high concentration on the preset content; when the initial focus score is close to 0, it can be said that the target has hardly paid attention to the preset content.
[0040] When outputting an initial attention score for a target object based on the current image, the attention detection model can extract attention-related visual features and determine the initial attention score based on these features. For example, visual features may include, but are not limited to: facial orientation features, such as whether the target object's face is directly facing the screen / blackboard / camera; a direct facial orientation indicates focused attention, while excessive facial turning indicates distraction. Gaze direction features, such as the target object's eye direction or gaze placement; a gaze that remains fixed on a preset content area (such as the center of the screen or the presentation area) indicates focus, while frequent gaze deviations indicate inattentiveness. Eye state features, such as the degree of eye opening and blinking frequency; naturally open eyes and a normal blinking frequency indicate alertness, while frequent eye closing or an abnormally low blinking frequency may indicate fatigue or decreased attention. Head posture stability features, i.e., the range of head posture angle changes in three-dimensional space. Stable head posture indicates sustained focus, while frequent head shaking indicates inattentiveness.
[0041] For example, the initial confidence score characterizes the degree to which a target object is consistently detected. It is a time-series statistical metric used to quantify the extent to which a target object is stably detected across multiple consecutive frames. Its value does not depend on the quality or probability of target object detection in a single frame, but rather on the continuity and persistence of the target object's appearance over time. The initial confidence score can be a normalized value; a higher value indicates a longer period of stable and continuous detection of the target object.
[0042] For example, the initial confidence level is a value between 0 and 1. When the initial confidence level is close to 1, it means that the target object is consistently detected in every frame of the observation window; when the initial confidence level is close to 0, it means that the target object is not detected in the observation window, or is only detected in a few frames.
[0043] When outputting the initial confidence score of the target object based on the current image, the focus detection model can extract continuity features and determine the initial confidence score based on these features. For example, continuity features may include, but are not limited to: detection continuity, which refers to whether the target object maintains a continuous detected state between adjacent frames; if valid detection boxes of the target object are output in consecutive frames, the detection continuity is high; if the detection result frequently jumps between the presence and absence of valid detection boxes, the detection continuity is low. Detection duration, which refers to the duration (in frames or seconds) that the target object maintains in the detected state; the longer the detection duration, the more stably the target object remains within the image acquisition area. Detection missing interval, which refers to the time interval between two consecutive detections of the target object; the shorter and less frequent the detection missing interval, the more stable the target object's presence within the image acquisition area. Detection coverage, which refers to the proportion of valid frames in which the target object is detected within a preset time window out of the total number of frames; the higher the detection coverage, the higher the proportion of time the target object continuously exists within the image acquisition area within that preset time window.
[0044] For example, continuous detection means that the target object is successfully detected in multiple consecutive frames of images without any interruption in time. Initial confidence focuses on whether it has been successfully detected over a period of time. Initial confidence can effectively distinguish the following scenarios: the target object is always sitting in front of the camera, and the target object is detected normally in every frame, with the initial confidence maintained at a high level (e.g., greater than 0.9); the target object frequently enters and exits the camera's field of view, and although the target object may be detected in the current frame, there have been multiple detection interruptions over a period of time, with the initial confidence at a low level (e.g., less than 0.5). The above two scenarios may output the same "target object detected" result under single-frame image analysis, but through the initial confidence, this application can accurately distinguish between the two completely different actual states of "continuous presence" and "intermittent appearance".
[0045] For example, the initial confidence level can represent the stability of target object detection. If a target object is present in consecutive frames, the initial confidence level is 1; if a target object is present in intermittent frames, the initial confidence level is 0.5; if a target object is present in a frame but disappears, the initial confidence level is 0. In the above process, detecting a target object means detecting the target object's face, or detecting the target object's head.
[0046] For example, the behavior category of a target object refers to the semantic label output by the attention detection model after visually understanding the current image of the target object, describing the target object's current specific action or state. Unlike the initial attention score (continuous numerical value) and initial confidence score (consistent), the behavior category is a qualitative description of what the target object is doing. Taking online education scenarios as an example, behavior categories can include, but are not limited to: listening attentively, taking notes with head down, playing on a phone with head down, talking with face turned to the side, resting with eyes closed, sleeping on the table, getting up and leaving, returning to one's seat, etc. There are no restrictions on this behavior category.
[0047] Step 202: Determine the consistency score based on the number of items in the same category and the window length N of the time-series sliding window.
[0048] For example, regarding the window length N of the temporal sliding window, after determining the focus state of the target object based on the previous frame image, the window length N of the temporal sliding window can be updated based on the focus state of the target object. This window length N is the same as the window length N of the temporal sliding window corresponding to the current image. For details on how to update the window length N of the temporal sliding window, please refer to subsequent embodiments.
[0049] For example, after inputting the current image into the attention detection model, the behavior category of the target object can also be obtained, and the number of images of the same category can be determined based on the number of images corresponding to that behavior category in N frames. For instance, assuming the behavior category of the target object is behavior category a, if there are 5 frames of images in the N frames preceding the current image that have behavior category a, then the number of images of the same category can be 5, or it can be 6 (i.e., the 5 frames preceding the current image and the current image).
[0050] For example, when determining the consistency score based on the number of items in the same category and the window length N, the quotient of the number of items in the same category and the window length N can be used as the consistency score, which is denoted as consistency.
[0051] Step 203: Determine candidate focus scores based on consistency scores and initial focus scores.
[0052] For example, if the consistency score is not less than a first threshold, the initial focus score can be determined as a candidate focus score; that is, the initial focus score remains unchanged to obtain the candidate focus score. For instance, if consistency ≥ 0.7, it means that the behavior categories of most images within the time-series sliding window are consistent, and the current image belongs to the mainstream behavior category. The initial focus score remains unchanged to obtain the candidate focus score.
[0053] For example, if the consistency score is less than the second threshold, the initial focus score can be reduced to obtain a candidate focus score. That is, the initial focus score is reduced, and the reduced focus score can be used as a candidate focus score. The first threshold can be greater than the second threshold. For instance, if consistency < 0.3, it indicates that the current image's behavior category is inconsistent with most images within the time-series sliding window; the current image belongs to a minority behavior category, and the initial focus score is a suspected false positive. The initial focus score can be reduced to obtain a candidate focus score, and the reduction value can be configured according to requirements.
[0054] For example, if the consistency score is less than the first threshold and not less than the second threshold, then the target focus score of the previous frame of the current image, the initial focus score of the current image, and the initial focus score of the next frame of the current image are weighted and calculated to obtain the candidate focus score.
[0055] For example, if the consistency score is less than the first threshold and not less than the second threshold, the weighted result of the previous and next frames can be used to replace the initial focus score of the current image, that is, the neighboring frames are used for smoothing correction.
[0056] Regarding the target focus score of the previous frame, when processing the previous frame, its initial focus score can be used to obtain the target focus score of the previous frame. For details on how to obtain the target focus score of the previous frame, please refer to the process for obtaining the target focus score of the current image. Regarding the initial focus score of the next frame, after acquiring the next frame of the current image, the next frame can be input into the focus detection model to obtain its initial focus score. Because it depends on the initial focus score of the next frame, in actual processing, it is necessary to wait for the next frame to arrive before correcting the initial focus score of the current image, introducing a delay of one frame extraction interval.
[0057] For example, if the consistency score is less than the first threshold and not less than the second threshold, the candidate focus score of the current image can be determined using the following formula: R't = w1×R{t-1}+w2×Rt+w3×R{t+1}. R't represents the candidate focus score of the current image, R{t-1} represents the target focus score of the previous frame, Rt represents the initial focus score of the current image, and R{t+1} represents the initial focus score of the next frame. w1, w2, and w3 represent weighting coefficients, which can be configured according to actual needs, such as w1 being 0.3, w2 being 0.4, and w3 being 0.3. To mitigate the impact of outliers in the current frame, the weighting coefficients of neighboring frames can be controlled to be greater than the weighting coefficient of the current image, such as w1 being greater than w2 and w3 being greater than w2. w1 and w3 can be the same, or w1 and w3 can be different, such as w1 being greater than w3 or w1 being less than w3.
[0058] In summary, considering that the initial attention score output by the attention detection model may contain errors (e.g., a false detection rate of 5%-15% per frame), the initial attention score can be corrected using temporal context. Based on this, a cross-frame confidence correction module can be deployed to correct the initial attention score using temporal context to obtain the candidate attention score for the current image.
[0059] For example, see Figure 3 The diagram illustrates the process of correcting the initial focus score. The input to the cross-frame confidence correction module is the initial focus score of the current image. The module determines the consistency score. If the consistency score is not less than a first threshold, the initial focus score is determined as a candidate focus score. If the consistency score is less than a second threshold, the initial focus score is reduced to obtain a candidate focus score. If the consistency score is less than the first threshold but not less than the second threshold, a weighted average is performed on the target focus score of the previous frame, the initial focus score of the current image, and the initial focus score of the next frame to obtain a candidate focus score.
[0060] Step 204: Based on the window length N of the temporal sliding window, and based on the candidate focus scores and the target focus scores of the N frames preceding the current image, determine the target focus score of the current image. N can be a positive integer greater than 1. For example, the candidate focus scores and the target focus scores of the N frames preceding the current image can be weighted to obtain the target focus score of the current image.
[0061] For example, regarding the window length N of the temporal sliding window, after determining the focus state of the target object based on the previous frame image, the window length N of the temporal sliding window can be updated based on the focus state of the target object. This window length N is the window length N of the temporal sliding window corresponding to the current image.
[0062] Regarding the target focus score of the preceding N frames, when processing the preceding N frames, the target focus score of the preceding N frames can be obtained based on the initial focus score of the preceding N frames.
[0063] For example, after obtaining the candidate focus score of the current image, a weighted operation can be performed on the candidate focus score and the target focus score of the N preceding frames to obtain the target focus score of the current image. When performing the weighted operation on the focus scores, the weighting coefficient of the current image can be greater than the weighting coefficient of the N preceding frames; the weighting coefficient of the image with a small interval from the current image can be greater than the weighting coefficient of the image with a large interval from the current image.
[0064] For example, since the focus scores (initial focus scores or candidate focus scores) of a single frame image flicker due to model noise, temporal smoothing is required. Based on this, a temporal sliding window aggregation module can be deployed. The temporal sliding window aggregation module can maintain a temporal sliding window, and the window length N of the temporal sliding window can be dynamically adjusted. The target focus scores of N frames of images are stored through the temporal sliding window.
[0065] In one possible implementation, the target focus score of the current image can also be determined based on the candidate focus scores and the target focus score of the previous frame image. For example, the target focus score of the current image can be determined using the following formula: St = α × Rt + (1-α) × S{t-1}; where St can represent the target focus score of the current image, Rt can represent the candidate focus scores of the current image, α can represent the smoothing coefficient, with a value ranging from 0.2 to 0.5, such as 0.3. The smaller α is, the stronger the smoothing (more resistant to flicker), but the slower the response, and S{t-1} can represent the target focus score of the previous frame image.
[0066] Step 205: Determine the focus state of the target object based on the target focus score of the current image.
[0067] For example, if the target focus score of the current image and the K1 consecutive frames are greater than the first score, then the focus state is determined to be a focused state. That is, if the target focus score of the current image is greater than the first score, and the target focus score of the K1-1 consecutive frames preceding the current image is greater than the first score, then the focus state is determined to be a focused state. The first score can be configured according to actual needs.
[0068] In this context, a focused state can indicate that the target object is within the detection area and its attention is concentrated on preset content. For example, a focused state means that the target object is within the image acquisition area, and its attention is continuously focused on preset content (such as courseware or lecture content). In this focused state, the target object's facial orientation, gaze direction, and eye state all exhibit characteristics consistent with focused attention.
[0069] For example, if the target focus score of the current image and the consecutive K2 frames is greater than the second score but not greater than the first score, then the focus state can be determined to be a regression state. That is, if the target focus score of the current image is greater than the second score but not greater than the first score, and the target focus scores of the consecutive K2-1 frames preceding the current image are greater than the second score but not greater than the first score, then the focus state is determined to be a regression state. The second score can be configured according to actual needs.
[0070] The "return state" can represent the transition process of a target object switching from a distracted state to a focused state. For example, the return state refers to the intermediate transition process of a target object switching from a distracted state to a focused state, or it can be described as returning to focus after being distracted. In this return state, the target object's attention is recovering from a scattered state to a focused state, such as turning the head from the side back to facing forward, or turning the gaze from off-center back to the screen area.
[0071] For example, if the target focus score of the current image and the consecutive K3 frames is greater than the third score but not greater than the second score, then the focus state is determined to be a distracted state. That is, if the target focus score of the current image is greater than the third score but not greater than the second score, and the target focus score of the consecutive K3-1 frames preceding the current image is greater than the third score but not greater than the second score, then the focus state is determined to be a distracted state. The third score can be configured according to actual needs.
[0072] In this context, "distracted state" refers to a situation where the target object is within the detection area but its attention is not focused on the preset content. For example, distracted state means that the target object is within the image acquisition area, but its attention is not focused on the preset content. In this distracted state, the target object may exhibit behaviors such as looking away, turning its face to the side, closing its eyes and dozing off, looking down at its phone, or talking to others.
[0073] For example, if the target focus score of the current image and the consecutive K4 frames is not greater than the third score, the focus state can be determined to be an "out-of-focus" state. That is, if the target focus score of the current image is not greater than the third score, and the target focus scores of the consecutive K4-1 frames preceding the current image are not greater than the third score, then the focus state can be determined to be an "out-of-focus" state. The "out-of-focus" state can indicate that the target object is not within the detection area. For instance, the "out-of-focus" state means that the target object is not within the image acquisition area, i.e., the target object's face has not been detected in multiple consecutive frames. In the "out-of-focus" state, it can also indicate that the target object has left its seat or has moved out of the camera's field of view.
[0074] In the above process, the first score is greater than or equal to the second score, the second score is greater than or equal to the third score, K1 is not greater than K2, K2 is not greater than K3, and K3 is not greater than K4.
[0075] For example, a focus state machine module can be deployed, which can abstract semantically defined states from continuous target focus scores and perform transitions between states. See also Figure 4 The diagram illustrates the state transitions of focused states. In a focused state (denoted as FOCUSED), if the transition condition for a distracted state is met, the state transitions from focused to distracted; if the transition condition for an unfocused state is met, the state transitions from focused to unfocused. In a distracted state (denoted as WANDERING), if the transition condition for a returning state is met, the state transitions from distracted to returning. In a returning state (denoted as RETURNING), if the transition condition for a distracted state is met, the state transitions from returning to distracted; if the transition condition for a focused state is met, the state transitions from returning to focused. In an unfocused state (denoted as ABSENT), if the transition condition for a returning state is met, the state transitions from unfocused to returning.
[0076] For the transition conditions between different attention states (such as entry and exit conditions), please refer to Table 1. Table 1 defines the four levels of attention states and state transition rules.
[0077] Table 1 For example, for key design considerations regarding state transitions, hysteresis thresholds can be configured, such as a first score, a second score, and a third score. The first score represents the focus threshold, the second score represents the regression threshold, and the third score represents the distraction threshold. The first score is greater than the second score, and the second score is greater than the third score. For example, the third score can be 3 points, the second score can be 3.5 points, and the second score is greater than the third score. This helps to prevent repeated jumps near the threshold (hysteresis interval anti-jitter).
[0078] For the critical design of state transitions, the number of confirmation frames can be configured. A state transition only takes effect after K consecutive frames meet the conditions; a single-frame abrupt change will not trigger a state transition. The value of K frames varies depending on the importance of the state. For example, entering a focused state requires K1 consecutive frames (K1 being the smallest value, such as 3 consecutive frames); entering a returning state requires K2 consecutive frames (such as 4 consecutive frames) to ensure the student is returning to focus; entering a distracted state requires K3 consecutive frames (such as 6 consecutive frames) to avoid accidental triggering due to brief actions like looking down to pick up a pen; and entering a disengaged state requires K4 consecutive frames (such as 8 consecutive frames) to avoid misjudgment during a moment of looking down.
[0079] For example, regarding the secondary confirmation of the disappearance of the target object: when the target object's face is detected to be out of the frame in a single frame, it is not immediately determined to be in the ABSENT state. Instead, the detection results of the previous K4 frames are checked. If the detection results of the previous K4 frames are all that the target object's face is out of the frame, then the ABSENT state is determined. If the detection results of only a few frames are that the target object's face is out of the frame, it is marked as a temporary occlusion and the original state is maintained, instead of changing the focus state to the ABSENT state.
[0080] Step 206: Determine the target variance based on the window length N of the time-series sliding window, the target focus score of the current image, and the target focus scores of the N frames preceding the current image.
[0081] For example, after obtaining the target attention score of the current image, the target variance can be determined based on the target attention score of the current image and the target attention scores of N frames. The target variance represents the attention variance within the temporal sliding window. The larger the target variance, the more unstable the state, requiring more intensive sampling. This embodiment does not impose restrictions on how to calculate the target variance within the temporal sliding window.
[0082] Step 207: Determine the target confidence level based on the initial confidence level. For example, the initial confidence level can be used as the target confidence level, or the initial confidence level can be adjusted to obtain the target confidence level.
[0083] For example, the target variance can be normalized to obtain the normalized variance, and the stability score can be determined based on the normalized variance. Then, the consistency score, stability score, and initial confidence score are weighted to obtain the target confidence score. For instance, the target confidence score can be determined using the following formula: confidence=w1×consistency+w2×(1-σ 2 / σ 2 _max)+w3×stability; In the above formula, confidence can represent the target confidence level. Consistency can represent the consistency score; the determination process for the consistency score is described in step 202. σ 2 It can represent the target variance, σ 2 _max represents the configured maximum variance, which can be configured according to actual needs. The maximum variance is used to normalize the target variance. σ 2 / σ 2 `_max` represents the normalized variance, which is obtained by normalizing the target variance. (1-σ) 2 / σ 2 _max can represent the stability score, which is negatively correlated with the normalized variance. stability represents the initial confidence level, the details of which are described in step 201.
[0084] w1 represents the weighting coefficient for the consistency score, which can be configured according to actual needs. w2 represents the weighting coefficient for the stability score, which can also be configured according to actual needs. w3 represents the weighting coefficient for the initial confidence score, which can also be configured according to actual needs. For example, the weighting coefficient for the consistency score can be greater than the weighting coefficient for the stability score, and the weighting coefficient for the consistency score can be greater than the weighting coefficient for the initial confidence score, or it can be no greater than the weighting coefficient for the stability score. For example, w1 is 0.5, w2 is 0.3, and w3 is 0.2.
[0085] Step 208: Update the window length of the time-series sliding window based on the focus state, target variance, and target confidence, so that when determining the target focus score based on the next frame image, it can be used as the window length N corresponding to the next frame image. That is, the updated window length is used as the window length N corresponding to the next frame image.
[0086] For example, the first frame interval can be determined based on the focus state. The first frame interval corresponding to the focus state is not less than the first frame interval corresponding to the regression state, the first frame interval corresponding to the regression state is not less than the first frame interval corresponding to the distraction state, and the first frame interval corresponding to the departure state is not less than the first frame interval corresponding to the focus state. For instance, the first frame interval corresponding to the focus state is greater than the first frame interval corresponding to the regression state, the first frame interval corresponding to the regression state is greater than the first frame interval corresponding to the distraction state, and the first frame interval corresponding to the departure state is greater than or equal to the first frame interval corresponding to the focus state. For example, the first frame interval corresponding to the focus state could be 10 seconds, indicating stable focus, requiring sparse sampling; the first frame interval corresponding to the regression state could be 2 seconds, indicating intensive sampling during the distraction period, requiring precise capture of the regression time; the first frame interval corresponding to the distraction state could be 1 second, indicating intensive sampling during the regression confirmation period. The first frame interval corresponding to the departure state could be 10 seconds or greater, indicating that the state has left, and intensive sampling is not required.
[0087] For example, the second frame-sampling interval can be determined based on the target variance. The second frame-sampling interval is negatively correlated with the target variance. That is, the smaller the target variance, the larger the second frame-sampling interval. The value range of the second frame-sampling interval is the same as that of the first frame-sampling interval, such as a value range of 1 to 10 seconds.
[0088] For example, when the target variance is less than the first variance threshold, the second frame extraction interval can be 10 seconds; when the target variance is less than the second variance threshold but not less than the first variance threshold, the second frame extraction interval can be 2 seconds; when the target variance is less than the third variance threshold but not less than the second variance threshold, the second frame extraction interval can be 1 second. There are no restrictions on this, as long as the second frame extraction interval is negatively correlated with the target variance.
[0089] For example, the third frame-sampling interval can be determined based on the target confidence level. The third frame-sampling interval is positively correlated with the target confidence level, that is, the higher the target confidence level, the larger the third frame-sampling interval. The value range of the third frame-sampling interval is the same as that of the first frame-sampling interval, such as a value range of 1 second to 10 seconds.
[0090] For example, when the target confidence level is greater than the first confidence level threshold, the third frame extraction interval can be 10 seconds; when the target confidence level is greater than the second confidence level threshold but not greater than the first confidence level threshold, the third frame extraction interval can be 2 seconds; when the target confidence level is greater than the third confidence level threshold but not greater than the second confidence level threshold, the third frame extraction interval can be 1 second. There are no restrictions on this, as long as the third frame extraction interval is positively correlated with the target confidence level.
[0091] For example, after obtaining the first, second, and third frame-drop intervals, a target frame-drop interval can be determined based on these intervals. For instance, the sum of the first, second, and third frame-drop intervals can be used as the target frame-drop interval. Alternatively, the average of the first, second, and third frame-drop intervals can be used as the target frame-drop interval. The target frame-drop interval can also be obtained by weighting the first, second, and third frame-drop intervals; where the weighting coefficient of the first frame-drop interval can be greater than the weighting coefficient of the second frame-drop interval, and vice versa; or, the weighting coefficient of the first frame-drop interval can be greater than the weighting coefficient of the third frame-drop interval, and vice versa; or, the weighting coefficient of the second frame-drop interval can be greater than the weighting coefficient of the first frame-drop interval, and vice versa. Of course, the above are just examples of a few weighting coefficients. The weighting coefficients for the first frame extraction interval, the second frame extraction interval, and the third frame extraction interval can be configured according to actual needs. There are no restrictions on the values of these weighting coefficients.
[0092] For example, the window length of the time-series sliding window can be updated based on the configured time length and the target frame extraction interval. That is, the window length N is dynamically adjusted according to the target frame extraction interval to ensure that the time-series sliding window covers a fixed time range, namely the configured time length, such as 30 seconds.
[0093] For example, the window length of a time-series sliding window can be the quotient of the time length and the target frame skipping interval, or it can be obtained by rounding up or down the quotient of the time length and the target frame skipping interval. For instance, if the time length is 30 seconds and the target frame skipping interval is 2 seconds, then the window length of the time-series sliding window is 15 frames.
[0094] For example, considering that a fixed 2 seconds / frame cannot balance resource consumption and evaluation accuracy, an adaptive frame skipping scheduling module can be deployed. This module can dynamically adjust the frame skipping interval based on the user's attention level. See also Figure 5 The diagram shown illustrates the dynamic adjustment of the frame skipping interval based on the user's attention level.
[0095] For example, when the focus state is focused, the frame skipping interval (i.e., the first frame skipping interval) can be 10 seconds / frame; when the focus state is returning to focus, the first frame skipping interval can be 2 seconds / frame; when the focus state is distracted, the first frame skipping interval can be 1 second / frame; and when the focus state is absent, the first frame skipping interval can be 10 seconds / frame.
[0096] For example, see Table 2 for an example of determining the target frame skipping interval.
[0097] Table 2 In one possible implementation, after obtaining the target frame extraction interval, images can also be extracted from the video using the target frame extraction interval. That is, the current image in the above embodiment is extracted from the video using the target frame extraction interval. Assuming the target frame extraction interval is 2 seconds, images are extracted from the video at 2-second intervals. Based on each extracted frame image, that image is used as the current image to perform the above processing flow.
[0098] In one possible implementation, the above steps can be used to obtain the target's attention state. For each attention state (such as focused state, returning state, distracted state, absent state, etc.), the duration of the same attention state can be tracked. For example, the entry time is recorded each time a state transition occurs, and the duration of the current state is calculated. The duration is used for: graded intervention triggers (different levels of distraction: 10 seconds / 30 seconds / 60 seconds), and post-class report statistics (total attention time in this lesson, longest consecutive distraction time, etc.).
[0099] For example, based on the duration of the state machine, a tiered intervention strategy can be automatically triggered. The timing of tiered intervention triggering and debouncing can be found in [reference needed]. Figure 6 As shown. For example, if the duration of inattentiveness reaches 10 seconds, the intervention level is L1, which is a mild reminder level. The intervention action is a color change of the front-end attention indicator (e.g., from green to yellow), which is imperceptible to the student. The anti-shake design is: after triggering at L1 level, if the student enters a RETURNING state, it does not upgrade to L2 level, and the anti-shake duration can be 2 seconds.
[0100] If the inattentive state lasts for 30 seconds, the intervention level is L2, which is the teacher notification level. The intervention action is a pop-up reminder card on the teacher's device, including the duration and the current behavior. The anti-shake design is that if the student returns to focus within 5 seconds after being triggered at L2 level, the intervention will not escalate to L3 level. This anti-shake design avoids the frequent inattentive-return-inattentive state transitions that would otherwise require frequent interventions.
[0101] If the inattentive state lasts for 60 seconds or more, the intervention level is L3, which is the abnormality marking level. The intervention action is to automatically mark the abnormality, record it in the post-lesson report, and highlight the warning on the teacher's end. After returning to a focused state, the L1 / L2 reminders are automatically turned off, and the L3 mark is retained for post-lesson statistics.
[0102] In one possible implementation, each state transition generates a structured event, denoted as a state transition event. The state transition event includes the following content, the content of which is not limited. This state transition event is sent to the signaling service via a message queue, either to the front end or to trigger an intervention strategy.
[0103] json { "event_type": "state_transition", "from_state": "FOCUSED", "to_state": "WANDERING", "duration_in_from_state_ms": 180000, "smoothed_score_at_transition": 2.8, "frame_ts": 1718300456000, "confidence": 0.87 } In one possible implementation, the analysis service sends a frame skipping frequency adjustment command to the recording service via a message queue. This command includes the following, and its content is not limited. Upon receiving the command, the recording service dynamically adjusts the frame skipping parameters, switching the frame skipping frequency without restarting the recording process. Furthermore, a minimum frame skipping interval of 0.5 seconds (2fps) and a maximum interval of 15 seconds are set to implement rate limiting protection, preventing resource exhaustion or data loss due to extreme frequencies. Additionally, the frame skipping interval is re-evaluated during each state transition and remains unchanged throughout the state duration.
[0104] json { "event_type": "frame_rate_adjust", "room_id": 1001, "user_id": 2001, "interval_seconds": 1, "reason": "state_changed_to_WANDERING", "valid_until": "next_state_change" } As can be seen from the above technical solutions, in the embodiments of this application, the initial focus score of the current image is optimized based on the target focus score of N frames of images, and the focus state of the target object is determined based on the optimized target focus score. Thus, the focus of the target object is evaluated based on multiple frames of images. The evaluation results are not easily affected by factors such as image quality fluctuations, lighting changes, head posture changes, and facial occlusion. The focus evaluation accuracy is high, the false judgment rate is low, and the accuracy and reliability of focus detection results are improved.
[0105] After obtaining the attention state based on the current image, the window length of the temporal sliding window can be updated based on the attention state, target variance, and target confidence. That is, after each image acquisition, the window length of the temporal sliding window is dynamically adjusted to match the attention state. After optimizing the initial attention score with reference to the window length of the temporal sliding window, the accuracy of attention assessment is further improved, achieving stability, accuracy, and operability of attention assessment.
[0106] Significantly Improved Stability of Attention Assessment: By using sliding window aggregation, single-frame flicker is eliminated, reducing the standard deviation of smoothed attention scores. The teacher-side line graph transforms from a jagged shape to a smooth curve, greatly improving readability. Accurate Distinction Between Instantaneous Behaviors and Continuous States: The state machine's confirmation frame mechanism effectively filters normal learning behaviors such as looking down to pick up a pen or briefly turning the head, avoiding false triggers of inattention alerts and improving the accuracy of inattention detection. Automatic Correction of False Detections: The cross-frame confidence correction module utilizes temporal consistency detection and adjacent frame smoothing to reduce the false detection rate of single frames, significantly improving reliability. Support for Intelligent Tiered Intervention: The state machine's continuous duration tracking and tiered intervention mechanism achieve a closed loop of detecting inattention → tiered reminders → automatic shutdown. Teachers do not need to continuously monitor the screen; the system automatically pushes intervention suggestions at critical moments. Optimized Resource Utilization: Adaptive frame extraction scheduling increases the frame extraction interval when students are focused, reducing AI inference calls. Real-Time Anti-Jitter: The hysteresis threshold design for state transitions effectively prevents repeated state jumps caused by fluctuations in attention scores around the threshold.
[0107] In one possible implementation, see Figure 7 The diagram shown illustrates the structure of a multi-frame temporal correlation attention assessment system. This system includes a temporal sliding window aggregation module, an attention state machine module, an adaptive frame extraction scheduling module, and a cross-frame confidence correction module.
[0108] The current image of the target object is input into the attention detection model to obtain a single-frame raw inference result, which includes the initial attention score, initial confidence score, and behavior category of the target object. The cross-frame confidence correction module determines the consistency score based on the number of objects of the same category and the window length N of the temporal sliding window; the cross-frame confidence correction module determines candidate attention scores based on the consistency score and the initial attention score. The temporal sliding window aggregation module determines the target attention score of the current image based on the window length N of the temporal sliding window, the candidate attention scores, and the target attention scores of the N preceding frames. This can be achieved by weighting the candidate attention scores and the target attention scores of the N preceding frames. The attention state machine module determines the attention state of the target object based on the target attention score of the current image. The adaptive frame-skipping scheduling module determines the target variance based on the window length N of the temporal sliding window, the target attention score of the current image, and the target attention scores of the N preceding frames. The adaptive frame-skipping scheduling module determines the target confidence based on the initial confidence score. The adaptive frame-skipping scheduling module updates the window length of the temporal sliding window based on the focus state, target variance, and target confidence.
[0109] In one possible implementation, the sliding window's data structure (an ordered set sorted by frame acquisition timestamps) is shown below, and the content of this data structure is not limited. FrameResult: frame_ts: frame acquisition timestamp (milliseconds); room_id: room ID; user_id: student ID; attention: raw attention score (focus score, 0-5); emotion: emotion description; behavior: behavior description; face_in_frame: whether the face is in the frame; raw_response: the model's raw output.
[0110] The state machine state record (key-value storage) is shown below. Attention State: current_state: current state (FOCUSED / WANDERING / RETURNING / ABSENT, etc.); state_entered_at: timestamp of entering the current state; smoothed_score: current smoothed score; consecutive_count: number of consecutive frames that meet the transition conditions; last_frame_ts: timestamp of the most recent frame; confidence: current confidence; current_interval: current frame interval; interventions: intervention level.
[0111] State transition events (message queue messages) can be represented as follows, without any restrictions: `event_type`: event type (state_transition); `room_id`: room ID; `user_id`: student ID; `from_state`: state before transition; `to_state`: state after transition; `duration_in_from_state_ms`: duration in the previous state; `smoothed_score_at_transition`: smoothed score at transition; `frame_ts`: timestamp of the trigger frame; `confidence`: confidence level.
[0112] The frame rate adjustment command (message queue message) can be as follows, and there are no restrictions on it. The frame rate adjustment command (denoted as FrameRateAdjustCmd) can include the following content: event_type: event type (frame_rate_adjust); room_id: room ID; user_id: student ID; interval_seconds: new frame rate interval; reason: reason for adjustment; valid_until: validity period.
[0113] After inference is completed, a temporal correlation processing pipeline is added: Frame analysis processing flow (8-step pipeline): Step 1, Single-frame raw inference: Call the visual large model to perform attention / emotion / behavior analysis on the frame image. Step 2, Construct frame results: Encapsulate the raw inference results into a standard frame result structure. Step 3, Sliding window aggregation: Add the frame results to the sliding window and calculate the smoothing score and window variance. Step 4, Cross-frame confidence correction: Based on the consistency detection of consecutive frames, correct the scores of suspected false positive frames. Step 5, State machine transition: Input the corrected score into the state machine and determine whether a state transition occurs. Step 6, Adaptive frame extraction scheduling: Evaluate whether the frame extraction interval needs to be adjusted based on the current state; if so, send an adjustment command. Step 7, Graded intervention determination: If a state transition occurs, check whether intervention is triggered or deactivated. Step 8, Write the final evaluation results (including smoothing score, confidence, and state information) into the database.
[0114] Regarding the implementation details of the sliding window: a distributed cached ordered set is used to store the frame results for each student, sorted by frame collection timestamp; before each aggregation, old frames that exceed the time window are deleted; during aggregation, all frame data within the window is read; calculations are completed at the application layer, and only the final smoothed value is stored in the state machine record; the window data is set with an expiration time (default 2 hours), and is automatically cleaned up after the course ends.
[0115] Regarding the implementation details of the state machine: a key-value structure of a distributed cache is used to store the current state of each student; the state transition adopts the CAS (Compare-And-Swap) pattern: read the current state; check the transition condition; if the condition is met, update the state with an atomic operation; if the CAS fails (due to concurrent updates), reread and retry; the acknowledgment frame counter is stored in the state record; the counter is incremented or reset each time a new frame is received, and a transition is triggered when the threshold is reached.
[0116] Regarding the implementation details of adaptive frame dropping: After receiving the frequency adjustment instruction, the recording service does not restart the recording process, but dynamically switches the frame dropping frequency: stops the current frame dropping task; starts a new frame dropping task with the new interval; the new task reuses the same video stream, and the frame dropping interval change is transmitted from the analysis service to the recording service through the message queue.
[0117] Regarding the implementation details of tiered intervention: the intervention status is stored in a distributed cache; the triggered intervention level and time are recorded; debouncing logic: each time RETURNING→FOCUSED transition occurs, check if there are any unclosed L1 / L2 interventions; if so, send an intervention closure event to the front end; L3 (abnormal marker) is not automatically closed and is retained until the post-class report; intervention events are sent to the signaling service via a message queue.
[0118] The above technical solutions can be extended to the following scenarios: Cross-class learning profiling: Persisting the state transition event sequence of each class to build a long-term focus profile of students, supporting cross-class analysis such as "the student's focus rate has been declining in the last 3 classes". Personalized threshold adaptation: Students of different age groups have different focus baselines. Threshold 1 / threshold 2 and the number of confirmation frames N can be automatically adjusted based on historical data to achieve personalized assessment. Multi-person classroom expansion: In one-to-many scenarios, an independent sliding window and state machine are maintained for each student, and the teacher can view the focus status panels of multiple students simultaneously. Course type adaptation: Different course types (lecture / interaction / practice) have different focus modes. The state machine parameters for switching course type templates can be preset (e.g., interactive courses allow for more frequent state switching). Model hot switching: When the visual model is upgraded, there may be differences in the scoring scale between the old and new models. The sliding window can automatically and smoothly transition, avoiding score jumps caused by model switching.
[0119] Based on the same concept as the method described above, this application proposes a device for determining the state of focus, see [link to relevant documentation]. Figure 8 The diagram shown is a structural schematic of the device, which may include: The acquisition module 81 is used to input the current image of the target object into the attention detection model to obtain the initial attention score and the initial confidence score of the target object; wherein, the initial attention score is used to characterize the degree of attention of the target object to the preset content, and the initial confidence score is used to characterize the degree to which the target object is continuously detected; The determining module 82 is used to determine the target focus score of the current image based on the window length N of the time-series sliding window, the initial focus score, and the target focus scores of the N frames preceding the current image; and to determine the focus state of the target object based on the target focus score of the current image. The update module 83 is used to update the window length of the temporal sliding window based on the focus state, target variance, and target confidence of the target object; wherein the target variance is determined based on the target focus score of the current image and the target focus scores of the N frames preceding the current image; wherein the target confidence is determined based on the initial confidence.
[0120] For example, when determining the target focus score of the current image based on the initial focus score and the target focus scores of the N frames preceding the current image, the determining module 82 is specifically used for: A consistency score is determined based on the number of images of the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images of the same category is determined based on the number of images in the N frames that correspond to the behavior category; Candidate focus scores are determined based on the consistency score and the initial focus score; The target focus score of the current image is obtained by weighting the candidate focus score and the target focus score of the N frames.
[0121] When determining candidate focus scores based on the consistency score and the initial focus score, the determining module 82 is specifically used for: If the consistency score is not less than a first threshold, the initial focus score is determined as the candidate focus score; if the consistency score is less than a second threshold, the initial focus score is reduced to obtain the candidate focus score; wherein, the first threshold is greater than the second threshold. If the consistency score is less than the first threshold and not less than the second threshold, then the target focus score of the previous frame of the current image, the initial focus score, and the initial focus score of the next frame of the current image are weighted and calculated to obtain the candidate focus score.
[0122] For example, when determining the focus state of the target object based on the target focus score of the current image, the determining module 82 is specifically used for: If the target focus score of the current image and the K1 consecutive frames is greater than the first score, then the focus state is determined to be a focused state; if the target focus score of the current image and the K2 consecutive frames is greater than the second score but not greater than the first score, then the focus state is determined to be a regression state; if the target focus score of the current image and the K3 consecutive frames is greater than the third score but not greater than the second score, then the focus state is determined to be a distracted state; if the target focus score of the current image and the K4 consecutive frames is not greater than the third score, then the focus state is determined to be a disengaged state. Where K1 is not greater than K2, K2 is not greater than K3, and K3 is not greater than K4; The "focused state" indicates that the target object is within the detection area and attention is concentrated on the preset content; the "distracted state" indicates that the target object is within the detection area but attention is not concentrated on the preset content; the "return state" indicates the transition process of the target object switching from the distracted state to the focused state; and the "departure state" indicates that the target object is not within the detection area.
[0123] For example, the determining module 82 is further configured to determine the target confidence based on the initial confidence; wherein, when determining the target confidence based on the initial confidence, the determining module 82 is specifically configured to: determine a consistency score based on the number of images of the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images of the same category is determined based on the number of images corresponding to the behavior category in the N frames of images; The target variance is normalized to obtain the normalized variance, and a stability score is determined based on the normalized variance; wherein the stability score is negatively correlated with the normalized variance. The target confidence level is obtained by weighting the consistency score, the stability score, and the initial confidence level; wherein the weighting coefficient of the consistency score is greater than the weighting coefficient of the stability score, and the weighting coefficient of the consistency score is greater than the weighting coefficient of the initial confidence level.
[0124] For example, when the update module 83 updates the window length of the time-series sliding window based on the focus state, target variance, and target confidence of the target object, it is specifically used for: A first frame-sampling interval is determined based on the focus state, a second frame-sampling interval is determined based on the target variance, and a third frame-sampling interval is determined based on the target confidence level. The first frame-sampling interval corresponding to the focus state is not less than the first frame-sampling interval corresponding to the regression state, the first frame-sampling interval corresponding to the regression state is not less than the first frame-sampling interval corresponding to the distraction state, and the first frame-sampling interval corresponding to the departure state is not less than the first frame-sampling interval corresponding to the focus state. The second frame-sampling interval is negatively correlated with the target variance, and the third frame-sampling interval is positively correlated with the target confidence level. The target frame extraction interval is determined based on the first frame extraction interval, the second frame extraction interval, and the third frame extraction interval, and the window length of the time-series sliding window is updated based on the configured time length of the time-series sliding window and the target frame extraction interval.
[0125] Based on the same application concept as the above method, this application proposes an electronic device, see [link to application]. Figure 9 As shown, the electronic device may include: a processor 91 and a machine-readable storage medium 92, the machine-readable storage medium 92 storing machine-executable instructions that can be executed by the processor 91; the processor 91 is used to execute the machine-executable instructions to implement the method for determining the attention state disclosed in the above example of this application.
[0126] Based on the same concept as the above method, this application also provides a machine-readable storage medium storing a plurality of computer instructions, which, when executed by a processor, can implement the method for determining the attention state disclosed in the above examples of this application.
[0127] The aforementioned machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information, such as executable instructions, data, etc. For example, machine-readable storage media can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.
[0128] Based on the same concept as the methods described above, this application also provides a computer program product, which includes a computer program. When executed by a processor, the computer program implements the method for determining attention states disclosed in the examples above.
[0129] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for determining a state of focus, characterized in that, The method includes: The current image of the target object is input into the attention detection model to obtain the initial attention score and initial confidence score of the target object. The initial attention score is used to characterize the degree of attention the target object pays to the preset content, and the initial confidence score is used to characterize the degree to which the target object is continuously detected. Based on the window length N of the time-series sliding window, and based on the initial focus score and the target focus scores of the N frames preceding the current image, the target focus score of the current image is determined. The focus state of the target object is determined based on the target focus score of the current image; The window length of the temporal sliding window is updated based on the attention state, target variance, and target confidence; wherein the target variance is determined based on the target attention score of the current image and the target attention scores of the N frames of images, and the target confidence is determined based on the initial confidence.
2. The method according to claim 1, characterized in that, Determining the target focus score of the current image based on the initial focus score and the target focus scores of the N frames preceding the current image includes: A consistency score is determined based on the number of images of the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images of the same category is determined based on the number of images in the N frames that correspond to the behavior category; Candidate focus scores are determined based on the consistency score and the initial focus score; The target focus score of the current image is obtained by weighting the candidate focus score and the target focus score of the N frames.
3. The method according to claim 2, characterized in that, The process of determining candidate focus scores based on the consistency score and the initial focus score includes: If the consistency score is not less than a first threshold, the initial focus score is determined as the candidate focus score; if the consistency score is less than a second threshold, the initial focus score is reduced to obtain the candidate focus score; wherein, the first threshold is greater than the second threshold. If the consistency score is less than the first threshold and not less than the second threshold, then the target focus score of the previous frame of the current image, the initial focus score, and the initial focus score of the next frame of the current image are weighted and calculated to obtain the candidate focus score.
4. The method according to claim 1, characterized in that, Determining the focus state of the target object based on the target focus score of the current image includes: If the target focus score of the current image and the K1 consecutive frames is greater than the first score, then the focus state is determined to be a focused state; if the target focus score of the current image and the K2 consecutive frames is greater than the second score but not greater than the first score, then the focus state is determined to be a regression state; if the target focus score of the current image and the K3 consecutive frames is greater than the third score but not greater than the second score, then the focus state is determined to be a distracted state; if the target focus score of the current image and the K4 consecutive frames is not greater than the third score, then the focus state is determined to be a disengaged state. Where K1 is not greater than K2, K2 is not greater than K3, and K3 is not greater than K4; The "focused state" indicates that the target object is within the detection area and attention is concentrated on the preset content; the "distracted state" indicates that the target object is within the detection area but attention is not concentrated on the preset content; the "return state" indicates the transition process of the target object switching from the distracted state to the focused state; and the "departure state" indicates that the target object is not within the detection area.
5. The method according to claim 1, characterized in that, The process of determining the target confidence level based on the initial confidence level includes: A consistency score is determined based on the number of images of the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images of the same category is determined based on the number of images in the N frames that correspond to the behavior category; The target variance is normalized to obtain the normalized variance, and a stability score is determined based on the normalized variance; wherein the stability score is negatively correlated with the normalized variance. The target confidence level is obtained by weighting the consistency score, the stability score, and the initial confidence level; wherein the weighting coefficient of the consistency score is greater than the weighting coefficient of the stability score, and the weighting coefficient of the consistency score is greater than the weighting coefficient of the initial confidence level.
6. The method according to claim 1, characterized in that, The step of updating the window length of the time-series sliding window based on the focus state, target variance, and target confidence includes: A first frame-sampling interval is determined based on the focus state, a second frame-sampling interval is determined based on the target variance, and a third frame-sampling interval is determined based on the target confidence level. The first frame-sampling interval corresponding to the focus state is not less than the first frame-sampling interval corresponding to the regression state, the first frame-sampling interval corresponding to the regression state is not less than the first frame-sampling interval corresponding to the distraction state, and the first frame-sampling interval corresponding to the departure state is not less than the first frame-sampling interval corresponding to the focus state. The second frame-sampling interval is negatively correlated with the target variance, and the third frame-sampling interval is positively correlated with the target confidence level. The target frame extraction interval is determined based on the first frame extraction interval, the second frame extraction interval, and the third frame extraction interval, and the window length of the time-series sliding window is updated based on the configured time length of the time-series sliding window and the target frame extraction interval.
7. A device for determining a state of focus, characterized in that, The device includes: The acquisition module is used to input the current image of the target object into the attention detection model to obtain the initial attention score and the initial confidence score of the target object; wherein, the initial attention score is used to characterize the degree of attention of the target object to the preset content, and the initial confidence score is used to characterize the degree to which the target object is continuously detected; The determination module is used to determine the target focus score of the current image based on the window length N of the time-series sliding window, the initial focus score, and the target focus scores of the N frames preceding the current image; and to determine the focus state of the target object based on the target focus score of the current image. An update module is used to update the window length of the temporal sliding window based on the focus state, target variance, and target confidence of the target object; wherein the target variance is determined based on the target focus score of the current image and the target focus scores of the N frames preceding the current image; wherein the target confidence is determined based on the initial confidence.
8. The apparatus according to claim 7, characterized in that, The determining module, based on the initial focus score and the target focus scores of the N frames preceding the current image, determines the target focus score of the current image by specifically: A consistency score is determined based on the number of images of the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images of the same category is determined based on the number of images in the N frames that correspond to the behavior category; Candidate focus scores are determined based on the consistency score and the initial focus score; The target focus score of the current image is obtained by weighting the candidate focus score and the target focus score of the N frames.
9. The apparatus according to claim 8, characterized in that, When the determining module determines the candidate focus score based on the consistency score and the initial focus score, it is specifically used for: If the consistency score is not less than a first threshold, the initial focus score is determined as the candidate focus score; if the consistency score is less than a second threshold, the initial focus score is reduced to obtain the candidate focus score; wherein, the first threshold is greater than the second threshold. If the consistency score is less than the first threshold and not less than the second threshold, then the target focus score of the previous frame of the current image, the initial focus score, and the initial focus score of the next frame of the current image are weighted and calculated to obtain the candidate focus score.
10. The apparatus according to claim 7, characterized in that, When the determining module determines the focus state of the target object based on the target focus score of the current image, it is specifically used for: If the target focus score of the current image and the K1 consecutive frames is greater than the first score, then the focus state is determined to be a focused state; if the target focus score of the current image and the K2 consecutive frames is greater than the second score but not greater than the first score, then the focus state is determined to be a regression state; if the target focus score of the current image and the K3 consecutive frames is greater than the third score but not greater than the second score, then the focus state is determined to be a distracted state; if the target focus score of the current image and the K4 consecutive frames is not greater than the third score, then the focus state is determined to be a disengaged state. Where K1 is not greater than K2, K2 is not greater than K3, and K3 is not greater than K4; The "focused state" indicates that the target object is within the detection area and attention is concentrated on the preset content; the "distracted state" indicates that the target object is within the detection area but attention is not concentrated on the preset content; the "return state" indicates the transition process of the target object switching from the distracted state to the focused state; and the "departure state" indicates that the target object is not within the detection area.
11. The apparatus according to claim 7, characterized in that, The determining module is further configured to determine the target confidence level based on the initial confidence level; wherein, when determining the target confidence level based on the initial confidence level, the determining module is specifically configured to: A consistency score is determined based on the number of images of the same category and the window length N; wherein, after inputting the current image into the attention detection model, the behavior category of the target object is obtained, and the number of images of the same category is determined based on the number of images in the N frames that correspond to the behavior category; The target variance is normalized to obtain the normalized variance, and a stability score is determined based on the normalized variance; wherein the stability score is negatively correlated with the normalized variance. The target confidence level is obtained by weighting the consistency score, the stability score, and the initial confidence level; wherein the weighting coefficient of the consistency score is greater than the weighting coefficient of the stability score, and the weighting coefficient of the consistency score is greater than the weighting coefficient of the initial confidence level.
12. The apparatus according to claim 7, characterized in that, When the update module updates the window length of the time-series sliding window based on the focus state, target variance, and target confidence of the target object, it is specifically used for: A first frame-sampling interval is determined based on the focus state, a second frame-sampling interval is determined based on the target variance, and a third frame-sampling interval is determined based on the target confidence level. The first frame-sampling interval corresponding to the focus state is not less than the first frame-sampling interval corresponding to the regression state, the first frame-sampling interval corresponding to the regression state is not less than the first frame-sampling interval corresponding to the distraction state, and the first frame-sampling interval corresponding to the departure state is not less than the first frame-sampling interval corresponding to the focus state. The second frame-sampling interval is negatively correlated with the target variance, and the third frame-sampling interval is positively correlated with the target confidence level. The target frame extraction interval is determined based on the first frame extraction interval, the second frame extraction interval, and the third frame extraction interval, and the window length of the time-series sliding window is updated based on the configured time length of the time-series sliding window and the target frame extraction interval.
13. An electronic device, characterized in that, include: A processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; The processor is configured to execute machine-executable instructions to implement the method of any one of claims 1-6.
