Earphone wearing detection method and device, electronic equipment and storage medium
By combining infrared detection and G-sensor detection, and using triaxial acceleration data from an accelerometer to analyze attitude stability and motion disturbance characteristics, the problem of misjudgment in TWS earphone wearing detection is solved, achieving higher accuracy and reliability.
Patent Information
- Application Number
- CN202611486113.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-22
- Publication Date
- 2026-11-27
AI Technical Summary
Existing TWS earphone wear detection technology is easily interfered with by signals reflected from external objects, leading to false judgments that the earphones are being worn, resulting in insufficient accuracy.
By combining infrared detection and G-sensor detection, and acquiring triaxial acceleration data from the accelerometer, low-pass filtering, attitude stability characteristics, and motion disturbance characteristics are performed to determine whether the headphones are in a stationary state on the table, thereby avoiding misjudgment.
It improves the accuracy and robustness of headphone wear detection, avoids misjudging the headphone as being worn in non-wearing scenarios such as desktops, and enhances the reliability of functional linkage and user experience.
Smart Images

Figure CN123185489A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of headphone wear detection technology, specifically to a headphone wear detection method, device, electronic device, and storage medium. Background Technology
[0002] True Wireless Stereo (TWS) earbuds typically feature infrared sensors for wear detection. An infrared transmitter and receiver are positioned on the side of the earbud closest to the ear canal. By detecting changes in the reflected infrared light signal on the skin or in the ear canal, the system determines whether the earbuds are being worn. However, infrared detection inherently relies on changes in the intensity or state of the reflected signal. When the earbuds are placed near a table, desk, fabric surface, or other objects, if these objects reflect the infrared signal, the system may misinterpret this reflection as ear reflection, thus incorrectly determining that the earbuds are being worn, resulting in insufficient accuracy in wear detection. Summary of the Invention
[0003] This application provides a method, device, electronic device, and storage medium for detecting headphone wear, which can accurately determine whether the headphone is on a desktop, thereby avoiding incorrect determination that the headphone is being worn.
[0004] In a first aspect, embodiments of this application provide a method for detecting headphone wearing, including: After detecting a reflected signal that meets the wearing conditions, the raw triaxial acceleration data collected by the accelerometer is acquired and the raw triaxial acceleration data is cached frame by frame. The original triaxial acceleration data is low-pass filtered to obtain filtered triaxial acceleration data that is buffered frame by frame; The current frame is divided into multiple continuous segments. For the filtered triaxial acceleration data in each segment, the maximum angle between the vector of each sampling point and the average vector of that segment is calculated to obtain the attitude stability characteristics of that segment. The standard deviation of the resultant acceleration magnitude is calculated based on the original triaxial acceleration data of the current frame to obtain the motion disturbance characteristics of the frame; The average attitude unit vector of the current frame is calculated based on the filtered triaxial acceleration data in the current frame, and the angle between the average attitude unit vector and the reference unit vector of the ear side of the earphone in the table-placed posture is calculated to determine whether the attitude state of the current frame is close to the reference state, intermediate state, or deviating significantly. Based on the posture stability characteristics, the motion disturbance characteristics, and the posture states of multiple consecutive frames, it is determined whether the headphones are in a stationary state on a table, and when it is determined to be in a stationary state on a table, a non-wearing state indication is output.
[0005] Secondly, embodiments of this application provide an earphone wearing detection device, comprising: The data acquisition module is used to acquire the raw triaxial acceleration data collected by the accelerometer after detecting a reflected signal that meets the wearing conditions, and to cache the raw triaxial acceleration data frame by frame. The filtering module is used to perform low-pass filtering on the original triaxial acceleration data to obtain and buffer the filtered triaxial acceleration data frame by frame; The stability feature determination module is used to divide the current frame into multiple continuous segments, calculate the maximum angle between the vector of each sampling point and the average vector of the segment for the filtered triaxial acceleration data in each segment, and obtain the attitude stability features of the segment. The disturbance feature determination module is used to calculate the standard deviation of the resultant acceleration magnitude based on the original triaxial acceleration data of the current frame, and obtain the motion disturbance features of the frame. The attitude state determination module is used to calculate the average attitude unit vector of the current frame based on the filtered triaxial acceleration data in the current frame, and to calculate the angle between the average attitude unit vector and the reference unit vector of the ear side of the earphone in the table-placed posture, so as to determine whether the attitude state of the current frame is close to the reference state, intermediate state or deviating significantly. The table placement determination module is used to determine whether the earphone is in a table-placed stationary state based on the posture stability characteristics, the motion disturbance characteristics, and the posture states of multiple consecutive frames, and outputs a non-wearing state indication when it is determined to be in a table-placed stationary state.
[0006] Thirdly, embodiments of this application also provide an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps in the above-described headphone wearing detection method.
[0007] Fourthly, embodiments of this application also provide a storage medium storing a computer program, which, when executed by a processor, implements the steps in the headphone wearing detection method described above. Attached Figure Description
[0008] To more clearly illustrate the technical solutions in this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0009] Figure 1 This is a schematic diagram of the installation of a G-sensor provided in one embodiment of this application; Figure 2 This is a schematic diagram of a TWS earphone placed on a table according to an embodiment of this application; Figure 3 This is a schematic diagram of wearing TWS earphones according to an embodiment of this application; Figure 4 This is a schematic diagram of the steps of an earphone wearing detection method provided in an embodiment of this application; Figure 5 This is a schematic diagram of the algorithm for an earphone wearing detection method provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of an earphone wearing detection device provided in one embodiment of this application; Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0010] The technical solutions of this application will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0011] TWS earbuds refer to earphone products where the left and right earbuds are connected wirelessly and communicate with the audio source device wirelessly. TWS earbuds typically include a left earbud and a right earbud, which are roughly mirror images of each other in structure. However, since they correspond to the user's left and right ears respectively, their default placement and wearing orientation in space are not entirely the same.
[0012] An accelerometer (G-sensor) is an inertial sensor used to measure the acceleration components of a carrier in three orthogonal directions. In this embodiment, the G-sensor is disposed inside the earphone body of the TWS earphone and is used to output the acceleration components of the earphone body in its own coordinate system in real time along three axes, typically denoted as the X-axis, Y-axis, and Z-axis. When the earphone is stationary or under low dynamic conditions, the three-axis acceleration components output by the G-sensor mainly reflect the projection of gravitational acceleration in the earphone coordinate system, thus the attitude orientation of the earphone in space can be characterized based on the three-axis acceleration components.
[0013] Please see Figure 1 , Figure 1 This is a schematic diagram of the installation of a G-sensor provided in one embodiment of this application. Figure 1As shown, the TWS earphones include an earphone body, inside which a G-sensor and an infrared sensor are installed. An infrared emitting window and an infrared receiving window are located on the outer side of the earphone body near the ear canal. The G-sensor is mounted on the circuit board of the earphone body with a fixed mounting orientation, and its three orthogonal axes remain fixed relative to the earphone body. This ensures a stable correspondence between the three-axis acceleration components output by the G-sensor and the earphone body's attitude in space. When the earphone body's attitude in space changes, the projection components of gravitational acceleration onto the three axes of the G-sensor change accordingly. Therefore, the three-axis acceleration components output by the G-sensor can characterize the earphone body's attitude orientation in space.
[0014] Please see Figure 2 , Figure 2 This is a schematic diagram of a TWS earphone placed on a table according to an embodiment of this application. Figure 2 As shown, when TWS earbuds are placed on a horizontal table, the earbud body contacts the table with a specific surface of its shell, and the earbud body presents a relatively fixed orientation in space. At this time, the three-axis acceleration components output by the G-sensor mainly reflect the projection of gravitational acceleration in the earbud coordinate system, and the projection direction is basically consistent with the direction of the pre-calibrated reference unit vector. At the same time, since the table provides stable support for the earbuds, the earbud body tends to be stationary, and the three-axis acceleration data output by the G-sensor fluctuates little in the time dimension.
[0015] Please see Figure 3 , Figure 3 This is a schematic diagram of wearing a TWS earphone according to an embodiment of this application. Figure 3 As shown, when TWS earbuds are worn in a user's ear, the earbud body is embedded in the user's ear. The orientation of the earbud body in space is significantly different from that when it is placed on a table. At this time, there is a large angle between the gravity projection direction corresponding to the three-axis acceleration components output by the G-sensor and the pre-calibrated reference unit vector direction. At the same time, due to the user's head movements, body movements, and physiological activities such as chewing and speaking, the earbud body will be continuously subjected to small disturbances when worn. The three-axis acceleration data output by the G-sensor shows continuous dynamic fluctuations in the time dimension.
[0016] based on Figure 2 and Figure 3 It can be seen that there are differences in posture and dynamic fluctuation between TWS earphones when they are stationary on a table and when they are worn. Based on the above two types of differences, this application embodiment identifies the wearing status of the earphones by combining infrared detection and G-sensor detection.
[0017] In one embodiment, such as Figure 4 As shown, a method for detecting earphone wear is provided. Although the logical order is illustrated in the schematic diagram, in some cases, the steps shown or described may be performed in a different order than that shown in the accompanying drawings. The earphone wear detection method provided in this application can be applied to TWS earphones, and can be executed by the main control module in the TWS earphone or a processing unit connected to the main control module. Detailed descriptions are provided below. It should be noted that the order of description of the following embodiments is not intended to limit the priority of the embodiments.
[0018] according to Figure 1 The headphone wearing detection method shown includes at least steps S410 to S460, which are described in detail below: In step S410, after detecting a reflected signal that meets the wearing conditions, the raw triaxial acceleration data collected by the accelerometer is acquired and the raw triaxial acceleration data is cached frame by frame.
[0019] The reflected signal can be a signal detected by an infrared sensor. An infrared sensor is a sensor that detects near-range targets based on the principle of infrared light reflection, typically consisting of an infrared emitter and an infrared receiver. The infrared emitter emits infrared light outwards from the earphone, and the infrared receiver receives the infrared light reflected back from the external target and outputs the corresponding reflected signal. The reflected signal refers to the electrical signal corresponding to the infrared light reflected back from the external target, received by the infrared receiver. Its intensity, rate of change, or duration can be used to characterize the distance between the external target and the infrared sensor, the reflectivity, and the relative motion state. A reflected signal that meets the wearing conditions can be defined as a reflected signal whose intensity is greater than a preset intensity threshold or whose change in intensity meets a preset trigger condition, thus being determined as a reflected signal indicating the presence of a near-ear target.
[0020] After detecting a reflected signal that meets the wearing conditions, the raw triaxial acceleration data is further acquired by the G-sensor in real time at a preset sampling rate. Raw triaxial acceleration data refers to unfiltered or otherwise preprocessed triaxial acceleration sampled data. Each set of raw triaxial acceleration data includes acceleration components in the X, Y, and Z axes, corresponding to one sampling time. Optionally, data acquisition by the G-sensor can be started immediately after detecting a reflected signal that meets the wearing conditions, or the G-sensor can be kept in acquisition mode and read the most recent raw triaxial acceleration data from the buffer.
[0021] Frame-by-frame caching of raw triaxial acceleration data refers to dividing continuously acquired raw triaxial acceleration data into several frames according to a preset number of sampling points, and caching the raw triaxial acceleration data of each frame independently, so that feature calculation and state determination can be performed at the frame granularity later.
[0022] In another embodiment, the raw triaxial acceleration data collected by the accelerometer can be obtained based on the corresponding reflected signal detected by the capacitive sensor, touch sensor or proximity sensor, after the reflected signal that meets the wearing conditions is detected.
[0023] In step S420, the original triaxial acceleration data is low-pass filtered to obtain and buffered triaxial acceleration data frame by frame.
[0024] Low-pass filtering can suppress high-frequency components in the original triaxial acceleration data while retaining low-frequency, slowly changing components related to the direction of gravity. This provides a more stable representation of the headphone's static attitude characteristics and gravity projection distribution within the current time window, avoiding attitude judgment jumps caused by high-frequency random noise from the sensor itself, sampling jitter, minor mechanical vibrations, or short-term impact spikes. Optionally, the low-pass filter can be a first-order low-pass filter, a second-order low-pass filter, or other forms of low-pass filtering. In one embodiment, the low-pass filter can be a first-order low-pass filter based on an exponential moving average.
[0025] Filtered triaxial acceleration data refers to the triaxial acceleration data obtained after low-pass filtering the original triaxial acceleration data. The method of buffering filtered triaxial acceleration data frame by frame corresponds to the method of buffering original triaxial acceleration data frame by frame, ensuring that both original and filtered triaxial acceleration data are buffered simultaneously within the same frame. The original triaxial acceleration data can more completely reflect the subtle jitters, short-term disturbances, and dynamic changes of the headphones within the corresponding time window of the frame, making it suitable for characterizing whether the headphones are in contact with a person, being worn, or in other non-static states. Filtered triaxial acceleration data mainly retains the low-frequency components and slow change trends related to the direction of gravity, making it suitable for characterizing the overall attitude characteristics and stationary state of the headphones within the corresponding time window of the frame.
[0026] In step S430, the current frame is divided into multiple continuous segments. For the filtered triaxial acceleration data in each segment, the maximum angle between the vector of each sampling point and the average vector of the segment is calculated to obtain the attitude stability characteristics of the segment.
[0027] Dividing the current frame into multiple consecutive segments can compress the originally dense sequence of sampling points into several representative local feature values while preserving the temporal distribution information of data changes within the corresponding time window of the current frame. This reduces the noise sensitivity and computational burden caused by point-by-point analysis. Each segment corresponds to a shorter time window within the current frame, and multiple segments are arranged in chronological order to collectively cover the entire time window of the current frame.
[0028] Attitude stability features are characteristics used to characterize whether the headphone's attitude remains stable within a corresponding time window. For each sub-segment, the attitude stability feature is represented by the maximum angle between the vector of each sampling point within the sub-segment and the average vector of that sub-segment. The average vector of the sub-segment reflects the average direction of the headphone's attitude within that sub-segment, while the angle between the vector of each sampling point and the average vector of the sub-segment reflects the degree of deviation of each sampling point from the average direction. Taking the maximum value of the angles corresponding to each sampling point as the attitude stability feature allows us to characterize the fluctuation range of the headphone's attitude within that sub-segment from the worst-case perspective. When the headphone is stationary on a table, the angle between the vector of each sampling point within the sub-segment and the average vector of the sub-segment is usually small, and the corresponding attitude stability feature value is small; when the headphone is being worn or affected by slight movements of the human body or external disturbances, the angle is usually large, and the corresponding attitude stability feature value is large.
[0029] In step S440, the standard deviation of the resultant acceleration magnitude is calculated based on the original triaxial acceleration data of the current frame to obtain the motion disturbance characteristics of the frame.
[0030] Motion disturbance features refer to the characteristic quantities used to characterize the degree of motion disturbance of the headphones within a corresponding time window. In this embodiment, the standard deviation of the sum acceleration magnitude of each sampling point in the current frame is used for characterization. The smaller the standard deviation, the more the headphones tend to be stationary, and the larger the standard deviation, the more obvious the dynamic disturbance of the headphones.
[0031] The resultant acceleration magnitude is a scalar value obtained by taking the square root of the sum of the squares of the three-axis acceleration components at a given sampling point, reflecting the magnitude of the acceleration vector corresponding to that sampling point. When the headphones are stationary and only subject to gravity, the resultant acceleration magnitude at each sampling point is theoretically equal to the gravitational acceleration value. When the headphones are in motion or subject to disturbance, the resultant acceleration magnitude will fluctuate around the gravitational acceleration value. The standard deviation characterizes the dispersion of a set of data relative to its mean. Using the standard deviation of the resultant acceleration magnitude at each sampling point within the current frame as the motion disturbance characteristic of that frame can reflect the strength of the motion disturbance of the headphones within the corresponding time window of that frame from the perspective of the entire frame.
[0032] It's important to note that motion perturbation features are calculated based on the raw triaxial acceleration data of the current frame, not on filtered triaxial acceleration data. This is because low-pass filtering suppresses high-frequency components in the raw data. Calculating the standard deviation based on filtered data might smooth out short-term disturbances experienced by the headphones during actual use, reducing the sensitivity of the motion perturbation features to dynamic changes. Calculating motion perturbation features based on raw triaxial acceleration data more completely preserves the dynamic fluctuation information of the headphones within the corresponding time window of that frame, thereby improving the ability of the motion perturbation features to distinguish between wearing and non-wearing states.
[0033] In step S450, the average attitude unit vector of the current frame is calculated based on the filtered triaxial acceleration data in the current frame, and the angle between the average attitude unit vector and the reference unit vector of the ear side of the earphone in the table-placed posture is calculated to determine whether the attitude state of the current frame is close to the reference state, intermediate state, or deviating significantly.
[0034] The average attitude unit vector is a vector with a magnitude of 1 obtained by averaging the filtered triaxial acceleration data of each sample point in the current frame along each of the three axes, and then normalizing this average attitude vector. It is used to characterize the average pointing direction of the headphone attitude within the time window corresponding to the current frame. By averaging multiple sample points in the current frame, random errors from single sampling can be suppressed; normalizing the average attitude vector can eliminate the influence of the magnitude of the average attitude vector on subsequent angle calculations, making the angle calculation depend only on the attitude direction.
[0035] The placement posture refers to the spatial posture of the earphones when placed on a horizontal table, desk, or other similar supporting surface. Since TWS earphones typically consist of a left and a right earphone, which are roughly mirror images of each other in structure and correspond to the user's left and right ears in actual use, the direction of gravity of the left earphone in the placement posture differs from that of the right earphone in their respective earphone coordinate systems. Therefore, in this embodiment, corresponding reference unit vectors are pre-calibrated for the left and right earphones to obtain left-ear reference unit vectors and right-ear reference unit vectors, which are used to determine the posture orientation of the left and right earphones respectively.
[0036] Calibration methods may include: placing the headphones on a horizontal table in a standard tabletop posture under controlled conditions, collecting the three-axis acceleration data output by the G-sensor in this posture, calculating the average vector of the three-axis acceleration data, and normalizing the average vector to obtain the corresponding ear-side reference unit vector. Optionally, the headphones on the same ear side can be calibrated multiple times, and the results of multiple calibrations can be averaged to reduce the random error of a single calibration. The reference unit vector can be calibrated and stored in the headphones' memory before leaving the factory, or it can be completed by the user through a specific calibration process during first use. Since the left and right ear headphones differ in structure and orientation, the values of their corresponding reference unit vectors in their respective headphone coordinate systems are not the same. When determining the posture state, it is necessary to select the corresponding reference unit vector based on the ear-side attributes of the currently processed headphones.
[0037] The angle between the average attitude unit vector and the reference unit vector can be calculated by performing a dot product operation on them, and then determining the angle based on the inverse cosine of the dot product. The attitude state of the current frame can be determined based on the relationship between the angle and a preset angle threshold. The attitude state can characterize the degree of deviation of the current frame's attitude direction from the reference attitude direction, including three states: close to the reference state, intermediate state, and significantly deviated state. These represent the attitude direction being basically consistent with the reference attitude direction, having some deviation but not yet reaching a significant level, and having a significant deviation, respectively.
[0038] The "close to reference state" indicates that the angle between the average pose unit vector of the current frame and the reference unit vector of the earpiece in the table-placed pose is small, meaning the current spatial pose of the headphones is very close to the preset table-placed pose. The "intermediate state" indicates that the angle between the average pose unit vector of the current frame and the reference unit vector of the earpiece in the table-placed pose is in the middle range, meaning the current spatial pose of the headphones deviates somewhat from the preset table-placed pose. The "large deviation state" indicates that the angle between the average pose unit vector of the current frame and the reference unit vector of the earpiece in the table-placed pose is large, meaning the current spatial pose of the headphones is significantly different from the preset table-placed pose.
[0039] In step S460, based on the posture stability characteristics, motion disturbance characteristics, and posture states of multiple consecutive frames, it is determined whether the headphones are in a stationary state on the table, and when it is determined to be in a stationary state on the table, a non-wearing state indication is output.
[0040] The attitude state features of a single frame can be affected by short-term disturbances or sampling noise, and judgments based solely on a single frame are prone to misjudgment. Therefore, determining whether the headphones are in a stationary state on the table is based on the attitude state of multiple consecutive frames to reduce the risk of misjudgment from a single frame.
[0041] The "table-placed still state" refers to the headphones being in a table-placed posture and approaching a state of stillness. The conditions for determining this state include two aspects: posture direction and stillness. The posture direction condition requires that the posture state of multiple consecutive frames indicates that the posture direction is basically consistent with the reference posture direction or has not yet deviated significantly. The stillness condition requires that the motion disturbance characteristics and posture stability characteristics of multiple consecutive frames indicate that the headphones approach stillness within that time window. When the posture direction condition and the stillness condition meet the preset conditions, the headphones are determined to be in the table-placed still state.
[0042] When the headphones are determined to be stationary on a table, a non-wearing state indication is output. This non-wearing state indication indicates that the headphones are not currently being worn. It can be output to the headphone's main control module in the form of a level signal, flag, message packet, or other means, triggering the main control module to execute functions corresponding to the non-wearing state, such as pausing playback, entering sleep mode, or reducing power consumption. When the headphones are determined not to be stationary on a table, the original infrared detection result can be maintained, i.e., the headphones are considered to be worn, or further combined with other information to determine whether the headphones are worn. This application embodiment does not limit this approach.
[0043] Using the technical solution of this application embodiment, low-pass filtering of the original triaxial acceleration data can remove high-frequency noise and short-term impact spikes, while retaining low-frequency attitude components related to the direction of gravity, thus improving the reliability of attitude judgment and avoiding frequent state jumps caused by instantaneous fluctuations; dividing the frame into multiple continuous segments can retain intra-frame temporal distribution information, sensitively reflecting the continuous minute attitude changes of the earphone when in contact with or worn by the human body, and improving the ability to distinguish between stationary and non-stationary states; determining motion disturbance characteristics based on the standard deviation of the resultant acceleration magnitude can measure the degree of intra-frame acceleration fluctuations, providing a reliable criterion for stationary determination; respectively By setting reference vectors for the left and right ear structures, the difference in ear orientation can be eliminated. The posture deviation is quantified into three states, providing fine-grained input for continuous frame decision-making. By combining posture stability features, motion perturbation features, and posture states across multiple frames to determine whether the earphone is in a stationary state on a table, false triggering of infrared light in tabletop reflection scenarios can be effectively suppressed. This prevents the earphone from being mistakenly identified as worn simply because of a reflective target in non-wearing scenarios such as on a table, improving the accuracy and robustness of wear detection. Outputting a non-wearing indicator when the earphone is placed on a table avoids false wake-up, false playback, and wasted power, improving the reliability of functional linkage and user experience.
[0044] Based on the above technical solution, as an embodiment, the raw triaxial acceleration data is collected by an accelerometer at a preset sampling rate. The method of caching the raw triaxial acceleration data frame by frame may include dividing the raw triaxial acceleration data into frames, with a first number of sampling points constituting one frame, and caching the raw triaxial acceleration data frame by frame. The method of dividing the current frame into multiple consecutive segments may include dividing the sampling points of the current frame into multiple consecutive segments in chronological order, each segment containing a second number of sampling points, and each segment containing the corresponding raw triaxial acceleration data and filtered triaxial acceleration data.
[0045] The preset sampling rate can be set to 50Hz, 100Hz, 200Hz, or other values. The first quantity refers to the number of sampling points required to constitute a frame, and its value is equal to the preset sampling rate multiplied by the expected frame duration. Optionally, the expected frame duration can be set to 0.5 seconds, 1 second, 2 seconds, or other values. The second quantity refers to the number of sampling points required to constitute a segment, and its value is equal to the preset sampling rate multiplied by the expected segment duration. Optionally, the expected segment duration can be set to 50 milliseconds, 100 milliseconds, 200 milliseconds, or other values. The second quantity is less than the first quantity, and the first quantity is usually an integer multiple of the second quantity, so that the current frame can be evenly divided into multiple consecutive segments. Sampling points within the same time window retain both the original triaxial acceleration data and the filtered triaxial acceleration data, so that different feature calculations can be performed on the two types of data at the segment granularity.
[0046] In a specific example, the preset sampling rate is 100Hz, the first quantity is 100, and the second quantity is 10, meaning the G-sensor outputs 100 sets of sampled data per second, with a time interval of 10 milliseconds between adjacent sets of sampled data. The system processes the original triaxial acceleration data into frames of 100 sample points each, resulting in multiple consecutive frames with a frame duration of 1 second. For each frame, the 100 sample points are divided into 10 consecutive segments in chronological order, each segment containing 10 sample points, corresponding to a local time window of 100 milliseconds. For each segment, the original triaxial acceleration data and the filtered triaxial acceleration data corresponding to the 10 sample points within that segment are simultaneously retained. After the above processing, the original 100 consecutive sample points within 1 second are divided into 10 local data units arranged in chronological order, which preserves the temporal distribution information while reducing the noise sensitivity and computational burden caused by point-by-point analysis.
[0047] The technical solution adopted in this application can ensure that the feature calculation has a sufficient statistical sample size while taking into account real-time performance, and enable the original data and filtered data within the same time window to serve different feature calculations, thereby improving the rationality of data organization and the stability and efficiency of subsequent feature calculations.
[0048] Based on the above technical solution, as an embodiment, the maximum angle between the vector of each sampling point and the average vector of the sub-segment is calculated for the filtered triaxial acceleration data in each sub-segment to obtain the attitude stability characteristics of the sub-segment. This includes: averaging multiple filtered triaxial acceleration vectors in the current sub-segment to obtain the average vector of the sub-segment; dividing the average vector and each filtered triaxial acceleration vector in the current sub-segment by their respective magnitudes to obtain the average unit vector and the unit vector of each sampling point; calculating the angle between the unit vector of each sampling point and the average vector through normalized vector dot product; and determining the maximum value among the angles corresponding to the unit vectors of each sampling point in the current sub-segment as the attitude stability characteristics of the current sub-segment.
[0049] Averaging multiple filtered triaxial acceleration vectors within the current sub-segment means taking the arithmetic mean of the filtered triaxial acceleration vectors corresponding to all sampling points within the current sub-segment in the X, Y, and Z directions respectively, and obtaining a three-dimensional vector composed of the three average values as the average vector of the sub-segment, which reflects the average direction of the headphone attitude within the sub-segment.
[0050] The average vector and each filtered triaxial acceleration vector within the current sub-segment are divided by their respective magnitudes to normalize both the average vector and the vectors at each sampling point. This ensures that the magnitudes of both the average unit vector and the unit vectors at each sampling point are 1, eliminating the influence of vector magnitudes on subsequent angle calculations. The angle between the unit vector at each sampling point and the average vector is calculated using the normalized vector dot product. This involves first calculating the dot product of each sampling point unit vector with the average unit vector, and then determining the angle based on the inverse cosine of the dot product. Since the magnitudes of both the average unit vector and the unit vectors at each sampling point are 1, the result of their dot product is the cosine of the angle between them. A smaller angle indicates that the attitude direction of the corresponding sampling point is closer to the average attitude direction of the sub-segment; a larger angle indicates a more significant deviation.
[0051] The maximum value of the included angles corresponding to the unit vectors of each sampling point in the current sub-segment is determined as the attitude stability feature of the current sub-segment. This can characterize the fluctuation range of the headphone attitude in the sub-segment from the perspective of the worst case. Even if the attitude direction of most sampling points in the sub-segment is consistent with the average direction, as long as a few sampling points deviate significantly, the attitude stability feature will increase accordingly, thus reflecting the attitude fluctuation situation in the sub-segment more sensitively.
[0052] Suppose the current sub-segment contains N sampling points, and the corresponding filtered triaxial acceleration vectors are as follows: The average vector of this segment can be calculated using the following formula: ;in, Let N be the average vector of this sub-segment, and N be the number of sampling points within the sub-segment. Indicates the first The filtered triaxial acceleration vector of each sampling point.
[0053] The average unit vector and the unit vector at each sampling point can be obtained using the following formulas: ; ;in, It is the average unit vector. For the first Unit vector at each sampling point for The length of the mold, for The length of the module.
[0054] The included angle can be calculated using the following formula: ;in, Indicates the first The angle between each sampling point and the average vector; It is an inverse cosine function.
[0055] The technical solution adopted in this application can eliminate the influence of vector magnitude on the angle calculation based on normalization processing, and sensitively characterize the fluctuation amplitude of the headphone posture within the sub-segment based on the maximum value, thereby improving the sensitivity of posture stability features to posture changes and the stability of calculation results.
[0056] Based on the above technical solution, as an embodiment, the method of calculating the standard deviation of the resultant acceleration magnitude based on the original triaxial acceleration data of the current frame to obtain the motion disturbance characteristics of the frame may include the following steps: First, based on the original triaxial acceleration data of each sampling point in the current frame, calculate the sum of squares of the acceleration components in the three axes for each sampling point, and take the square root of the sum of squares to obtain the resultant acceleration magnitude of each sampling point. Then, average the resultant acceleration magnitudes of each sampling point in the current frame to obtain the average resultant acceleration magnitude. Next, calculate the difference between the resultant acceleration magnitude of each sampling point in the current frame and the average resultant acceleration magnitude, and square the difference to obtain the squared difference for each sampling point. Finally, average and take the square root of the squared differences of each sampling point in the current frame to obtain the standard deviation of the resultant acceleration magnitude in the current frame, which serves as the motion disturbance characteristic of the current frame.
[0057] For each sampling point in the current frame, the acceleration components along the X, Y, and Z axes are squared respectively. The sum of these three squares is then taken as the square root to obtain the magnitude of the resultant acceleration at that sampling point. This magnitude reflects the magnitude of the three-axis acceleration vector corresponding to that sampling point. The average magnitude of the resultant acceleration at each sampling point in the current frame is obtained, reflecting the overall level of the headphone's resultant acceleration within the corresponding time window. Calculating the difference between the magnitude of the resultant acceleration at each sampling point and the average, and then squaring this difference, eliminates the influence of the sign of the difference, ensuring that subsequent averaging correctly reflects the overall dispersion of all sampling points. The standard deviation obtained by taking the square root of the average of the squared differences reflects the dispersion of the headphone's resultant acceleration magnitude within the current frame from the perspective of the entire frame, thus reflecting the strength of the dynamic disturbance experienced by the headphone within that time window.
[0058] The resultant acceleration magnitude at each sampling point can be calculated using the following formula: ;in, Indicates the first The resultant acceleration magnitude of each sampling point; for The square of, Indicates the first The original X-axis acceleration data of each sampling point; similarly... for The square of, Indicates the first The original Y-axis acceleration data of each sampling point; for The square of, Indicates the first The original Z-axis acceleration data of each sampling point; .
[0059] The average value of the combined acceleration magnitude within the current frame can be calculated using the following formula: ;in, This represents the average magnitude of the combined acceleration within the current frame.
[0060] The standard deviation of the sum of acceleration magnitudes within the current frame can be calculated using the following formula: ;in, The standard deviation of the summative acceleration magnitude within the current frame is used as the motion perturbation feature of the current frame.
[0061] The technical solution adopted in this application embodiment can completely retain the dynamic fluctuation information of the headphones within the time window corresponding to the current frame based on the original data, and quantify the degree of motion disturbance of the headphones from the perspective of the whole frame based on the standard deviation, thereby improving the ability of motion disturbance features to distinguish between the wearing state and the stationary state on the table.
[0062] Based on the above technical solution, as an embodiment, the method of calculating the average attitude unit vector of the current frame based on the filtered triaxial acceleration data in the current frame may include: averaging the filtered triaxial acceleration data of each sampling point in the current frame in the three-axis direction to obtain the average attitude vector of the current frame; calculating the sum of squares of the components of the average attitude vector in the three-axis direction, and taking the square root of the sum of squares to obtain the magnitude of the average attitude vector; dividing the components of the average attitude vector in the three-axis direction by the magnitude to obtain the average attitude unit vector of the current frame.
[0063] The method for calculating the average attitude unit vector of the current frame can refer to the method for calculating the average vector of a sub-segment disclosed above. The difference is that the average attitude unit vector is frame-level, while the average vector of a sub-segment is sub-segment-level. The previous method averaged and normalized the filtered triaxial acceleration vectors within a sub-segment to obtain the average unit vector of the sub-segment; while this embodiment averages and normalizes the filtered triaxial acceleration vectors of all sampling points within the current frame to obtain the average attitude unit vector of the current frame.
[0064] Specifically, for all sampled points within the current frame, the filtered triaxial acceleration data is arithmetically averaged along the X, Y, and Z axes. These three averages together constitute the average attitude vector for the current frame. The average attitude vector of the current frame reflects the average pointing direction of the headphone's attitude within the corresponding time window. The sum of squares of the components of the average attitude vector along the three axes is calculated, and the square root of the sum of squares is taken as the magnitude of the average attitude vector. Each component of the average attitude vector along the three axes is divided by the magnitude to obtain three normalized components. The vector formed by these three normalized components is the average attitude unit vector of the current frame, with a magnitude of 1 and a direction consistent with the average attitude vector.
[0065] The technical solution adopted in this application can suppress the random error of a single sampling based on the average operation of multiple sampling points, and eliminate the influence of the modulus on the subsequent angle calculation based on normalization processing, thereby improving the stability and accuracy of the average attitude unit vector in representing the attitude direction of the current frame.
[0066] Based on the above technical solution, as an embodiment, calculating the angle between the average attitude unit vector and the reference unit vector of the corresponding ear side of the earphone in the table-placed posture, to determine whether the attitude state of the current frame is close to the reference state, intermediate state, or significantly deviated from the reference state, may include: obtaining a pre-calibrated reference unit vector representing the direction of gravity of the corresponding ear side of the earphone in the table-placed posture; performing a dot product operation on the average attitude unit vector and the reference unit vector to obtain the dot product result; determining the angle between the average attitude unit vector and the reference unit vector based on the inverse cosine value of the dot product result; when the angle is less than a first angle threshold, determining the attitude state of the current frame as close to the reference state; when the angle is greater than or equal to the first angle threshold and less than or equal to a second angle threshold, determining the attitude state of the current frame as intermediate state, wherein the first angle threshold is less than the second angle threshold; when the angle is greater than the second angle threshold, determining the attitude state of the current frame as significantly deviated from the reference state.
[0067] The system reads pre-calibrated reference unit vectors for the left and right earpieces from the earphone's memory and selects the corresponding reference unit vector based on the ear-side attributes of the currently processed earphone. The reference unit vector can be calibrated by placing the earphones on a horizontal table in a controlled environment with a standard tabletop orientation, collecting the three-axis acceleration data output by the G-sensor in this orientation, calculating the average vector of the three-axis acceleration data, and normalizing the average vector to obtain the corresponding ear-side reference unit vector.
[0068] Multiply the components of the mean attitude unit vector and the reference unit vector along the X, Y, and Z axes respectively, and then sum the three products to obtain the dot product. Since the magnitudes of the mean attitude unit vector and the reference unit vector are both 1, the dot product is the cosine of the angle between them. Taking the inverse cosine of the dot product yields the angle, as shown in the formula above.
[0069] The first angle threshold and the second angle threshold are two pre-set thresholds used to divide the included angle into intervals, with the first angle threshold being smaller than the second angle threshold. Based on the first and second angle thresholds, the range of included angle values is divided into three intervals, corresponding to three posture states. Optionally, the specific values of the first and second angle thresholds can be set based on the structural characteristics of the headphone product, typical usage scenarios, and calibration experiment results.
[0070] In one embodiment, the first angle threshold can be set to 15 degrees, 20 degrees, or 25 degrees, and the second angle threshold can be set to 45 degrees, 50 degrees, or 60 degrees. Taking a first angle threshold of 20 degrees and a second angle threshold of 50 degrees as an example, when the included angle is less than 20 degrees, the current frame's attitude state is determined to be close to the reference state; when the included angle is greater than or equal to 20 degrees and less than or equal to 50 degrees, the current frame's attitude state is determined to be an intermediate state; and when the included angle is greater than 50 degrees, the current frame's attitude state is determined to be a significantly deviated state. A smaller first angle threshold helps to accurately classify scenarios where the attitude direction is basically consistent with the reference direction into the close-to-reference state, while a larger second angle threshold helps to accurately classify scenarios where the attitude direction deviates significantly into the significantly deviated state. The combined effect of both allows the intermediate state to cover transitional scenarios where the attitude direction has some deviation but has not yet reached a significant degree of deviation.
[0071] In a specific example, the pre-calibrated left ear reference unit vector for the left earbud has components of 0.05, 0.12, and 0.99 in the X, Y, and Z axes, respectively. The pre-calibrated right ear reference unit vector for the right earbud has components of -0.05, 0.12, and 0.99 in the X, Y, and Z axes, respectively. When the left earbud is stationary on a table, the angle between its average pose unit vector in the current frame and the left ear reference unit vector is typically within 5 degrees, corresponding to a pose state close to the reference. When the left earbud is worn on the user's left ear, the angle is typically above 60 degrees, corresponding to a pose state with significant deviation. When the left earbud is placed diagonally on the table or during a transition from picking it up to putting it down, the angle may be between 20 and 50 degrees, corresponding to an intermediate pose state.
[0072] The technical solution of this application embodiment can use corresponding reference unit vectors to determine the attitude direction for the left and right earphones respectively, avoiding the determination bias caused by the structural differences between the left and right ears, and divide the interval of the included angle into three levels based on two angle thresholds, providing fine-grained attitude state input for subsequent multi-frame joint determination.
[0073] Based on the above technical solution, as an embodiment, determining whether the headphones are in a stationary state on a table, according to attitude stability characteristics, motion disturbance characteristics, and attitude states of multiple consecutive frames, may include: determining whether the current frame meets the intra-frame stability condition based on the relationship between the attitude stability characteristics of each sub-segment in the current frame and a preset stability threshold; determining whether the current frame meets the stationary condition based on the relationship between the motion disturbance characteristics of the current frame and a preset disturbance threshold; if the first few consecutive frames are in a state of large deviation, then the headphones are determined not to be in a stationary state on a table; if multiple consecutive frames are in a state close to the reference, and multiple consecutive second few frames meet the stationary condition and the intra-frame stability condition, then the headphones are determined to be in a stationary state on a table; if multiple consecutive frames are in an intermediate state, and multiple consecutive second few frames meet the stationary condition and the intra-frame stability condition, then the headphones are determined to be in a stationary state on a table; if multiple consecutive frames are in a state close to the reference or multiple consecutive third few frames are in an intermediate state, but the stationary condition or the intra-frame stability condition is not met for multiple consecutive second few frames, then the headphones are determined not to be in a stationary state on a table; wherein, the number of the first frames is less than the number of the second frames, and the number of the second frames is less than or equal to the number of the third frames.
[0074] For each segment within the current frame, the attitude stability characteristics of that segment are compared with a preset stability threshold, and the comparison result determines whether the current frame meets the intra-frame stability condition. Optionally, the current frame is determined to meet the intra-frame stability condition when the attitude stability characteristics of all segments within the current frame are less than the preset stability threshold; the current frame is determined not to meet the intra-frame stability condition when the attitude stability characteristics of any segment within the current frame are greater than or equal to the preset stability threshold; alternatively, the current frame is determined to meet the intra-frame stability condition when the number of segments with attitude stability characteristics less than the preset stability threshold within the current frame reaches a preset number threshold. The specific value of the preset stability threshold can be set according to actual needs.
[0075] The motion perturbation features of the current frame are compared with a preset perturbation threshold. If the motion perturbation features are less than the preset perturbation threshold, the current frame is determined to meet the stationary condition; if the motion perturbation features are greater than or equal to the preset perturbation threshold, the current frame is determined not to meet the stationary condition. The specific value of the preset perturbation threshold can be set according to actual needs.
[0076] The first, second, and third frame counts are all pre-defined positive integers used to quantify the required number of consecutive frames. The first frame count is less than the second frame count, and the second frame count is less than or equal to the third frame count. The first frame count represents the lower limit of the number of consecutive frames deviating significantly from the stationary state required to determine if the headphones are not in a stationary state on the table. A smaller value helps to quickly rule out the possibility of a stationary state when there is a significant deviation in the headphones' orientation, shortening the determination delay. The second frame count represents the lower limit of the number of consecutive frames satisfying both the stationary and intra-frame stability conditions required to determine if the headphones are in a stationary state on the table. A larger value helps to ensure the stability of the determination result and avoid misjudgments caused by short-term disturbances. The third frame count represents the lower limit of the number of consecutive intermediate state frames required to determine if the headphones are in a stationary state on the table. Its value is greater than or equal to the second frame count, further improving the reliability of the determination by requiring more consecutive frames when the orientation is in a transitional range.
[0077] Joint decision-making is performed by combining the attitude states of multiple consecutive frames. Among them, multiple consecutive frames refer to the consecutive frames used to determine the stationary state of the table, and the number of frames can be set according to the actual detection accuracy and response speed requirements.
[0078] If the first few consecutive frames show a significant deviation, it indicates that the current posture of the headphones is significantly different from the posture on the table, and it can be directly determined that the headphones are not in a stationary state on the table. The first frame count is less than the second frame count to ensure that large deviations can be quickly eliminated, improving the detection response speed.
[0079] If the headphones are in a close-to-reference state for multiple consecutive frames, and the second and third consecutive frames satisfy the stationary condition and the intra-frame stability condition, it indicates that the current posture of the headphones is continuously close to the posture of the headphones on the table, and the headphones remain stationary and intra-frame stable. At this time, it can be determined that the headphones are in a stationary state on the table.
[0080] If the third consecutive frame is in the intermediate state, and the second consecutive frame satisfies the static condition and the intra-frame stability condition, it indicates that although the current posture of the headphones is not completely close to the posture of the table, it has been in the intermediate state for a long time and has been kept static and intra-frame stable. Therefore, it can also be determined that the headphones are in the static state of the table.
[0081] If the headphones are in a close-to-reference state for several consecutive frames or in an intermediate state for several consecutive frames, but do not meet the stationary condition and intra-frame stability condition for several consecutive frames, it indicates that although the headphones are in a similar posture to the table posture, they have not maintained a stationary or intra-frame stability. Therefore, it is determined that the headphones are not in a stationary state on the table.
[0082] Figure 5 This is a schematic diagram of the algorithm for an earphone wearing detection method provided in an embodiment of this application; see reference. Figure 5In one specific embodiment, the accelerometer's sampling rate is 100Hz, each frame contains 100 sampling points, meaning each frame corresponds to 1 second of data; each frame is divided into 10 consecutive segments in chronological order, each segment containing 10 sampling points. A preset stability threshold is T1, a preset disturbance threshold is T2, and a first angle threshold is... The second angle threshold is ,and < The first frame has L=3, the second frame has M=5, and the third frame has N=8, with L<M<N.
[0083] Once the infrared sensor detects a reflected signal that meets the wearing conditions, the system begins acquiring raw triaxial acceleration data from the accelerometer and buffers it frame by frame. Each frame of raw triaxial acceleration data undergoes a first-order low-pass filter to obtain filtered triaxial acceleration data, which is then buffered frame by frame.
[0084] For the current frame, the system performs the following processing: The first step is to calculate the attitude stability features of each sub-segment within the frame.
[0085] The 100 sampling points of the current frame are divided into 10 segments in chronological order, with 10 sampling points in each segment. The average vector of the 10 filtered triaxial acceleration vectors within each segment is calculated. This average vector and the 10 filtered triaxial acceleration vectors within the segment are then normalized to obtain the average unit vector and the unit vectors of the 10 sampling points. The angle between the unit vector of each sampling point and the average unit vector is calculated, and the maximum value is taken as the attitude stability feature of the segment. If the attitude stability features of all 10 segments in the current frame are less than T1, the current frame is determined to meet the intra-frame stability condition; otherwise, the current frame is determined not to meet the intra-frame stability condition.
[0086] The second step is to calculate the motion perturbation features of the current frame.
[0087] Based on the raw triaxial acceleration data of 100 sampling points within the current frame, the resultant acceleration magnitude of each sampling point is calculated. The average of the 100 resultant acceleration magnitudes is obtained. The squared difference between the resultant acceleration magnitude of each sampling point and this average is calculated. The square root of the average of all squared differences is then used to obtain the standard deviation of the resultant acceleration magnitude of the current frame, which is taken as the motion perturbation feature of the current frame. If the motion perturbation feature of the current frame is less than T2, the current frame is determined to meet the stationary condition; otherwise, the current frame is determined not to meet the stationary condition.
[0088] The third step is to calculate the pose state of the current frame.
[0089] The filtered triaxial acceleration data from 100 sampling points within the current frame are averaged along each of the three axes to obtain the average attitude vector of the current frame. The magnitude of this average attitude vector is calculated, and each component of the average attitude vector along the three axes is divided by this magnitude to obtain the average attitude unit vector of the current frame. The reference unit vector of the left earphone in its table-placed posture is obtained, and the angle between the average attitude unit vector of the current frame and this reference unit vector is calculated. .like < If so, then the current frame is determined to be in a state close to the reference; if ≤ ≤ If so, then the current frame is determined to be in an intermediate state; if > If so, it is determined that the current frame is in a state of large deviation.
[0090] The fourth step is joint decision-making.
[0091] The system makes a joint decision based on the judgment results of multiple consecutive frames: If three consecutive frames show a large deviation, it is determined that the headphones are not in a stationary state on the table. If the headphones are in a close-to-reference state for multiple consecutive frames, and five consecutive frames satisfy the stationary condition and the intra-frame stability condition, then the headphones are determined to be in a stationary state on the table. If the headphones are in an intermediate state for eight consecutive frames, and five consecutive frames satisfy the stationary condition and the intra-frame stability condition, then the headphones are determined to be in a stationary state on the table. If the headphones are in a close-to-reference state for multiple consecutive frames or in an intermediate state for eight consecutive frames, but do not satisfy the stationary condition and the intra-frame stability condition for five consecutive frames, then the headphones are determined not to be in a stationary state on the table.
[0092] When the headphones are determined to be stationary on a table, the headphone main control module outputs a non-wearing status indication, pausing playback, entering sleep mode, or turning off noise cancellation, thereby avoiding false wake-up, false playback, and wasted power consumption caused by infrared false triggering.
[0093] The technical solution adopted in this application embodiment can perform joint verification in two dimensions: posture direction and dynamic fluctuation, avoiding the risk of misjudgment caused by single-dimensional judgment. By setting the first frame number, second frame number and third frame number in a hierarchical manner, different frame number requirements are adopted for different posture states, which improves the accuracy and robustness of the table-placed static state judgment, while also taking into account the real-time nature of the judgment.
[0094] To facilitate better implementation of the headphone wearing detection method of this application, this application also provides a headphone wearing detection device based on the above-described headphone wearing detection method. The meanings of the terms used are the same as in the headphone wearing detection method described above, and specific implementation details can be found in the description of the method embodiments.
[0095] Please see Figure 6 , Figure 6 This is a schematic diagram of the headphone wearing detection device provided in an embodiment of this application, wherein the headphone wearing detection device includes: The data acquisition module 601 is used to acquire the raw triaxial acceleration data collected by the accelerometer after detecting a reflected signal that meets the wearing conditions, and to cache the raw triaxial acceleration data frame by frame. The filtering module 602 is used to perform low-pass filtering on the original triaxial acceleration data to obtain and buffer the filtered triaxial acceleration data frame by frame; The stability feature determination module 603 is used to divide the current frame into multiple continuous segments, calculate the maximum angle between the vector of each sampling point and the average vector of the segment for the filtered triaxial acceleration data in each segment, and obtain the attitude stability features of the segment. The disturbance feature determination module 604 is used to calculate the standard deviation of the resultant acceleration magnitude based on the original triaxial acceleration data of the current frame, and obtain the motion disturbance features of the frame. The attitude state determination module 605 is used to calculate the average attitude unit vector of the current frame based on the filtered triaxial acceleration data in the current frame, and to calculate the angle between the average attitude unit vector and the reference unit vector of the ear side of the earphone in the table-placed posture, so as to determine whether the attitude state of the current frame is close to the reference state, intermediate state or deviating significantly. The table placement determination module 606 is used to determine whether the earphone is in a table-placed stationary state based on the posture stability characteristics, the motion disturbance characteristics, and the posture states of multiple consecutive frames, and outputs a non-wearing state indication when it is determined to be in a table-placed stationary state.
[0096] In one embodiment, the raw triaxial acceleration data is collected by the accelerometer at a preset sampling rate; the data acquisition module 601 is specifically used to perform: frame processing of the raw triaxial acceleration data with a first number of sampling points as a frame, and cache the raw triaxial acceleration data frame by frame; The stability feature determination module 603 is specifically used to perform the following: dividing the sampling points of the current frame into multiple continuous segments in chronological order, each segment containing a second number of sampling points, and each segment containing the corresponding original triaxial acceleration data and filtered triaxial acceleration data.
[0097] In one embodiment, the stability feature determination module 603 is specifically used to perform: The average vector of the current sub-segment is obtained by averaging the multiple filtered triaxial acceleration vectors within the current sub-segment. Divide the average vector and each filtered triaxial acceleration vector in the current sub-segment by their respective magnitudes to obtain the average unit vector and the unit vector of each sampling point. The angle between the unit vector at each sampling point and the average vector is calculated by the normalized vector dot product; The maximum value among the included angles corresponding to the unit vectors of each sampling point in the current sub-segment is determined as the attitude stability feature of the current sub-segment.
[0098] In one embodiment, the disturbance feature determination module 604 is specifically used to perform: Based on the original triaxial acceleration data of each sampling point in the current frame, calculate the sum of squares of the acceleration components of each sampling point in the three axes, and take the square root of the sum of squares to obtain the resultant acceleration magnitude of each sampling point. The average value of the resultant acceleration magnitude is obtained by averaging the resultant acceleration magnitude values of each sampling point in the current frame. Calculate the difference between the resultant acceleration magnitude of each sampling point in the current frame and the average resultant acceleration magnitude, and square the difference to obtain the squared difference for each sampling point. The standard deviation of the sum acceleration magnitude in the current frame is obtained by averaging and taking the square root of the squared differences of the sampling points in the current frame, and is used as the motion disturbance feature of the current frame.
[0099] In one embodiment, the attitude state determination module 605 is specifically used to perform: The average attitude vector of the current frame is obtained by averaging the filtered triaxial acceleration data of each sampling point in the three-axis direction. Calculate the sum of squares of the components of the average attitude vector in the three-axis directions, and take the square root of the sum of squares to obtain the magnitude of the average attitude vector; Divide the components of the average attitude vector in each of the three axes by the magnitude to obtain the average attitude unit vector of the current frame.
[0100] In one embodiment, the attitude state determination module 605 is specifically used to perform: Obtain a pre-calibrated reference unit vector that represents the direction of gravity on the ear side of the earphone when it is placed on a table. Perform a dot product operation between the average attitude unit vector and the reference unit vector to obtain the dot product result; Based on the inverse cosine value of the dot product result, determine the angle between the average attitude unit vector and the reference unit vector; When the included angle is less than the first angle threshold, the attitude state of the current frame is determined to be the close-to-reference state; When the included angle is greater than or equal to the first angle threshold and less than or equal to the second angle threshold, the attitude state of the current frame is determined to be an intermediate state, wherein the first angle threshold is less than the second angle threshold; When the included angle is greater than the second angle threshold, the attitude state of the current frame is determined to be a state with a large deviation.
[0101] In one embodiment, the table placement determination module 606 is specifically used to perform: Based on the relationship between the attitude stability features of each sub-segment in the current frame and the preset stability threshold, determine whether the current frame meets the intra-frame stability condition; Based on the relationship between the motion perturbation features of the current frame and the preset perturbation threshold, determine whether the current frame meets the stationary condition; If the first few consecutive frames are in the state of large deviation, it is determined that the headphones are not in the state of being placed still on the table. If the headphones are in the near-reference state for multiple consecutive frames, and the second and third consecutive frames satisfy the static condition and the intra-frame stability condition, then the headphones are determined to be in the table-placed static state. If the third consecutive frame is in the intermediate state, and the second consecutive frame satisfies the static condition and the intra-frame stability condition, then the headphones are determined to be in the table-placed static state. If multiple consecutive frames are in the near-reference state or the third consecutive frames are in the intermediate state, but the second consecutive frames do not satisfy the static condition or the intra-frame stability condition, then it is determined that the headphones are not in the table-placed static state. Wherein, the first number of frames is less than the second number of frames, and the second number of frames is less than or equal to the third number of frames.
[0102] Using the technical solution of this application embodiment, low-pass filtering of the original triaxial acceleration data can remove high-frequency noise and short-term impact spikes, while retaining low-frequency attitude components related to the direction of gravity, thus improving the reliability of attitude judgment and avoiding frequent state jumps caused by instantaneous fluctuations; dividing the frame into multiple continuous segments can retain intra-frame temporal distribution information, sensitively reflecting the continuous minute attitude changes of the earphone when in contact with or worn by the human body, and improving the ability to distinguish between stationary and non-stationary states; determining motion disturbance characteristics based on the standard deviation of the resultant acceleration magnitude can measure the degree of intra-frame acceleration fluctuations, providing a reliable criterion for stationary determination; respectively By setting reference vectors for the left and right ear structures, the difference in ear orientation can be eliminated. The posture deviation is quantified into three states, providing fine-grained input for continuous frame decision-making. By combining posture stability features, motion perturbation features, and posture states across multiple frames to determine whether the earphone is in a stationary state on a table, false triggering of infrared light in tabletop reflection scenarios can be effectively suppressed. This prevents the earphone from being mistakenly identified as worn simply because of a reflective target in non-wearing scenarios such as on a table, improving the accuracy and robustness of wear detection. Outputting a non-wearing indicator when the earphone is placed on a table avoids false wake-up, false playback, and wasted power, improving the reliability of functional linkage and user experience.
[0103] Specific limitations regarding the headphone wearing detection device can be found in the limitations of the headphone wearing detection method described above, and will not be repeated here. Each module in the aforementioned headphone wearing detection device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0104] In addition, this application also provides an electronic device, such as Figure 7 As shown, it illustrates the structural diagram of the electronic device involved in this application, specifically: The electronic device may include components such as a processor 701 with one or more processing cores and a memory 702 with one or more storage media. Those skilled in the art will understand that... Figure 7 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 701 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 702, and by calling data stored in the memory 702, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 701.
[0105] The memory 702 can be used to store software programs and modules. The processor 701 executes various functional applications and data processing by running the software programs and modules stored in the memory 702. The memory 702 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 702 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
[0106] In one embodiment, the electronic device further includes a power supply 703 that supplies power to the various components. Preferably, the power supply 703 can be logically connected to the processor 701 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 703 may also include one or more DC or AC power supplies, recharging systems, power equipment debugging circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0107] In one embodiment, the electronic device may further include an input unit 704, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0108] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 701 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 702 according to the following instructions, and the processor 701 runs the applications stored in the memory 702, thereby implementing the steps in any of the headphone wearing detection methods provided in the embodiments of this application.
[0109] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the electronic device to which the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0110] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the methods described in any embodiment of this application.
[0111] In one embodiment, a storage medium is provided on which a computer program is stored, which, when executed by a processor, implements the method described in any embodiment of this application.
[0112] In some embodiments, a computer program product is also provided, including a computer program or instructions that, when executed by a processor, implement the methods described in any embodiment of this application.
[0113] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0114] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be accomplished by instructions, or by instructions controlling related hardware. These instructions can be stored in a storage medium and loaded and executed by a processor.
[0115] Therefore, this application provides a storage medium storing a computer program that can be loaded by a processor to execute the steps in any of the headphone wearing detection methods provided in this application.
[0116] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0117] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0118] Since the instructions stored in the storage medium can execute the steps of any of the headphone wearing detection methods provided in this application, the beneficial effects that any of the headphone wearing detection methods provided in this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0119] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element.
[0120] The above provides a detailed description of the headphone wearing detection method, device, electronic device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A method for detecting headphone wearing, characterized in that, include: After detecting a reflected signal that meets the wearing conditions, the raw triaxial acceleration data collected by the accelerometer is acquired and the raw triaxial acceleration data is cached frame by frame. The original triaxial acceleration data is low-pass filtered to obtain filtered triaxial acceleration data that is buffered frame by frame; The current frame is divided into multiple continuous segments. For the filtered triaxial acceleration data in each segment, the maximum angle between the vector of each sampling point and the average vector of that segment is calculated to obtain the attitude stability characteristics of that segment. The standard deviation of the resultant acceleration magnitude is calculated based on the original triaxial acceleration data of the current frame to obtain the motion disturbance characteristics of the frame; The average attitude unit vector of the current frame is calculated based on the filtered triaxial acceleration data in the current frame, and the angle between the average attitude unit vector and the reference unit vector of the ear side of the earphone in the table-placed posture is calculated to determine whether the attitude state of the current frame is close to the reference state, intermediate state, or deviating significantly. Based on the posture stability characteristics, the motion disturbance characteristics, and the posture states of multiple consecutive frames, it is determined whether the headphones are in a stationary state on a table, and when it is determined to be in a stationary state on a table, a non-wearing state indication is output.
2. The headphone wearing detection method according to claim 1, characterized in that, The raw triaxial acceleration data is collected by the acceleration sensor according to a preset sampling rate; The frame-by-frame caching of the raw triaxial acceleration data includes: The original triaxial acceleration data is divided into frames, with a first number of sampling points as one frame, and the original triaxial acceleration data is cached frame by frame. The step of dividing the current frame into multiple consecutive segments includes: The sampling points of the current frame are divided into multiple consecutive segments in chronological order. Each segment contains a second number of sampling points, and each segment contains the corresponding original triaxial acceleration data and filtered triaxial acceleration data.
3. The headphone wearing detection method according to claim 1, characterized in that, The maximum angle between the vector of each sampling point and the average vector of the sub-segment is calculated from the filtered triaxial acceleration data within each sub-segment to obtain the attitude stability characteristics of the sub-segment, including: The average vector of the current sub-segment is obtained by averaging the multiple filtered triaxial acceleration vectors within the current sub-segment. Divide the average vector and each filtered triaxial acceleration vector in the current sub-segment by their respective magnitudes to obtain the average unit vector and the unit vector of each sampling point. The angle between the unit vector at each sampling point and the average vector is calculated by the normalized vector dot product; The maximum value among the included angles corresponding to the unit vectors of each sampling point in the current sub-segment is determined as the attitude stability feature of the current sub-segment.
4. The headphone wearing detection method according to claim 1, characterized in that, The step of calculating the standard deviation of the resultant acceleration magnitude based on the original triaxial acceleration data of the current frame to obtain the motion disturbance characteristics of the frame includes: Based on the original triaxial acceleration data of each sampling point in the current frame, calculate the sum of squares of the acceleration components of each sampling point in the three axes, and take the square root of the sum of squares to obtain the resultant acceleration magnitude of each sampling point. The average value of the resultant acceleration magnitude is obtained by averaging the resultant acceleration magnitude values of each sampling point in the current frame. Calculate the difference between the resultant acceleration magnitude of each sampling point in the current frame and the average resultant acceleration magnitude, and square the difference to obtain the squared difference for each sampling point. The standard deviation of the sum acceleration magnitude in the current frame is obtained by averaging and taking the square root of the squared differences of the sampling points in the current frame, and is used as the motion disturbance feature of the current frame.
5. The headphone wearing detection method according to claim 1, characterized in that, The step of calculating the average attitude unit vector of the current frame based on the filtered triaxial acceleration data within the current frame includes: The average attitude vector of the current frame is obtained by averaging the filtered triaxial acceleration data of each sampling point in the three-axis direction. Calculate the sum of squares of the components of the average attitude vector in the three-axis directions, and take the square root of the sum of squares to obtain the magnitude of the average attitude vector; Divide the components of the average attitude vector in each of the three axes by the magnitude to obtain the average attitude unit vector of the current frame.
6. The headphone wearing detection method according to claim 5, characterized in that, The step of calculating the angle between the average pose unit vector and the reference unit vector of the earpiece on the table-side to determine whether the pose state of the current frame is close to the reference state, intermediate state, or significantly deviated from the reference state includes: Obtain a pre-calibrated reference unit vector that represents the direction of gravity on the ear side of the earphone when it is placed on a table. Perform a dot product operation between the average attitude unit vector and the reference unit vector to obtain the dot product result; Based on the inverse cosine value of the dot product result, determine the angle between the average attitude unit vector and the reference unit vector; When the included angle is less than the first angle threshold, the attitude state of the current frame is determined to be the close-to-reference state; When the included angle is greater than or equal to the first angle threshold and less than or equal to the second angle threshold, the attitude state of the current frame is determined to be an intermediate state, wherein the first angle threshold is less than the second angle threshold; When the included angle is greater than the second angle threshold, the attitude state of the current frame is determined to be a state with a large deviation.
7. The headphone wearing detection method according to any one of claims 1 to 6, characterized in that, The step of determining whether the headphones are in a stationary state on the table based on the posture stability characteristics, the motion disturbance characteristics, and the posture states of multiple consecutive frames includes: Based on the relationship between the attitude stability features of each sub-segment in the current frame and the preset stability threshold, determine whether the current frame meets the intra-frame stability condition; Based on the relationship between the motion perturbation features of the current frame and the preset perturbation threshold, determine whether the current frame meets the stationary condition; If the first few consecutive frames are in the state of large deviation, it is determined that the headphones are not in the state of being placed still on the table. If the headphones are in the near-reference state for multiple consecutive frames, and the second and third consecutive frames satisfy the static condition and the intra-frame stability condition, then the headphones are determined to be in the table-placed static state. If the third consecutive frame is in the intermediate state, and the second consecutive frame satisfies the static condition and the intra-frame stability condition, then the headphones are determined to be in the table-placed static state. If multiple consecutive frames are in the near-reference state or the third consecutive frames are in the intermediate state, but the second consecutive frames do not satisfy the static condition or the intra-frame stability condition, then it is determined that the headphones are not in the table-placed static state. Wherein, the first number of frames is less than the second number of frames, and the second number of frames is less than or equal to the third number of frames.
8. A headphone wearing detection device, characterized in that, include: The data acquisition module is used to acquire the raw triaxial acceleration data collected by the accelerometer after detecting a reflected signal that meets the wearing conditions, and to cache the raw triaxial acceleration data frame by frame. The filtering module is used to perform low-pass filtering on the original triaxial acceleration data to obtain and buffer the filtered triaxial acceleration data frame by frame; The stability feature determination module is used to divide the current frame into multiple continuous segments, calculate the maximum angle between the vector of each sampling point and the average vector of the segment for the filtered triaxial acceleration data in each segment, and obtain the attitude stability features of the segment. The disturbance feature determination module is used to calculate the standard deviation of the resultant acceleration magnitude based on the original triaxial acceleration data of the current frame, and obtain the motion disturbance features of the frame. The attitude state determination module is used to calculate the average attitude unit vector of the current frame based on the filtered triaxial acceleration data in the current frame, and to calculate the angle between the average attitude unit vector and the reference unit vector of the ear side of the earphone in the table-placed posture, so as to determine whether the attitude state of the current frame is close to the reference state, intermediate state or deviating significantly. The table placement determination module is used to determine whether the earphone is in a table-placed stationary state based on the posture stability characteristics, the motion disturbance characteristics, and the posture states of multiple consecutive frames, and outputs a non-wearing state indication when it is determined to be in a table-placed stationary state.
9. An electronic device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the headphone wearing detection method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the headphone wearing detection method as described in any one of claims 1 to 7.
