Calibration methods, devices, and electronic equipment for electronic compasses
By acquiring the brightness and color information of the display screen, and using a magnetic field interference estimation model to predict and subtract screen interference, the problem of dynamic magnetic field interference experienced by electronic compasses in smart devices is solved, thus improving output accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- VIVO MOBILE COMM CO LTD
- Filing Date
- 2026-03-17
- Publication Date
- 2026-06-30
AI Technical Summary
Electronic compasses in smart devices are affected by dynamic magnetic field interference, which leads to a decrease in output accuracy, and existing technologies are unable to effectively eliminate this interference.
By acquiring the screen brightness and pixel RGB grayscale values of the display, the magnetic field interference estimation model is used to predict the screen interference magnetic field vector value, and vector subtraction correction is performed to directly use the display status information of the electronic device for calibration.
It improves the output accuracy of the electronic compass, reduces the impact of dynamic interference on the display screen, and enhances the purity and precision of the magnetic field data.
Smart Images

Figure CN122306032A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of electronic equipment technology, specifically relating to a calibration method, device, and electronic equipment for an electronic compass. Background Technology
[0002] As electronic devices such as smartphones, tablets, and wearable devices become increasingly complex, the number of integrated magnetic components is constantly increasing, causing significant magnetic field interference to electronic compasses. Some of this interference exhibits dynamic uncertainty, making it difficult to completely eliminate through traditional static calibration.
[0003] To mitigate the aforementioned interference, the industry typically places electronic compasses in areas far from major sources of interference. However, in practical applications, electronic compasses can still be affected by other dynamic changes within the device, leading to a decrease in their output accuracy. Summary of the Invention The purpose of this application is to provide a calibration method, apparatus, and electronic device for an electronic compass, which can improve the output accuracy of the electronic compass.
[0004] In a first aspect, embodiments of this application provide a calibration method for an electronic compass, applied to an electronic device, the electronic device including a display screen and an electronic compass, the method comprising: When the electronic compass is in working condition, the display status of the display screen is acquired; wherein, the display status includes at least one of screen brightness and pixel RGB grayscale values; The calibration value of the electronic compass is determined based on the correspondence between the display status and the calibration value. The electronic compass is calibrated based on the calibration values.
[0005] Secondly, embodiments of this application provide an electronic compass calibration device applied to an electronic device, the electronic device including a display screen and an electronic compass, the device comprising: The acquisition module is used to acquire the display status of the display screen when the electronic compass is in working state; wherein, the display status includes at least one of screen brightness and pixel RGB grayscale value; The determining module is used to determine the calibration value of the electronic compass based on the correspondence between the display status and the calibration value; The calibration module is used to calibrate the electronic compass according to the calibration values.
[0006] Thirdly, embodiments of this application provide an electronic device, which includes a display screen, an electronic compass, a processor, and a memory. The memory stores programs or instructions that can run on the processor, and when the programs or instructions are executed by the processor, they implement the steps of the electronic compass calibration method as described in the first aspect.
[0007] Fourthly, embodiments of this application provide a computer-readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the electronic compass calibration method as described in the first aspect.
[0008] Fifthly, embodiments of this application provide a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being used to run programs or instructions to implement the electronic compass calibration method as described in the first aspect.
[0009] In a sixth aspect, embodiments of this application provide a computer program product stored in a storage medium, which is executed by at least one processor to implement the electronic compass calibration method as described in the first aspect.
[0010] In this embodiment, when the electronic compass is in operation, the display status of the screen is acquired, and the corresponding calibration value is determined based on the correspondence between the display status and the calibration value, thereby calibrating the electronic compass. This calibration process directly utilizes the inherent display status information of the electronic device, without the need for additional hardware. Since the display status reflects the real-time characteristics of the screen during operation, the calibration value determined accordingly can adapt to the interference characteristics of the screen under different states, thereby improving the output accuracy of the electronic compass after calibration. Attached Figure Description
[0011] Figure 1 This is a flowchart of a calibration method for an electronic compass provided in some embodiments of this application; Figure 2 This is a flowchart of a model training method provided in some embodiments of this application; Figure 3 This is a structural block diagram of an electronic compass calibration device provided in some embodiments of this application; Figure 4 This is a schematic diagram of the structure of an electronic device provided in some embodiments of this application; Figure 5 This is a schematic diagram of the hardware structure of an electronic device that implements the various embodiments of this application. Detailed Implementation
[0012] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.
[0013] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0014] The calibration method for the electronic compass provided in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0015] Figure 1 This is a flowchart illustrating a calibration method for an electronic compass provided in some embodiments of this application, applied to an electronic device including a display screen and an electronic compass, such as... Figure 1 As shown, the method may include the following steps: step 101, step 102 and step 103.
[0016] In step 101, while the electronic compass is in working condition, the display status of the display screen is obtained.
[0017] In this embodiment, the display state refers to the characteristic data set of the visual state being presented on the display screen of an electronic device. The display state includes at least one of screen brightness and pixel RGB grayscale values.
[0018] In this embodiment, screen brightness refers to a parameter characterizing the overall luminous intensity of the display screen. For example, it could be a backlight brightness level value provided by the operating system (such as an integer from 0 to 255), a PWM dimming duty cycle, or a standardized relative brightness value. In practical applications, screen brightness can be obtained by querying the system display service interface.
[0019] In this embodiment, the pixel RGB grayscale value refers to the color information of all pixels constituting the current frame screen image, typically represented as a two-dimensional array, with each pixel containing values for three channels: red (R), green (G), and blue (B). In practical applications, the pixel RGB grayscale value can be obtained by reading it from the frame buffer of the electronic device or the output of the graphics processor.
[0020] In this embodiment, the purpose of acquiring the display state of the screen is to establish an input reference for dynamic magnetic field interference compensation. The magnetic field interference of the display screen on the electronic compass originates from the current in the display screen driving circuit, and the amplitude and distribution of this current are dynamically determined by the screen brightness and the light emission state of each pixel. Therefore, the display state is an observable and direct variable that causes dynamic magnetic field interference. Acquiring the display state of the screen captures the real-time operating state of the interference source, providing data input for subsequent quantification of its impact.
[0021] Considering that the displayed content on the screen is constantly changing, such as interface scrolling, video playback, or automatic brightness adjustment, if the compensation algorithm relies on fixed parameters or historical averages, it cannot track such dynamic changes, leading to compensation lag or failure. In this embodiment, by acquiring the current screen brightness and pixel RGB grayscale values in real time, it can be ensured that subsequent processing is always based on the latest interference source state for prediction, possessing the ability to dynamically track and adaptively adjust.
[0022] Furthermore, the display status, as inherent output data of the electronic device's graphic display system, can be directly obtained through the operating system's standard interface without the need for additional sensors. Using this as input allows for the acquisition of the crucial input information required for compensation without increasing the hardware cost or space footprint of the electronic device.
[0023] In step 102, the calibration value of the electronic compass is determined based on the correspondence between the display status and the calibration value.
[0024] In this embodiment of the application, the calibration value refers to the parameter used to calibrate the electronic compass, and its specific form may vary depending on the calibration method.
[0025] In some embodiments, the calibration value can be the screen interference magnetic field vector value, that is, the three-dimensional magnetic field interference generated by the display screen in the current display state and acting on the position of the electronic compass. This form has a clear physical meaning, can be directly used for vector subtraction compensation, and is consistent with the original reading format of the electronic compass, which facilitates subsequent processing.
[0026] In other embodiments, the calibration value may also be other forms such as magnetic field compensation amount, correction coefficient matrix, angle compensation value or hard magnetic offset, as long as the electronic compass can be calibrated based on the correspondence between the display status and the calibration value.
[0027] In this embodiment, the correspondence between the display state and the calibration value refers to the mapping rule between the display state of the screen (including at least one of screen brightness and pixel RGB grayscale values) and the calibration value required by the electronic compass. This correspondence can be a pre-established function, a lookup table, or a pre-trained magnetic field interference estimation model.
[0028] In step 103, the electronic compass is calibrated according to the calibration values.
[0029] In this embodiment of the application, the correction process refers to the operation of correcting the original output of the electronic compass based on the calibration value. Its purpose is to eliminate or reduce the magnetic field interference component caused by the dynamic display state of the display screen, so that the corrected magnetic field data is closer to the real geomagnetic field, thereby improving the output accuracy of the electronic compass.
[0030] In some embodiments, when the calibration value is the screen interference magnetic field vector value, the correction process is a vector subtraction process. Specifically, the original magnetic field vector value detected by the electronic compass of the electronic device is obtained; the vector difference between the original magnetic field vector value and the screen interference magnetic field vector value is calculated, and this vector difference is determined as the compensated magnetic field vector value.
[0031] In this embodiment, the original magnetic field vector value refers to the triaxial magnetic field data directly measured and output by the electronic compass before undergoing the compensation processing of this method. This data is the vector superposition result of multiple magnetic field sources, including the real Earth's magnetic field, equipment hard magnetic interference, environmental soft magnetic interference, and screen dynamic interference. Typically, the original magnetic field vector value detected by the electronic compass is read synchronously or asynchronously at a predetermined sampling frequency through the sensor service interface of the operating system.
[0032] In this embodiment, vector difference refers to the subtraction operation between two three-dimensional vectors. In three-dimensional space, if vector A = (A... x A y A z ), vector B = (B x B y B z If the vector difference is C = AB = (A), then the vector difference is C = AB = (A). x -B x A y -B y A z -B z The result of this operation, C, is still a three-dimensional vector.
[0033] In the embodiments of this application, vector A represents the original magnetic field vector M. rawIt is caused by real geomagnetic field, fixed hard / soft magnetic interference of equipment, environmental interference, and screen dynamic interference. screen The vector sum. Vector B represents the screen interference magnetic field vector M. pred It is for M screen Component estimation. Therefore, perform M. comp =M raw -M pred Physically, this is equivalent to subtracting (or canceling out) the interference field component generated by the screen from the total measurement field. The resulting vector M comp The goal of the (compensated magnetic field vector) is to more closely approximate the vector sum of the real Earth's magnetic field and other non-screen fixed disturbances, thereby providing a cleaner input for direction calculation.
[0034] For example, at time t, the original magnetic field vector read by the electronic compass is: M raw =[100.5, -15.2, 45.8]μT, the screen interference magnetic field vector predicted by the magnetic field interference estimation model is: M pred =[2.1, 0.5, -1.3]μT, then the compensated magnetic field vector is: M comp =M raw -M pred =[100.5-2.1, (-15.2)-0.5, 45.8-(-1.3)]=[98.4,-15.7, 47.1]μT.
[0035] In this embodiment, by calibrating the electronic compass, the predicted screen interference is separated and removed from the mixed signal, making the magnetic field data output to upper-layer applications (such as compasses and navigation) purer and less affected by the dynamic display of the screen.
[0036] In this embodiment, the compensated magnetic field is determined by calculating the vector difference between the original magnetic field vector value and the screen interference magnetic field vector value. This operation has a clear physical meaning, reflects the intention to remove the predicted interference component from the total signal, and is logically clear and easy to implement. Three-dimensional vector subtraction, as a basic arithmetic operation, has low computational overhead and introduces almost no processing delay, which can match the high sampling frequency of the electronic compass, thus ensuring the high efficiency and real-time performance of the compensation process.
[0037] As can be seen from the above embodiments, in this embodiment, when the electronic compass is in working condition, the display status of the screen is acquired, and the corresponding calibration value is determined based on the correspondence between the display status and the calibration value, thereby calibrating the electronic compass. This calibration process directly utilizes the inherent display status information of the electronic device, without the need for additional hardware. Since the display status can reflect the real-time characteristics of the screen during operation, the calibration value determined accordingly can adapt to the interference characteristics of the screen under different states, thereby improving the output accuracy of the electronic compass after calibration.
[0038] In some embodiments provided in this application, when the calibration value is the screen interference magnetic field vector value, the screen interference magnetic field vector value can be determined by using a magnetic field interference estimation model. Accordingly, the above step 102 may specifically include the following steps: Step 1021.
[0039] In step 1021, the display state of the display screen is processed by the magnetic field interference estimation model to obtain the screen interference magnetic field vector value corresponding to the display state; wherein, the magnetic field interference estimation model is trained to record the correspondence between the screen display state and the screen interference magnetic field vector value.
[0040] In this embodiment, the magnetic field interference estimation model is a mathematical model or algorithm trained through machine learning that can establish a nonlinear correspondence between the "display state" and the "interference magnetic field vector sensed at the electronic compass." Its core function is fitting and prediction. Taking the display state of the screen (screen brightness and pixel RGB grayscale values) as input, the model outputs a three-dimensional vector value (the screen interference magnetic field vector value) through a computational graph (such as forward propagation). The three component values estimate the magnitude of the interference magnetic field generated by the display drive circuit on the X, Y, and Z sensitive axes of the electronic compass under the current display state.
[0041] In this embodiment, the display state is used as input to the magnetic field interference estimation model. This is based on the definite correspondence between the display state and the interfering magnetic field in a given hardware design, and this mapping can be learned from data through machine learning. By acquiring the current display state and inputting it into the magnetic field interference estimation model, the conversion from display information to the interfering magnetic field can be achieved. This conversion is based on the correspondence between the display state and electromagnetic coupling characteristics under specific device hardware, learned by the model during the training phase.
[0042] In some embodiments, step 1021 may specifically include the following steps: step 10211 and step 10212.
[0043] In step 10211, a single-channel brightness matrix with the same spatial size as the displayed image is generated according to the screen brightness, and the single-channel brightness matrix is concatenated with the image feature matrix constructed based on the pixel RGB grayscale values to obtain the input tensor of the convolutional neural network model.
[0044] In this embodiment, the single-channel luminance matrix is a two-dimensional matrix with the same number of rows and columns as the resolution of the current display screen (height H pixels, width W pixels), and the value of all elements in the matrix is equal to the current screen brightness. The image feature matrix is a multi-channel matrix obtained by formatting the original pixel data. For an RGB image, its size is H×W×3, and each channel corresponds to the R, G, and B color components. Channel concatenation refers to merging the single-channel luminance matrix (H×W×1) and the RGB image feature matrix (H×W×3) in the channel dimension to obtain a four-channel input tensor (H×W×4). This input tensor serves as the direct input object for the forward propagation calculation of the convolutional neural network model.
[0045] For example, the current screen resolution is 1080×1920, the normalized value of the brightness parameter is 0.7, and the current image is an RGB color image. First, a single-channel brightness matrix of size 1080×1920 is created, with all element values of 0.7. The original RGB pixel data constitutes a 1080×1920×3 image feature matrix. The two matrices are concatenated in the third dimension to obtain a 1080×1920×4 input tensor, which fully contains the color information and corresponding brightness information of the displayed image.
[0046] In this embodiment, by expanding the global brightness scalar into a matrix with the same size as the image space and concatenating it with pixel data, spatial alignment and deep fusion of brightness information and image information are achieved. This construction method enables the convolutional neural network to simultaneously perceive the brightness context corresponding to each spatial location when extracting local image features, which is closer to the physical nature of screen display interference, namely the spatial correlation between the interfering magnetic field and the luminous state of each point on the screen. The constructed multi-channel input tensor transforms the problem into an image regression task suitable for convolutional neural network processing, making full use of its architectural advantages in processing spatially correlated data, enabling it to automatically learn the complex spatial patterns of interference caused by the combined effect of brightness and image content.
[0047] In step 10212, the input tensor is input into the magnetic field interference estimation model for processing to obtain the screen interference magnetic field vector value corresponding to the display state.
[0048] In this embodiment, the input tensor passes through each layer of the model sequentially, with each layer performing specific mathematical transformations on the data, ultimately producing a three-dimensional vector result at the output layer. The shallow network captures the correlation patterns between local brightness and color, while the deep network fuses global information, finally outputting accurate physical quantity predictions via a fully connected layer. The three-dimensional magnetic field vector output by the model is consistent with the original data format of the electronic compass and can be directly used for subsequent vector subtraction compensation without additional format conversion.
[0049] In some embodiments, the magnetic field interference estimation model can be a lightweight convolutional neural network model, which, due to its low computational complexity, is suitable for real-time operation in resource-constrained environments such as mobile electronic devices. Furthermore, the lightweight model possesses millisecond-level inference capabilities, and its processing speed matches the screen refresh rate and electronic compass sampling rate, ensuring that synchronous interference prediction values are generated for every frame of display change, thereby reducing power consumption while maintaining real-time performance.
[0050] As can be seen, in this embodiment, a software model replaces a physical sensor, and the interference magnetic field is indirectly calculated using the upstream signal of the display screen's display status, thereby avoiding the cost and space occupation caused by adding physical sensors. The screen interference magnetic field vector output by the model serves as a calibration value, providing a clear operational object for subsequent correction processing, enabling the removal of the screen interference component from the mixed magnetic field signal.
[0051] In some embodiments provided in this application, to ensure that the magnetic field interference estimation model has high-precision prediction capabilities, it needs to be specially trained. Specifically, such as... Figure 2 As shown, the magnetic field interference estimation model is trained through the following steps: Step 201 and Step 202.
[0052] In step 201, a dataset is obtained; wherein, the dataset includes multiple sets of display state samples collected under known display states and the corresponding true values of electronic compass magnetic field measurements.
[0053] In this embodiment of the application, the dataset refers to a structured collection of data used to train a machine learning model, wherein each sample contains input features and a corresponding target value (label). The dataset may contain thousands to tens of thousands of such sample pairs, broadly covering typical and extreme display scenarios that the device may encounter.
[0054] In this embodiment of the application, the known display state refers to the screen display conditions that are manually set or precisely recorded during the data acquisition process to ensure that the input of each sample is clear and controllable.
[0055] In this embodiment of the application, the true value of the electronic compass magnetic field measurement refers to the three-axis magnetic field vector reading actually measured and recorded by the electronic compass under the aforementioned known display state. This reading serves as a monitoring signal, representing the result of the combined effect of the interference magnetic field actually generated by the screen and other fixed interferences under this specific display state. In step 202, the input tensor of the initial convolutional neural network model is constructed based on the displayed state samples, and the magnetic field measurement truth value is used as the output target. The initial convolutional neural network model is trained by supervised learning to obtain the magnetic field interference estimation model.
[0056] In this embodiment, constructing the input tensor of the initial convolutional neural network model based on display state samples refers to generating a multi-dimensional array that meets the input requirements of the convolutional neural network based on the screen brightness parameters and pixel RGB grayscale values in the display state samples. Specifically, firstly, a single-channel brightness matrix with the same spatial size as the displayed screen is generated based on the screen brightness. The number of rows and columns of this matrix is equal to the height H and width W of the current displayed screen, and the value of all elements in the matrix is equal to the screen brightness. Simultaneously, an image feature matrix is constructed based on the pixel RGB grayscale values. For RGB images, this matrix is a three-dimensional array with a size of H×W×3, and each channel corresponds to the R, G, and B color components, respectively. Then, the single-channel brightness matrix and the image feature matrix are concatenated along the channel dimension to obtain a four-channel input tensor with a size of H×W×4. This input tensor serves as the direct input object for the convolutional neural network model to perform forward propagation calculations.
[0057] In this embodiment, during supervised learning training, the model adjusts its internal parameters by comparing the difference between the predicted output and the true value, gradually reducing the prediction error. The initial neural network model is a network structure to be trained with random or specific initialized weights before training, and has not yet learned any correspondences. After training, the model's internal parameters are optimized and fixed, enabling it to perform forward propagation calculations on new display states and output a predicted vector that approximates the real interference magnetic field.
[0058] For example, preprocessed display state samples are input into the initial convolutional neural network model in batches to obtain the predicted magnetic field vectors for each batch. The loss (e.g., mean squared error) between the predicted vectors and the true values of the same batch is calculated. To improve generalization ability, an L2 regularization term can be introduced into the loss function to constrain the weight values to converge towards a smaller value, thereby suppressing overfitting. Subsequently, the gradient of the loss function with respect to the parameters of each layer is calculated based on the backpropagation algorithm, and an optimizer (e.g., Adam) is used to iteratively update the parameters. The above process is repeated until the overall prediction error of the model on the dataset converges to a predetermined range.
[0059] As can be seen, in this embodiment, through supervised learning training, the model automatically establishes an end-to-end correspondence between the original display information and the interference magnetic field vector. This process does not require manual design of intermediate features or reliance on precise physical formulas. The model can autonomously uncover the deep correlation between visual features such as texture, edges, and color distribution in the displayed image and spatial magnetic field disturbances, ultimately fitting the physical laws behind the data with high precision, ensuring the accuracy of the predicted values in the real-time compensation stage.
[0060] In some embodiments provided in this application, the initial convolutional neural network model described above may include: three convolutional blocks connected in sequence, a flattening layer connected to the third convolutional block, and at least one fully connected layer connected to the flattening layer; at least one of the three convolutional blocks includes a depth-separable convolutional layer.
[0061] In this embodiment, a convolutional block refers to the basic unit in a convolutional neural network that performs a complete feature extraction. A convolutional block typically contains multiple ordered computational layers, such as convolutional layers (for feature extraction), activation function layers (e.g., ReLU, which introduces nonlinearity), pooling layers (for downsampling, reducing spatial size and enhancing feature invariance), and optionally, batch normalization layers (to accelerate training and stabilize the network). Three sequentially connected convolutional blocks constitute the backbone of the model's feature extraction. The input tensor passes through these three convolutional blocks sequentially, with its spatial size gradually decreasing (through pooling) while the number of feature channels gradually increases, indicating that the features extracted from the original input evolve from low-level and local to high-level and abstract.
[0062] Depthwise separable convolutional layers are an efficient convolutional operation that decomposes standard convolution into two independent steps: depthwise convolution (performing spatial convolution on each input channel separately) and pointwise convolution (using 1×1 convolution to combine information from each channel). Compared to standard convolution, depthwise separable convolution reduces the number of model parameters and computational cost while maintaining similar expressive power. Depthwise separable convolutional layers are introduced as the core convolutional layer in at least one convolutional block, and they are a key technology for achieving lightweight models, ensuring efficient operation in resource-constrained environments such as mobile devices.
[0063] A flattening layer is a data reshaping layer that transforms multi-dimensional feature maps into one-dimensional feature vectors. Its function is to convert spatial structural features into a vector form suitable for processing by fully connected layers. Located after the third convolutional block, the flattening layer flattens the spatially dimensional feature map output from the last convolutional block, preparing input data for subsequent fully connected layers.
[0064] A fully connected layer is a type of neural network layer in which each neuron is connected to all neurons in the layer above. It excels at combining and nonlinearly combining features and is often used for classification or regression tasks. A fully connected layer follows a flattened layer. At least one fully connected layer (which may include one or more hidden layers and a final output layer) maps the flattened high-level feature vector to the target output space. The final output layer is typically a fully connected layer with three neurons that directly outputs the predicted three-dimensional screen interference magnetic field vector.
[0065] For example, the input is a tensor of size [H, W, 4]. Convolutional block 1 contains a depthwise separable convolutional layer (outputting 16 channels), followed by ReLU activation, 2×2 max pooling (size halved), and batch normalization, with an output size of [H / 2, W / 2, 16]. Convolutional block 2 has a similar structure to block 1, with a depthwise separable convolutional layer outputting 32 channels, followed by pooling, etc., with an output size of [H / 4, W / 4, 32]. Convolutional block 3 has a similar structure to convolutional block 2, with a depthwise separable convolutional layer outputting 32 channels, followed by pooling, etc., with an output size of [H / 8, W / 8, 32]. The flattening layer flattens the feature map of [H / 8, W / 8, 32] into a one-dimensional vector of length (H / 8 × W / 8 × 32). The fully connected layer may include a hidden layer with 128 neurons and an output layer with 3 neurons, ultimately outputting a three-dimensional vector.
[0066] As can be seen, in this embodiment, by introducing depthwise separable convolutional layers, the network structure reduces the number of parameters and computational complexity while maintaining feature extraction capabilities. This results in a small-sized, fast-inference model suitable for deployment on resource-constrained mobile electronic devices, enabling low-power, real-time interference prediction. Three sequentially connected convolutional blocks form a hierarchical feature learning path: shallow blocks capture local display patterns (such as edges and textures), while deeper blocks fuse information from a wider receptive field, learning the correlation between global display content and interference, thus comprehensively understanding the combined impact of display states on the magnetic field. The combination of flattening layers and fully connected layers achieves global synthesis and nonlinear transformation of high-level spatial features, ultimately accurately regressing to a continuous magnetic field vector. This lightweight approach ensures the model's expressive power and generalization performance across different display scenarios.
[0067] In some embodiments provided in this application, in order to optimize the resource utilization and power consumption of electronic devices while ensuring the compensation effect, the above step 101 can be implemented through a conditional triggering mechanism. Specifically, the above step 101 may include the following steps: Step 1011.
[0068] In step 1011, the display state of the display screen is obtained when the preset trigger conditions are met; wherein the trigger conditions include at least one of the following: the display screen is turned on, the screen brightness changes, and the pixel RGB grayscale value changes.
[0069] In this embodiment of the application, the preset triggering condition refers to a set of pre-set logical judgment rules or event signals used to determine whether it is necessary to immediately or frequently execute the display status acquisition and subsequent compensation calculation.
[0070] In this embodiment of the application, the display being turned on refers to the state transition event in which the display changes from a closed (screen off) state to an open (screen on) state and displays content.
[0071] In this embodiment, a change in screen brightness refers to a change in the overall backlight brightness or pixel self-illumination brightness of the display screen, including but not limited to: adjusting by manually sliding the brightness bar, adjusting by the automatic brightness function, or adjusting the system brightness due to application switching or scene switching.
[0072] In this embodiment of the application, a change in the RGB grayscale value of a pixel, i.e., a change in the displayed content, refers to any situation in which the image data in the display frame buffer is updated, including but not limited to: user interaction (such as touch swiping, application switching), dynamic content playback (such as video, animation), system interface updates, etc.
[0073] In this embodiment, the high-frequency or real-time information acquisition and subsequent compensation process is only initiated when an event occurs that may cause a significant change in the interfering magnetic field. When the display state remains stable, the acquisition frequency can be reduced or the existing compensation value can be maintained, thereby saving processing resources and power consumption.
[0074] For example, taking the display screen being turned on as an example, when a user presses the power button or raises their wrist (on a smartwatch) to turn on the screen, the electronic device detects the event that the display screen is turned on and immediately triggers a complete process of obtaining and compensating for display status information.
[0075] For example, taking changes in displayed content as an example, when a user scrolls through a webpage, plays a video, or switches applications, the electronic device detects the change in displayed content by monitoring updates to the graphics compositor or frame buffer, triggering a new round of information acquisition and compensation.
[0076] For example, taking brightness adjustment as an example, when a user manually adjusts the brightness slider, or when an electronic device moves from indoors to outdoors, causing automatic brightness adjustment to take effect, the electronic device detects the brightness adjustment event and triggers a compensation process to adapt to the interference characteristics under the new brightness level.
[0077] As can be seen, in this embodiment, an event-driven mechanism with preset trigger conditions achieves an intelligent balance between power consumption optimization and real-time response. This mechanism replaces the traditional fixed-frequency polling method. When the display status is stable, the electronic device does not need to perform continuous high-energy-consuming information acquisition and model calculation, thereby reducing the average processor load and overall device power consumption, which helps to extend the battery life of battery-powered devices. At the same time, the trigger conditions accurately cover all key operations and events that may cause changes in magnetic field interference, ensuring that the electronic device can immediately start the compensation process once an event occurs, guaranteeing the real-time performance of interference prediction and compensation, and avoiding compensation delays caused by timing sampling lags.
[0078] In some embodiments provided in this application, the provided electronic compass calibration method can also adapt to and effectively compensate for magnetic field interference generated by more complex display hardware configurations. Specifically, when the display screen is a deformable screen, the display state also includes the morphological parameters of the display screen; when the electronic device includes multiple display screens, the display state includes the screen brightness and pixel RGB grayscale values corresponding to each of the active display screens.
[0079] In this embodiment, the deformable screen may include a foldable screen, a rollable screen, or a flexible screen. Changes in its physical form (such as bending angle, radius of curvature, and folding state) will affect the distribution path of the current inside the screen and its relative spatial position and electromagnetic coupling relationship with the electronic compass, thereby dynamically changing the characteristics of the interference magnetic field.
[0080] In this embodiment, morphological parameters are quantitative parameters describing the current physical bending or deformation state of the screen, such as data from hinge angle sensors, bending strain sensors, or gyroscopes, used to indicate the screen's folding angle, bending curvature, or unfolding percentage. In foldable screen devices, morphological parameters can characterize whether the device is in a fully unfolded, partially folded, or fully closed state; for rollable screen devices, morphological parameters can characterize the screen's extended length.
[0081] In this embodiment, morphological parameters are input into the magnetic field interference estimation model as part of the display state. This allows the model to learn and compensate for additional magnetic field interference introduced by changes in the physical shape of the screen, thus freeing the compensation scheme from being limited to a fixed screen shape. Regardless of the usage state of the electronic device, this embodiment can dynamically adjust based on real-time morphological parameters to ensure that the electronic compass maintains high-precision direction output under various physical conditions.
[0082] In this embodiment, when the electronic device includes multiple displays, each active screen generates its own driving current, creating superimposed magnetic field interference at the electronic compass. The display status includes the brightness and pixel RGB grayscale values of all active screens, and these must be acquired synchronously or quasi-synchronously. For example, in a dual-screen phone, when the main screen and the secondary screen are simultaneously lit up displaying different content, the display status of both is acquired simultaneously; in a foldable screen device, the display status of both the inner and outer screens can be acquired simultaneously.
[0083] In this embodiment, by simultaneously acquiring the display status of all active screens, the magnetic field interference estimation model can predict the total interference field generated by the combined effect of multiple screens, achieving comprehensive modeling and compensation for complex interference sources. In complex interactive scenarios such as multi-tasking and cross-screen collaboration supported by multi-screen devices, the output of the electronic compass remains stable and reliable regardless of which screen combinations are working.
[0084] In summary, the embodiments of this application can be flexibly extended to deformable screens or multi-screen devices. By incorporating screen shape parameters or the display states of multiple screens into the model input, comprehensive compensation for interference in more complex display scenarios can be achieved.
[0085] The electronic compass calibration method provided in this application can be executed by an electronic compass calibration device. This application uses an electronic compass calibration device executing the electronic compass calibration method as an example to illustrate the electronic compass calibration device provided in this application.
[0086] Figure 3 This is a structural block diagram of an electronic compass calibration device provided in some embodiments of this application. The device is applied to an electronic device, which includes a display screen and an electronic compass, such as... Figure 3 As shown, the electronic compass calibration device 300 may include: an acquisition module 301, a determination module 302, and a calibration module 303; The acquisition module 301 is used to acquire the display status of the display screen when the electronic compass is in working state; wherein, the display status includes at least one of screen brightness and pixel RGB grayscale value; The determining module 302 is used to determine the calibration value of the electronic compass based on the correspondence between the display status and the calibration value; The calibration module 303 is used to calibrate the electronic compass according to the calibration value.
[0087] As can be seen from the above embodiments, in this embodiment, when the electronic compass is in working condition, the display status of the screen is acquired, and the corresponding calibration value is determined based on the correspondence between the display status and the calibration value, thereby calibrating the electronic compass. This calibration process directly utilizes the inherent display status information of the electronic device, without the need for additional hardware. Since the display status can reflect the real-time characteristics of the screen during operation, the calibration value determined accordingly can adapt to the interference characteristics of the screen under different states, thereby improving the output accuracy of the electronic compass after calibration.
[0088] Optionally, as an embodiment, the calibration value is the screen interference magnetic field vector value; The determining module 302 is specifically used to process the display state through a magnetic field interference estimation model to obtain the screen interference magnetic field vector value corresponding to the display state; wherein, the magnetic field interference estimation model is trained to record the correspondence between the screen display state and the screen interference magnetic field vector value.
[0089] Optionally, as an embodiment, the electronic compass calibration device 300 may further include: A training module is used to acquire a dataset; wherein, the dataset includes multiple sets of display state samples collected under known display states and corresponding true values of electronic compass magnetic field measurements; based on the display state samples, an input tensor for an initial convolutional neural network model is constructed, with the true value of the magnetic field measurement as the output target, and the initial convolutional neural network model is trained by supervised learning to obtain the magnetic field interference estimation model; The initial convolutional neural network model includes: three convolutional blocks connected in sequence, a flattening layer connected to the third convolutional block, and at least one fully connected layer connected to the flattening layer; at least one of the three convolutional blocks contains a depth-separable convolutional layer.
[0090] Optionally, as an embodiment, the acquisition module 301 is specifically used to acquire the display state of the display screen when a preset triggering condition is met; The triggering conditions include at least one of the following: the display screen is turned on, the screen brightness changes, or the pixel RGB grayscale value changes.
[0091] Optionally, as an embodiment, when the display screen is a deformable screen, the display state also includes the shape parameters of the display screen; In the case where the electronic device includes multiple displays, the display state includes the screen brightness and pixel RGB grayscale value corresponding to each of the displays that are in an active state.
[0092] The calibration device for the electronic compass in this application embodiment can be an electronic device or a component within an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices besides a terminal. For example, the electronic device can be a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. This application embodiment does not specifically limit the specific device.
[0093] The electronic compass calibration device in this embodiment can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this embodiment does not specifically limit the specific operating system used.
[0094] The electronic compass calibration device provided in this application embodiment can achieve the above-mentioned... Figure 1 To avoid repetition, the various processes implemented in the method embodiment shown will not be described again here.
[0095] Optionally, such as Figure 4 As shown, this application embodiment also provides an electronic device 400, including a processor 401 and a memory 402. The memory 402 stores a program or instructions that can run on the processor 401. When the program or instructions are executed by the processor 401, they implement the various steps of the above-described electronic compass calibration method embodiment and can achieve the same technical effect. To avoid repetition, they will not be described again here.
[0096] It should be noted that the electronic devices in the embodiments of this application include the mobile electronic devices and non-mobile electronic devices described above.
[0097] Figure 5 This is a schematic diagram of the hardware structure of an electronic device that implements the various embodiments of this application.
[0098] The electronic device 500 includes, but is not limited to, components such as: radio frequency unit 501, network module 502, audio output unit 503, input unit 504, sensor 505, display unit 506, user input unit 507, interface unit 508, memory 509, and processor 510.
[0099] Those skilled in the art will understand that the electronic device 500 may also include a power supply (such as a battery) for supplying power to various components. The power supply may be logically connected to the processor 510 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system. Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements, which will not be elaborated here.
[0100] In some embodiments, the processor 510 is configured to acquire the display status of the display screen when the electronic compass is in operation; wherein the display status includes at least one of screen brightness and pixel RGB grayscale values; determine the calibration value of the electronic compass according to the correspondence between the display status and the calibration value; and calibrate the electronic compass according to the calibration value.
[0101] As can be seen, in this embodiment, when the electronic compass is in operation, the display status of the screen is acquired, and the corresponding calibration value is determined based on the correspondence between the display status and the calibration value, thereby calibrating the electronic compass. This calibration process directly utilizes the inherent display status information of the electronic device, without the need for additional hardware. Since the display status can reflect the real-time characteristics of the screen during operation, the calibration value determined accordingly can adapt to the interference characteristics of the screen under different states, thereby improving the output accuracy of the electronic compass after calibration.
[0102] Optionally, as an embodiment, the calibration value is the screen interference magnetic field vector value; The processor 510 is specifically used to process the display state through a magnetic field interference estimation model to obtain the screen interference magnetic field vector value corresponding to the display state; wherein, the magnetic field interference estimation model is trained to record the correspondence between the screen display state and the screen interference magnetic field vector value.
[0103] Optionally, as an embodiment, the processor 510 is further configured to acquire a dataset; wherein the dataset includes multiple sets of display state samples collected under known display states and corresponding true values of electronic compass magnetic field measurements; based on the display state samples, an input tensor for an initial convolutional neural network model is constructed, with the true value of the magnetic field measurement as the output target, and the initial convolutional neural network model is trained by supervised learning to obtain the magnetic field interference estimation model; The initial convolutional neural network model includes: three convolutional blocks connected in sequence, a flattening layer connected to the third convolutional block, and at least one fully connected layer connected to the flattening layer; at least one of the three convolutional blocks contains a depth-separable convolutional layer.
[0104] Optionally, as an embodiment, the processor 510 is specifically used to obtain the display state of the display screen when a preset triggering condition is met; The triggering conditions include at least one of the following: the display screen is turned on, the screen brightness changes, or the pixel RGB grayscale value changes.
[0105] Optionally, as an embodiment, when the display screen is a deformable screen, the display state also includes the shape parameters of the display screen; In the case where the electronic device includes multiple displays, the display state includes the screen brightness and pixel RGB grayscale value corresponding to each of the displays that are in an active state.
[0106] It should be understood that, in this embodiment, the input unit 504 may include a graphics processing unit (GPU) 5041 and a microphone 5042. The GPU 5041 processes image data of still images or videos obtained by an image capture device (such as a camera) in video capture mode or image capture mode. The display unit 506 may include a display panel 5061, which may be configured in the form of a liquid crystal display, an organic light-emitting diode, or the like. The user input unit 507 includes at least one of a touch panel 5071 and other input devices 5072. The touch panel 5071 is also called a touch screen. The touch panel 5071 may include a touch detection device and a touch controller. Other input devices 5072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, and joysticks, which will not be described in detail here.
[0107] The memory 509 can be used to store software programs and various data. The memory 509 may primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area may store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, the memory 509 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (Synchlink DRAM, SLDRAM), and direct memory bus RAM (DRRAM). The memory 509 in this embodiment includes, but is not limited to, these and any other suitable types of memory.
[0108] Processor 510 may include one or more processing units; optionally, processor 510 integrates an application processor and a modem processor, wherein the application processor mainly handles operations involving the operating system, user interface, and applications, and the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into processor 510.
[0109] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described electronic compass calibration method embodiments and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0110] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0111] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described electronic compass calibration method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0112] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.
[0113] This application provides a computer program product, which is stored in a storage medium and executed by at least one processor to implement the various processes of the above-described electronic compass calibration method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.
[0114] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. 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 apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0115] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0116] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for calibrating an electronic compass, characterized in that, Applied to an electronic device, the electronic device including a display screen and an electronic compass, the method includes: When the electronic compass is in working condition, the display status of the display screen is acquired; wherein, the display status includes at least one of screen brightness and pixel RGB grayscale values; The calibration value of the electronic compass is determined based on the correspondence between the display status and the calibration value. The electronic compass is calibrated based on the calibration values.
2. The method according to claim 1, characterized in that, The calibration value is the screen interference magnetic field vector value; Determining the calibration value of the electronic compass based on the correspondence between the display status and the calibration value includes: The display state is processed by a magnetic field interference estimation model to obtain the screen interference magnetic field vector value corresponding to the display state; wherein, the magnetic field interference estimation model is trained to record the correspondence between the screen display state and the screen interference magnetic field vector value.
3. The method according to claim 2, characterized in that, The magnetic field disturbance estimation model was trained in the following manner: Acquire a dataset; wherein the dataset includes multiple sets of display state samples collected under known display states and the corresponding true values of electronic compass magnetic field measurements; The input tensor of the initial convolutional neural network model is constructed based on the displayed state samples. The magnetic field measurement true value is used as the output target. The initial convolutional neural network model is trained by supervised learning to obtain the magnetic field interference estimation model. The initial convolutional neural network model includes: three convolutional blocks connected in sequence, a flattening layer connected to the third convolutional block, and at least one fully connected layer connected to the flattening layer. At least one of the three convolutional blocks contains a depth-separable convolutional layer.
4. The method according to claim 1, characterized in that, The step of obtaining the display status of the display screen includes: Under the condition that the preset triggering conditions are met, the display status of the display screen is obtained; The triggering conditions include at least one of the following: the display screen is turned on, the screen brightness changes, or the pixel RGB grayscale value changes.
5. The method according to claim 1, characterized in that: When the display screen is a deformable screen, the display state also includes the shape parameters of the display screen; In the case where the electronic device includes multiple displays, the display state includes the screen brightness and pixel RGB grayscale value corresponding to each of the displays that are in an active state.
6. A calibration device for an electronic compass, characterized in that, Applied to an electronic device, the electronic device including a display screen and an electronic compass, the device includes: The acquisition module is used to acquire the display status of the display screen when the electronic compass is in working state; wherein, the display status includes at least one of screen brightness and pixel RGB grayscale value; The determining module is used to determine the calibration value of the electronic compass based on the correspondence between the display status and the calibration value; The calibration module is used to calibrate the electronic compass according to the calibration values.
7. The apparatus according to claim 6, characterized in that, The calibration value is the screen interference magnetic field vector value; The determining module is specifically used to process the display state through a magnetic field interference estimation model to obtain the screen interference magnetic field vector value corresponding to the display state; wherein, the magnetic field interference estimation model is trained to record the correspondence between the screen display state and the screen interference magnetic field vector value.
8. The apparatus according to claim 7, characterized in that, The device further includes: A training module is used to acquire a dataset; wherein, the dataset includes multiple sets of display state samples collected under known display states and corresponding true values of electronic compass magnetic field measurements; based on the display state samples, an input tensor for an initial convolutional neural network model is constructed, with the true value of the magnetic field measurement as the output target, and the initial convolutional neural network model is trained by supervised learning to obtain the magnetic field interference estimation model; The initial convolutional neural network model includes: three convolutional blocks connected in sequence, a flattening layer connected to the third convolutional block, and at least one fully connected layer connected to the flattening layer; at least one of the three convolutional blocks contains a depth-separable convolutional layer.
9. The apparatus according to claim 6, characterized in that, The acquisition module is specifically used to acquire the display status of the display screen when a preset triggering condition is met. The triggering conditions include at least one of the following: the display screen is turned on, the screen brightness changes, or the pixel RGB grayscale value changes.
10. The apparatus according to claim 6, characterized in that: When the display screen is a deformable screen, the display state also includes the shape parameters of the display screen; In the case where the electronic device includes multiple displays, the display state includes the screen brightness and pixel RGB grayscale value corresponding to each of the displays that are in an active state.
11. An electronic device, characterized in that, The electronic device includes a display screen, an electronic compass, a processor, and a memory, the memory storing programs or instructions that can run on the processor, the programs or instructions being executed by the processor to implement the steps of the calibration method for the electronic compass as described in any one of claims 1 to 5.