Disclosure of Invention
In order to solve the problems, the invention discloses a mobile phone AR positioning coordinate axis synchronization method based on three-datum-point calibration.
In order to achieve the purpose, the invention provides the following technical scheme:
a mobile phone AR positioning coordinate axis synchronization method based on three-datum point calibration comprises the following steps:
(1) establishing a local coordinate system of each online participating device by using the position of the online participating device and the angle of a gyroscope on each online participating device;
(2) selecting any one device participating in online as a main reference device, taking the rest devices as slave devices, taking a local coordinate system of the main reference device as a reference coordinate system, and displaying three reference points in the main reference device;
each slave device adjusts the position of each local coordinate system according to the three displayed reference points, and obtains the deviation between the local coordinate system and the reference coordinate system;
(3) and converting the coordinates of the virtual object in the reference coordinate system into the coordinates in the local coordinate system of each slave device, and displaying the coordinates on each slave device.
Further, the following steps: the three reference points displayed in the main reference device in step (2) can form an isosceles right triangle.
Further, the Z axis of the local coordinate system of each participating online device in step (1) is vertically upward.
Further, the specific method of step (2) is:
(2-a) selecting any one device participating in online as a main reference device, taking the other devices as slave devices, taking a local coordinate system of the main reference device as a reference coordinate system, and displaying three circular reference points on the main reference device;
(2-b) displaying the same three circular reference points on the slave device as well;
(2-c) the slave device scanning a display screen of the master reference device by using the camera, and adjusting the position of the slave device until the three circular reference points displayed on the slave device can be completely coincided with the three circular reference points displayed on the master reference device;
(2-d) obtaining the position (x) of the slave device in the reference coordinate system according to the position of the reference coordinate system and the orientation of the master reference device1,y1,z1);
(2-e) acquiring euler rotation angles and coordinate positions of the orientations of the master reference device and the slave device in local coordinate systems thereof, respectively;
(2-f) setting an initial vector (1,0,0), and obtaining a new vector (x, y, z) through Euler rotation;
(2-g) obtaining a rotation angle of the slave device on the XY plane through the new vector;
(2-h) calculating a rotation angle difference theta between the slave device and the master reference device;
(2-i) the slave device reversely rotating its local coordinate system according to the rotation angle difference θ, so that the local coordinate system of the slave device and the reference coordinate system are consistent in directions of X, Y, Z three coordinate axes;
(2-j) new coordinates (x) rotated by the local coordinate system of the slave device2,y2,z2) With its coordinates (x) in the reference coordinate system1,y1,z1) Obtaining the coordinate origin displacement between the slave equipment and the master reference equipment by the difference value, and recording the displacement as delta x, delta y and delta z;
and (2-k) repeating the steps (2-b) to (2-j) to respectively obtain the coordinate origin displacement between each slave device and the master reference device.
Further, the specific method of step (3) is:
(3-a) transmitting the relevant object coordinates in the AR environment to each slave device with the master reference device as a data distribution center;
(3-b) each slave device respectively displacing the received object coordinates in X, Y, Z three-axis directions according to the displacement of the origin of coordinates;
and (3-c) rotating the object coordinate after the displacement in the step (3-b) by an angle theta by taking the Z axis as a rotating axis to obtain the slave device coordinate in the master reference coordinate system on each slave device.
Compared with the prior art, the invention can form a uniform coordinate system among all mobile phones, thereby facilitating convenient and uniform online interaction; the method is simple and easy to implement, and is beneficial to promoting the realization of AR virtual interaction on a low-cost mobile phone.
Detailed Description
The technical solutions provided by the present invention will be described in detail below with reference to specific examples, and it should be understood that the following specific embodiments are only illustrative of the present invention and are not intended to limit the scope of the present invention.
Example 1:
the invention provides a mobile phone AR positioning coordinate axis synchronization method based on three-datum point calibration, which comprises the following steps:
(1) and respectively establishing a local coordinate system of each online participating device by using the position of each online participating device and the angle of the gyroscope, wherein the Z axis of the local coordinate system of each online participating device is vertically upward.
(2-a) selecting any one device participating in online as a main reference device, taking the other devices as slave devices, taking a local coordinate system of the main reference device as a reference coordinate system, and displaying three circular reference points on the main reference device, wherein the three displayed circular reference points can form an isosceles right triangle;
(2-b) displaying the same three circular reference points on the slave device as well;
(2-c) the slave device scanning a display screen of the master reference device by using the camera, and adjusting the position of the slave device until the three circular reference points displayed on the slave device can be completely coincided with the three circular reference points displayed on the master reference device;
(2-d) obtaining the position (x) of the slave device in the reference coordinate system according to the position of the reference coordinate system and the orientation of the master reference device1,y1,z1);
(2-e) acquiring euler rotation angles and coordinate positions of the orientations of the master reference device and the slave device in local coordinate systems thereof, respectively;
(2-f) setting an initial vector (1,0,0), and obtaining a new vector (x, y, z) through Euler rotation;
(2-g) obtaining a rotation angle of the slave device on the XY plane through the new vector;
(2-h) calculating a rotation angle difference theta between the slave device and the master reference device;
(2-i) the slave device reversely rotating its local coordinate system according to the rotation angle difference θ, so that the local coordinate system of the slave device and the reference coordinate system are consistent in directions of X, Y, Z three coordinate axes;
(2-j) new coordinates (x) rotated by the local coordinate system of the slave device2,y2,z2) With its coordinates (x) in the reference coordinate system1,y1,z1) Obtaining the coordinate origin displacement between the slave equipment and the master reference equipment by the difference value, and recording the displacement as delta x, delta y and delta z;
and (2-k) repeating the steps (2-b) to (2-j) to respectively obtain the coordinate origin displacement between each slave device and the master reference device.
(3-a) transmitting the relevant object coordinates in the AR environment to each slave device with the master reference device as a data distribution center;
(3-b) each slave device respectively displacing the received object coordinates in X, Y, Z three-axis directions according to the displacement of the origin of coordinates;
and (3-c) rotating the object coordinate after the displacement in the step (3-b) by an angle theta by taking the Z axis as a rotating axis to obtain the slave device coordinate in the master reference coordinate system on each slave device.
Example 2:
first, a master reference device and a slave device are initialized at arbitrary positions, and reference object coordinate positions are set to r11(0,1,0) and r21(0,1,0), respectively.
Secondly, the slave device scans the display screen of the master reference device by using a camera, the position of the slave device is adjusted until three circular reference points displayed on the slave device can be completely coincided with three circular reference points displayed on the master reference device, two new coordinates r12(-0.16035,0.98610, -0.04343) and r22(0.80003,0.15726, -0.57898) are respectively obtained, x and z components of the respective coordinates are respectively substituted into the following formula, and finally a difference value delta theta of two rotation angles is obtained, wherein the angle is the rotation angle of the master device relative to the slave device:
when z is greater than 0, theta is actg (x/z)
When z <0, θ ═ actg (x/z) + π
When z is 0, x is >0, θ is 0; x <0, θ ═ pi, x ═ 0, no solution.
The calculated delta theta was-0.58244 radians.
Substituting the measured parameters into the following formula to obtain the displacement of the coordinate origin of the master reference device relative to the slave device as follows:
ΔT(-0.12688,-0.0780,-0.02480),
θ21=θ2+Δθ,
r=sqrt(pow(r22.x,2)+pow(r22.z,2)),
Δx=r*cos(θ21)–r12.x,
Δz=r*sin(θ21)–r12.z,
Δy=r22.y。
fourthly, an object is placed at the position P1(0,0,0) of the reference coordinate system, and the new coordinate position obtained by the translation and rotation formulas of the following formulas is P2(-0.11961, -0.07805, 0.04907);
x=P1.x+Δx,
y=P1.y+Δy,
z=P2.z+Δz,
r=sqrt(pow(x,2)+pow(z,2)),
the angle theta 3 is obtained through the step three,
θ4=θ3–Δθ,
P2.x=cos(θ4)*r,
P2.y=y2,
P2.z=sin(θ4)*r。
finally, it should be noted that the above embodiments are only used for illustrating the technical solutions of the present invention and not for limiting the technical solutions, and those skilled in the art should understand that modifications or equivalent substitutions can be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions, and all the modifications and equivalent substitutions should be covered by the claims of the present invention.