Geomagnetic sensor calibration method for monocular panorama camera space orientation
By pre-calibrating the geomagnetic sensor of the monocular panoramic camera and automatically eliminating interference, the problem of the panoramic camera lacking direction identification is solved, and user-friendly magnetic direction angle shooting is achieved.
Patent Information
- Application Number
- CN202510837303.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-23
- Publication Date
- 2025-09-12
AI Technical Summary
Existing panoramic cameras lack a direction identification function, which makes it difficult for users to quickly determine the direction and increases the time cost of shooting panoramic images with magnetic direction angles.
This paper provides a spatial orientation geomagnetic sensor calibration method for a monocular panoramic camera. The method includes pre-calibrating the variable magnetic field interference of a magnetic encoding servo before shipment, automatically eliminating the interference of the magnetic encoding servo and the mainboard load current during the camera shooting process, and calculating the magnetic direction angle using an elliptical equation.
Automatic calibration of the geomagnetic sensor is achieved when taking photos, which improves the user experience and simplifies the process of taking panoramic images with magnetic direction angles.
Smart Images

Figure CN120630079A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of panoramic image shooting, and in particular to a geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera. Background Art
[0002] Geomagnetic sensors are devices used to measure the strength of the Earth's magnetic field. They are widely used in navigation systems, drones, smartphones, and robots to provide directional perception and attitude estimation. In photography, geomagnetic sensors can be used to determine the camera's orientation angle, assisting with applications such as panoramic photography, automatic composition, and geotagging.
[0003] The application demand for panoramic images in the fields of home furnishing, cultural tourism, surveying and mapping, outdoor photography, etc. has increased dramatically. Existing panoramic cameras generally lack the function of direction identification, which makes it difficult for users to quickly determine the direction through the image, seriously affecting the application effect in scenes such as field exploration and emergency rescue. In the existing technology, panoramic cameras for taking panoramic images are mostly binocular panoramic cameras or multi-eye panoramic cameras. If you want to take a panoramic image with a magnetic direction angle, you need to use the figure-eight method to manually calibrate (three-dimensionally). If the geomagnetic sensor needs to be calibrated with the figure-eight method before each photo is taken, it will undoubtedly greatly increase the time cost for users to take panoramic images with magnetic direction angles. Summary of the Invention
[0004] The purpose of this section is to summarize some aspects of the embodiments of the present invention and briefly introduce some preferred embodiments. Some simplifications or omissions may be made in this section and the abstract and title of this application to avoid obscuring the purpose of this section, the abstract and the title of the invention, and such simplifications or omissions should not be used to limit the scope of the present invention.
[0005] In view of the above problems existing in the prior art when photographing panoramic images, the present invention is proposed.
[0006] To solve the above technical problems, the present invention provides the following technical solution: a geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera, comprising the following steps:
[0007] S1. Pre-calibration before leaving the factory to solve the variable magnetic field interference of magnetic encoding servo;
[0008] S2: Automatically eliminate the variable magnetic field interference of the magnetic encoding servo during the photo shooting process, and obtain geomagnetic data and servo angle data;
[0009] S3. During the photographing process, the variable magnetic field interference caused by the load current of the mainboard of the monocular rotating panoramic camera is eliminated, and the magnetic direction angle α is calculated.
[0010] As a preferred solution of the geomagnetic sensor calibration method for the spatial orientation of a monocular panoramic camera of the present invention, step S1 specifically includes:
[0011] S101, a powered-on monocular rotating panoramic camera is fixed on a vertically placed bracket;
[0012] S102: The servo rotates to 0° as the initial position, and obtains the current geomagnetic data and the corresponding servo angle data. The current geomagnetic data and the corresponding servo angle data are recorded every time the servo rotates 10°, up to 350°, for a total of 36 sets of geomagnetic data.
[0013] S103, fitting an ellipse according to the acquired 36 sets of geomagnetic data to obtain an ellipse equation Ell1;
[0014] S104, subtracting the center EC1 data from the 36 sets of geomagnetic data to obtain interference values of the servos on the geomagnetic data at different positions;
[0015] S105: Generate a servo interference comparison table and store it in the camera.
[0016] As a preferred solution of the geomagnetic sensor calibration method for the spatial orientation of a monocular panoramic camera of the present invention, wherein: the ellipse equation Ell1 is, x²+A*x*z+B*z²+C*x+D*z+E=0; the center of the circle EC1 (X1, Z1) is calculated, where X1=-((A*D-2*B*C) / (A*A-4*B)), Z1=-((A*C-2*D) / (A*A-4*B)); A, B, C, D and E are constants; the coordinate system in the ellipse equation is established as follows: the center of the geomagnetic sensor is the origin, the vertical line passing through the origin is the Y axis, and the XZ plane is constructed with the horizontal plane of the origin, the X axis is perpendicular to the thickness direction of the main board, and the Z axis is parallel to the thickness direction of the main board.
[0017] As a preferred solution of the geomagnetic sensor calibration method for the spatial orientation of a monocular panoramic camera of the present invention, step S2 specifically includes:
[0018] S201, in the first stage of the active photography mode, the camera rotates counterclockwise around the vertical direction. During the rotation, the geomagnetic sensor periodically obtains component data of the Earth's magnetic field on the X-axis and Z-axis, discards the first ten groups of data and the last ten groups of data, and obtains geomagnetic data;
[0019] S202: Based on the servo interference comparison table, correct the geomagnetic data and obtain the servo angle data.
[0020] As a preferred solution of the geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera of the present invention, wherein: correcting the geomagnetic data includes the following steps: performing a linear lookup of the servo angle in the geomagnetic data in a servo interference comparison table to obtain the actual interference value corresponding to each servo angle, subtracting the actual interference value from the obtained geomagnetic data, and obtaining geomagnetic data with the servo interference eliminated.
[0021] As a preferred solution of the geomagnetic sensor calibration method for the spatial orientation of a monocular panoramic camera of the present invention, step S3 specifically includes:
[0022] S301, fitting the geomagnetic data with the servo interference eliminated to an ellipse equation to obtain the ellipse equation Ell2, and calculating the circle center EC2 (X, Z);
[0023] S302, in the second stage of the camera mode, the camera rotates clockwise to take pictures. When taking pictures at m different positions, n groups of data are continuously obtained. After filtering outliers, the average value of each group of data is obtained to obtain data i _x, data i _z, where i = 1, 2, ..., m; where data i _x represents data i The first element, data i _z represents data i The second element, data i It represents the coordinate point formed by taking the mean of the X-axis and Z-axis data after removing outliers at the i-th position;
[0024] S303, refer to the interference comparison table, data i _x, data i _z minus the interference value of the corresponding angle in the interference comparison table stored in the camera, and obtain Data i _x, Data i _z;
[0025] S304, Data i Substitute _x into the elliptic equation Ell2 to calculate z i , obtain the motherboard load current interference value z_offset corresponding to the i-th position i , z_offset i =z i -Data i _z, and find z_offset i mean ;
[0026] S305, pass Compensation center value Z', , correct the system error caused by the variable magnetic field interference generated by the motherboard load current;
[0027] S306, through Data i (Data i _x, Data i _z), EC2' (X, Z') calculates the magnetic direction angle α, α = arctan ((Data i _z-Z') / (Data i _x-X));
[0028] Wherein, EC2' is the center of the compensated ellipse, X refers to the value of the center of the compensated ellipse on the X-axis, and Z' is the value of the center of the compensated ellipse on the Z-axis.
[0029] Beneficial effects of the present invention: This application adds a geomagnetic orientation function to a monocular rotating panoramic camera to realize the function of shooting panoramic images with magnetic direction angles. The geomagnetic sensor is automatically calibrated when taking pictures without the user's perception, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort. Among them:
[0031] Figure 1 It is a schematic diagram of the process of the present invention.
[0032] Figure 2 During the light measurement phase of step S201 , the camera rotates counterclockwise around the vertical direction. During the rotation, the geomagnetic sensor periodically obtains component data graphs of the earth's magnetic field on the X-axis and the Z-axis.
[0033] Figure 3 This is the geomagnetic data diagram after discarding the ten data before and after in Example 2.
[0034] Figure 4 In S302, when the camera is in the second stage of the photo mode and rotates clockwise to take photos at four positions of 270°, 180°, 90°, and 0°, n groups (n=10 in this embodiment) of data graphs are continuously acquired (the red lines frame the clustered points, which are the data points when the camera is rotated to the corresponding angle and paused to take photos, distinguishing them from the circle of points obtained during light metering).
[0035] Figure 5 This is the EC1 ellipse diagram fitted in step S103.
[0036] Figure 6 Step S202 is to correct the geomagnetic data and obtain a graph of the servo angle data in combination with the servo interference comparison table.
[0037] Figure 7 This is the main view of the monocular rotating panoramic camera installed on the bracket.
[0038] Figure 8 This is a structural diagram of the connection between the servo, mainboard and geomagnetic sensor.
[0039] Figure 9 This is a schematic diagram of the three-dimensional structure connecting the servo, mainboard and geomagnetic sensor.
[0040] Among them, 100 is the bracket, 200 is the monocular rotating panoramic camera, 201 is the geomagnetic sensor, 202 is the power interface, 203 is the main board, and 204 is the servo. DETAILED DESCRIPTION
[0041] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in this field without creative work should fall within the scope of protection of the present invention.
[0042] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0043] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0044] The present invention is described in detail with reference to schematic diagrams. For ease of illustration, cross-sectional views of device structures may be partially enlarged and not to scale when describing embodiments of the present invention. Furthermore, the schematic diagrams are merely illustrative and should not limit the scope of the present invention. Furthermore, in actual production, the three-dimensional dimensions of length, width, and depth should be included.
[0045] In the description of the present invention, it should be noted that the terms "upper, lower, inner, and outer" and other references to orientations or positional relationships are based on the orientations or positional relationships shown in the accompanying drawings and are intended solely to facilitate and simplify the description of the present invention. They are not intended to indicate or imply that the devices or components referred to must have, be constructed, or operate in a specific orientation, and therefore should not be construed as limitations on the present invention. Furthermore, the terms "first, second, or third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0046] In this disclosure, unless otherwise specified or limited, the terms "mounted," "connected," and "connected" should be interpreted broadly. For example, they may refer to fixed, removable, or integral connections. They may also refer to mechanical, electrical, or direct connections, indirect connections through an intermediary, or internal communication between two components. Those skilled in the art will understand the specific meanings of these terms in this disclosure.
[0047] Example 1
[0048] Reference Figure 1 and Figures 7 to 9 This is the first embodiment of the present invention, which provides a geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera. Using this method, the geomagnetic sensor 201 can be automatically calibrated when taking pictures without the user's perception, thereby improving the user experience.
[0049] A geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera comprises the following steps:
[0050] S1. Pre-calibration before delivery to solve the variable magnetic field interference of the magnetic encoding servo 204, specifically including:
[0051] S101、 Figure 7 , the monocular rotating panoramic camera 200 in the powered-on state is fixed on the vertically placed bracket 100;
[0052] S102: The servo 204 rotates to 0° as the initial position, and obtains the current geomagnetic data and the corresponding angle data of the servo 204. The current geomagnetic data and the corresponding angle data of the servo 204 are recorded every time the servo 204 rotates 10°, until 350°, for a total of 36 sets of geomagnetic data.
[0053] S103. Fit an ellipse based on the 36 sets of geomagnetic data obtained to obtain the ellipse equation Ell1 x²+A*x*z+B*z²+C*x+D*z+E=0; calculate the center EC1(X1, Z1), where X1=-((A*D-2*B*C) / (A*A-4*B)), Z1=-((A*C-2*D) / (A*A-4*B)); A, B, C, D, and E are constants; the coordinate system in the ellipse equation is established as follows: the center of the geomagnetic sensor 201 is the origin, the vertical line passing through the origin is the Y-axis, and the XZ plane is constructed with the horizontal plane of the origin, with the X-axis perpendicular to the thickness direction of the mainboard 203, and the Z-axis parallel to the thickness direction of the mainboard 203;
[0054] S104, subtracting the center EC1 data from the 36 sets of geomagnetic data to obtain interference values of the servo 204 on the geomagnetic data at different positions;
[0055] S105, generating a servo 204 interference comparison table and storing it in the camera 200;
[0056] S2, automatically eliminate the variable magnetic field interference of the magnetic encoding servo 204 during the shooting process, obtain geomagnetic data and servo 204 angle data, specifically including:
[0057] S201: In the first stage of the active photography mode, the camera 200 rotates counterclockwise around the vertical direction. During the rotation, the geomagnetic sensor 201 periodically obtains component data of the Earth's magnetic field on the X-axis and the Z-axis, discards the first ten groups of data and the last ten groups of data, and obtains geomagnetic data.
[0058] S202 , combining the interference comparison table of the servo 204 , correcting the geomagnetic data and obtaining the angle data of the servo 204 .
[0059] Correcting the geomagnetic data includes the following steps: performing a linear lookup of the servo 204 angle in the geomagnetic data in a servo 204 interference comparison table to obtain an actual interference value corresponding to each servo 204 angle; subtracting the actual interference value from the obtained geomagnetic data to obtain geomagnetic data with the servo 204 interference eliminated;
[0060] S3, during the photographing process, eliminating the variable magnetic field interference caused by the load current of the mainboard 203 of the monocular rotating panoramic camera 200, and calculating the magnetic direction angle α, specifically including:
[0061] S301, fitting the geomagnetic data with interference from the servo 204 eliminated to an ellipse equation to obtain the ellipse equation Ell2, and calculating the circle center EC2 (X, Z);
[0062] S302, the camera 200 rotates clockwise to take pictures in the second stage of the photo mode. When taking pictures at m different positions, n groups of data are continuously obtained. After filtering outliers (outliers are outliers with large discreteness, filtering outliers means eliminating outliers, which is a prior art), the average value of each group of data is taken to obtain data i _x, data i _z, where i = 1, 2, ..., m; where data i _x represents data i The first element, data i _z represents data i The second element, data i It represents the coordinate point formed by taking the mean of the X-axis and Z-axis data after removing outliers at the i-th position;
[0063] S303, refer to the interference comparison table, data i _x, data i _z minus the interference value of the corresponding angle in the interference comparison table stored in the camera 200, and obtain Data i _x, Data i _z;
[0064] S304, Data i Substitute _x into the elliptic equation Ell2 to calculate z i , find the load current interference value z_offset of the mainboard 203 corresponding to the i-th position i , z_offset i =z i -Data i _z, and find z_offset i mean , ;
[0065] S305, pass Compensation center value Z', , correcting the system error caused by the variable magnetic field interference generated by the load current of the main board 203;
[0066] S306, through Data i (Data i _x, Data i _z), EC2' (X, Z') calculates the magnetic direction angle α, α = arctan ((Data i _z-Z') / (Data i _x-X));
[0067] Wherein, EC2' is the center of the compensated ellipse, X refers to the value of the center of the compensated ellipse on the X-axis, and Z' is the value of the center of the compensated ellipse on the Z-axis.
[0068] The main board 203 is the main circuit control board of the monocular rotating panoramic camera 200. The main board is also connected to a power interface 202 for convenient connection to a power source. The geomagnetic sensor 201 is connected to the main board 203. Figure 9 For reference, the direction perpendicular to the paper is parallel to the thickness direction of the mainboard 203, that is, the Z-axis direction is parallel to the direction perpendicular to the paper, the vertical direction parallel to the paper is parallel to the Y-axis direction, and the horizontal direction parallel to the paper is parallel to the X-axis direction.
[0069] The monocular rotating panoramic camera 200 rotates and calibrates the geomagnetic sensor 201, pre-calibrates to solve the variable magnetic field interference of the magnetic encoding servo 204, collects data when taking pictures at a fixed angle, corrects the system error caused by the interference generated by the load current of the main board 203, compensates the coordinates of the center of the ellipse, avoids the variable magnetic field of the magnetic encoding servo 204 and the variable magnetic field generated by the load current of the main board 203 from affecting the geomagnetic sensor 201, and takes a panoramic image with a magnetic direction angle.
[0070] Example 2
[0071] refer to Figures 2 to 6 This embodiment provides a geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera. The difference from Example 1 is that this embodiment further illustrates the present application with specific examples, making it easier to understand the technical solution of the present application.
[0072] In this embodiment, the servo 204 in the monocular rotating panoramic camera 200 is a universal magnetic encoding servo 204, and the model of the geomagnetic sensor 201 is qmc6309;
[0073] When the monocular rotating panoramic camera 200 of this embodiment is used for calibration, the ellipse fitted in step S103 is as follows: Figure 5 As shown, in step S104, the center EC1 data is subtracted from the 36 sets of geomagnetic data to obtain the interference value of the servo 204 on the geomagnetic data at different positions, as shown in Table 1.
[0074] Table 1
[0075]
[0076] Generate a servo 204 interference comparison table, as shown in Table 2.
[0077] Table 2
[0078]
[0079] In step S201, the first stage is the camera 200 metering stage. The camera 200 rotates counterclockwise around the vertical direction. During the rotation, the geomagnetic sensor 201 regularly obtains the component data of the earth's magnetic field on the X axis and the Z axis, and records the corresponding angle of the servo 204. In this embodiment, the camera 200 rotates 270° counterclockwise around the vertical direction in 5 seconds. During the rotation, the geomagnetic sensor 201 obtains a set of component data of the earth's magnetic field on the X axis and the Z axis every 30 milliseconds, and records the corresponding angle of the servo 204. Figure 2 As shown; since the mainboard 203 will have large fluctuations in current at the beginning and end of rotation, the ten sets of data before and after are greatly affected by the magnetic field of the current, and the ten sets of data before and after are discarded, as shown Figure 3 shown.
[0080] Combined with the interference comparison table of the servo 204, the geomagnetic data is corrected and the angle data of the servo 204 is obtained, such as Figure 6 shown.
[0081] In step S302, the camera 200 rotates clockwise in the second stage of the photo mode to take photos. When taking photos at the four positions of 270°, 180°, 90°, and 0°, n groups of data (n=10 in this embodiment) are continuously acquired. After filtering outliers, the average value is taken to obtain datai_x and datai_z, where i=1, 2, 3, and 4. In step S304, Data i Substitute _x into the elliptic equation Ell2 to calculate z i , find the load current interference value z_offset of the mainboard 203 corresponding to the i-th position i , z_offset i =z i -Data i _z, and find z_offset i mean , .
[0082] like Figure 4 As shown, a circle of data acquired by the camera 200 during the metering phase includes the interference value of the servo 204 and the interference value of the load current of the mainboard 203. In this figure, this circle of data points includes the interference value of the servo 204 and the interference value of the load current of the mainboard 203. After eliminating the interference value of the servo 204, an ellipse is fitted to determine the center EC2. This circle of data points and the center EC2 are still affected by the interference value of the load current of the mainboard 203. When the camera 200 pauses to take pictures at four positions, it is only affected by the interference value of the servo 204 and is not affected by the load current of the mainboard 203, because the load current of the mainboard 203 is stable at this time, that is, data i , eliminate the interference value of servo 204 i , at this time Data i Without any interference, the Datai Substitute -x into the Ell2 ellipse formula to calculate z i , z i Indicates that the horizontal axis is Data i -x, the value of the load current interference value of the main board 203 on the Z axis, so it can be obtained through z_offset i =z i -Data i _zCalculate the load current interference value of the mainboard 203, and then the center of the circle can be compensated to determine EC2'.
[0083] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, and all of these should be included in the scope of the technical solutions of the present invention.
Claims
1. A geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera, characterized by: The following steps are included: S1. Pre-calibration before leaving the factory to solve the variable magnetic field interference of magnetic encoding servo; S2: Automatically eliminate the variable magnetic field interference of the magnetic encoding servo during the photo shooting process, and obtain geomagnetic data and servo angle data; S3. During the photographing process, the variable magnetic field interference caused by the load current of the mainboard of the monocular rotating panoramic camera is eliminated, and the magnetic direction angle α is calculated.
2. The geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera according to claim 1, wherein: Step S1 specifically includes: S101, a powered-on monocular rotating panoramic camera is fixed on a vertically placed bracket; S102: The servo rotates to 0° as the initial position, and obtains the current geomagnetic data and the corresponding servo angle data. The current geomagnetic data and the corresponding servo angle data are recorded every time the servo rotates 10°, up to 350°, for a total of 36 sets of geomagnetic data. S103, fitting an ellipse according to the acquired 36 sets of geomagnetic data to obtain an ellipse equation Ell1; S104, subtracting the center EC1 data from the 36 sets of geomagnetic data to obtain interference values of the servos on the geomagnetic data at different positions; S105: Generate a servo interference comparison table and store it in the camera.
3. The geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera according to claim 2, wherein: The ellipse equation Ell1 is x² + A*x*z + B*z² + C*x + D*z + E = 0. Calculate the center EC1 (X1, Z1), where X1 = -((A*D-2*B*C) / (A*A-4*B)), and Z1 = -((A*C-2*D) / (A*A-4*B)). A, B, C, D, and E are constants. The coordinate system in the ellipse equation is established as follows: the center of the geomagnetic sensor is the origin, the vertical line through the origin is the Y-axis, and the XZ plane is constructed with the horizontal plane at the origin. The X-axis is perpendicular to the thickness of the motherboard, and the Z-axis is parallel to the thickness of the motherboard.
4. The geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera according to claim 1, wherein: Step S2 specifically includes: S201, in the first stage of the active photography mode, the camera rotates counterclockwise around the vertical direction. During the rotation, the geomagnetic sensor periodically obtains component data of the Earth's magnetic field on the X-axis and Z-axis, discards the first ten groups of data and the last ten groups of data, and obtains geomagnetic data; S202: Based on the servo interference comparison table, correct the geomagnetic data and obtain the servo angle data.
5. The geomagnetic sensor calibration method for monocular panoramic camera spatial orientation according to claim 4, characterized in that: Correcting the geomagnetic data includes the following steps: performing a linear lookup of the servo angle in the geomagnetic data in the servo interference comparison table to obtain the actual interference value corresponding to each servo angle; subtracting the actual interference value from the obtained geomagnetic data to obtain geomagnetic data with the servo interference eliminated.
6. The geomagnetic sensor calibration method for spatial orientation of a monocular panoramic camera according to claim 5, wherein: Step S3 specifically includes: S301, fitting the geomagnetic data with the servo interference eliminated to an ellipse equation to obtain the ellipse equation Ell2, and calculating the circle center EC2 (X, Z); S302, in the second stage of the camera mode, the camera rotates clockwise to take pictures. When taking pictures at m different positions, n groups of data are continuously obtained. After filtering outliers, the average value of each group of data is obtained to obtain data i _x, data i _z, where i = 1, 2, ..., m; where data i _x represents data i The first element, data i _z represents data i The second element, data i It represents the coordinate point formed by taking the mean of the X-axis and Z-axis data after removing outliers at the i-th position; S303, refer to the interference comparison table, data i _x, data i _z minus the interference value of the corresponding angle in the interference comparison table stored in the camera, and obtain Data i _x, Data i _z; S304, Data i Substitute _x into the elliptic equation Ell2 to calculate z i , obtain the motherboard load current interference value z_offset corresponding to the i-th position i , z_offset i =z i -Data i _z, and find z_offset i mean ; S305, pass Compensation center value Z', , correct the system error caused by the variable magnetic field interference generated by the motherboard load current; S306, through Data i (Data i _x, Data i _z), EC2' (X, Z') calculates the magnetic direction angle α, α = arctan ((Data i _z-Z') / (Data i _x-X)); Wherein, EC2' is the center of the compensated ellipse, X refers to the value of the center of the compensated ellipse on the X-axis, and Z' is the value of the center of the compensated ellipse on the Z-axis.