5G antenna pose estimation method, equipment and medium based on machine vision
Technical Field
The invention relates to the field of positioning detection, in particular to a 5G antenna pose estimation method, equipment and medium based on machine vision.
Background
With the rapid development of 5G communication technology, testing of 5G antenna performance becomes particularly critical. In the 5G antenna near field detection system based on the mechanical arm, the size and the height of a sampling surface are required to be set according to the working frequency and the size of the 5G antenna, the position of the sampling surface is determined according to the pose of the 5G antenna, and the position of the sampling surface determines the sampling track of the magnetic field probe at the tail end of the mechanical arm. Only when the position and direction of the antenna are matched with the position and direction of the magnetic field probe, the electromagnetic performance of the antenna can be accurately measured.
Machine vision is capable of performing tasks such as object recognition, positioning, and measurement without contact, and plays a vital role in the development of industrial automation and robotics today. The method based on monocular vision is simple and feasible, but cannot provide real scale information of a target object; although the binocular vision-based method can recover the three-dimensional information of the object, the method has higher requirements on ambient illumination and texture, and the stereo matching algorithm is complex; although the method based on the multi-view vision can provide more comprehensive visual angle information, the method has the advantages of large operation amount, high cost and increased system complexity, and is not beneficial to wide application in actual production environments. Therefore, the above methods have certain limitations in practical applications.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a 5G antenna pose estimation method, equipment and medium based on machine vision, so as to improve the accuracy and efficiency of antenna pose estimation and reduce the complexity of a system.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
The invention discloses a 5G antenna pose estimation method based on machine vision, which is characterized by comprising the following steps of:
s1: when the monocular camera reaches the ith acquisition point In the process, the monocular camera is utilized to position the ith mechanical armAcquisition of ith antenna imagePair of YOLOv modelsThe antenna in (a) is detected to obtain an antenna image of the ith ROI areaAnd willAt the position ofThe upper left corner of the middle is marked as;
S2: antenna image for ith-1 th and ith ROI areaAndFeature extraction and feature matching are carried out to obtain non-collinear 5G antenna feature pointsAt the position ofAndThe pixel point pairs corresponding to the above、; Wherein, Representing the characteristic point of the jth 5G antenna; Representation of At the position ofThe coordinates of the two points are set up in the same plane,Representation ofAt the position ofCoordinates on; m represents the total number of feature points, and m is more than or equal to 3; And Representing a j-th pixel point pair;
S3: calculating m pixel point pairs respectively at the following positions by using the formula (1) Pixel coordinates in (a)、Wherein, the method comprises the steps of, wherein,Representation ofAt the position ofThe coordinates of the two points are set up in the same plane,Representation ofAt the position ofCoordinates of:
(1)
In the formula (1), the components are as follows, Representation ofIn the i-1 th antenna imageUpper left corner coordinates of (a);
s4: based on the triangulation principle, the jth 5G antenna characteristic point is calculated by using the formula (2) Coordinates in the robot arm base coordinate system:
(2)
In the formula (2), the amino acid sequence of the compound,An internal reference matrix of the monocular camera is obtained through camera calibration;、 The camera coordinate system is a rotation matrix and a translation vector relative to the mechanical arm base coordinate system when the monocular camera shoots for the ith time respectively, and the rotation matrix and the translation vector are obtained through coordinate transformation; 、 The camera coordinate system is relative to the rotation matrix and the translation vector of the mechanical arm base coordinate system when the monocular camera shoots for the ith-1 time respectively, and the rotation matrix and the translation vector are obtained through coordinate transformation; indicating that the monocular camera is at the first Acquisition point in secondary photographingTo the point ofDepth values of (2); indicating that the monocular camera is at the first Acquisition point in secondary photographingTo the point ofDepth values of (2);
S5: performing iterative optimization on the objective function shown in the formula (3) by using an LM algorithm, taking the calculation result of S4 as the initial value of the LM algorithm, and solving the characteristic point of the jth 5G antenna Optimal coordinates in the robot arm base coordinate system;
(3)
In the formula (3), the amino acid sequence of the compound,Representation ofAndRepositioning error between;
s6: fitting an optimal coordinate set using SVD decomposition Obtaining the normal vector of the antenna plane; Wherein T represents a transpose;
s7: with direction of normal vector of antenna plane as antenna coordinate system The axial direction vector is expressed as; Selecting a certain vector direction on an antenna plane as an antenna coordinate systemThe axial direction vector is expressed as; By calculation ofAxial direction vectorCross-product of axial direction vectorsThe axial direction vector is expressed as;
S8: obtaining a transformation matrix of the antenna coordinate system relative to the mechanical arm base coordinate system by using the method (4)NamelyAndPose of the middle antenna:
(4)
In the formula (4), the amino acid sequence of the compound, Is a rotation matrix of the antenna coordinate system relative to the robot base coordinate system,Is a translation vector of the antenna coordinate system relative to the robot base coordinate system.
The 5G antenna pose estimation method based on machine vision is also characterized in that the repositioning error in S5The method comprises the following steps:
a: calculation using (5) AndActual distance between:
(5)
B: according to the cosine law, calculate using equation (6)AndDistance of repositioning between:
(6)
C: according to the actual distanceDistance of repositioningObtaining a repositioning error of formula (7):
(7)。
S8 is to calculate a rotation matrix using equation (8):
(8)
S8, selecting a fixed point on the 5G antenna as an origin of an antenna coordinate system, and marking a sitting of the origin under a mechanical arm base coordinate system as a translation vector。
The invention provides an electronic device, which is characterized by comprising: a memory for storing a computer program; and the processor is used for realizing the 5G antenna pose estimation method based on machine vision when executing the computer program.
The computer readable storage medium is characterized in that the computer readable storage medium is stored with a computer program, and the computer program realizes the 5G antenna pose estimation method based on machine vision when being executed by a processor.
Compared with the prior art, the invention has the following advantages:
1. the invention adopts a mode of combining the mechanical arm and the triangulation method, and utilizes the mechanical arm to take images under different visual angles with the monocular camera, thereby effectively replacing the traditional binocular or multi-view camera system, simplifying the structure of the system, reducing the operation amount and simultaneously reducing the hardware cost.
2. The method is simple and convenient to implement, and can calculate the pose of the 5G antenna to be detected while the mechanical arm carries the probe to execute the task of detecting the radiation performance of the 5G antenna, optimize the calculated pose result based on the pose information of the mechanical arm, and improve the accuracy of pose estimation.
3. According to the method, the camera image and the pose information of the tail end of the mechanical arm are analyzed, so that the pose of the 5G antenna to be detected is estimated, priori pose information is not needed to be relied on, and the dependence of the system on priori knowledge is reduced.
Drawings
FIG. 1 is a schematic diagram of the overall structure of a system according to the present invention;
FIG. 2 is a flow chart of a pose estimation method of the present invention;
FIG. 3 is a schematic diagram of a triangulation method according to an embodiment of the present invention;
Reference numerals in the drawings: 1a monocular camera; 2, a mechanical arm; 3, a mechanical arm base; 4, a man-machine interaction unit; 5a control unit; 6, 5G antenna to be measured; and 7, carrying the object stage.
Detailed Description
In this embodiment, as shown in fig. 1, a 5G antenna pose estimation device based on machine vision includes: the device comprises a monocular camera 1, a mechanical arm 2, a mechanical arm base 3, a man-machine interaction unit 4, a control unit 5, a 5G antenna 6 to be tested and a stage 7. Wherein, the monocular camera 1 is arranged at the tail end of the mechanical arm 2 in a mode that eyes are on hands, and the optical axis direction of the monocular camera 1 is the same as the Z-axis direction of the tail end of the mechanical arm 2; the mechanical arm 2 carries the monocular camera 1 to move to an image acquisition position so as to execute an image acquisition task; the man-machine interaction unit 4 is used for monitoring the running state of the system; the control unit 5 is used for sending instructions and processing data; the 5G antenna 6 to be tested is placed on the stage 7. In this embodiment, the mechanical arm is a 6-degree-of-freedom mechanical arm, and the 5G antenna to be tested is a rectangular PCB board antenna.
In this embodiment, as shown in fig. 2, a 5G antenna pose estimation method based on machine vision includes the following steps:
s1: when the monocular camera reaches the ith acquisition point In the process, the monocular camera is utilized to position the ith mechanical armAcquisition of ith antenna imagePair of YOLOv modelsThe antenna in (a) is detected to obtain an antenna image of the ith ROI areaAnd willAt the position ofThe upper left corner of the middle is marked as;
In the present embodiment, before S1 is performed, the following preparation work needs to be completed, including:
(A) Training an antenna detection model, wherein the process is as follows: by means of the device, the mechanical arm is controlled to carry the monocular camera to collect 60 5G antenna images at different visual angles, and the labelme tool is used for marking the antenna area of each image in the data set. And randomly selecting 48 antenna images in the data set as a training set, and taking the rest 12 antenna images as a test set. The images of the training set and their corresponding labels are input YOLOv to a target detection algorithm for training. After training, the model is applied to a test set, parameter adjustment and optimization are carried out according to the test result, and a 5G antenna detection model is obtained.
(B) Calibrating the monocular camera by using a checkerboard calibration method to obtain a monocular camera internal reference matrix shown as a formula (1)The expression is:
(1)
In the formula (1), the components are as follows, AndThe normalized focal lengths on the u-axis and v-axis of the camera image coordinate system are respectively,As the focal length of the camera,AndRespectively representing the size of unit pixels on a camera image coordinate system, wherein the unit is,AndRepresenting the optical center of the camera, i.e. the intersection of the camera optical axis and the image plane.
(C) Performing hand-eye calibration on the mechanical arm-camera system by using a Tsai method to obtain a hand-eye matrix shown as (2):
(2)
Wherein, 、Respectively represent shooting timesAnd (3) when an image is formed, a rotation matrix and a translation vector of the camera coordinate system relative to the tail end coordinate system of the mechanical arm are formed.
S2: antenna image for ith-1 th and ith ROI areaAndAnd carrying out feature extraction and feature matching. Specifically, toAndGraying, gaussian filtering and binarization are carried out, corner points and surface welding spots of an antenna are selected to serve as antenna characteristic points, a Shi-Tomas method is adopted to carry out corner point detection on an ROI image, SIFT descriptors of all the corner points are calculated, and a Brute-Force method is adopted to match the characteristic points to obtain non-collinear 5G antenna characteristic pointsAt the position ofAndThe pixel point pairs corresponding to the above、; Wherein, Representing the characteristic point of the jth 5G antenna; Representation of At the position ofThe coordinates of the two points are set up in the same plane,Representation ofAt the position ofCoordinates on; m represents the total number of feature points, and m is more than or equal to 3; And Representing a j-th pixel point pair;
s3: calculating m pixel point pairs respectively at the following positions by using the method (3) Pixel coordinates in (a)、Wherein, the method comprises the steps of, wherein,Representation ofAt the position ofThe coordinates of the two points are set up in the same plane,Representation ofAt the position ofCoordinates of:
(3)
In the formula (3), the amino acid sequence of the compound, Representation ofIn the i-1 th antenna imageUpper left corner coordinates of (a);
S4: as shown in fig. 3, based on the principle of triangulation, the jth 5G antenna characteristic point is calculated using equation (4) Coordinates in the robot arm base coordinate system:
(4)
In the formula (4), the amino acid sequence of the compound,、The camera coordinate system is a rotation matrix and a translation vector relative to the mechanical arm base coordinate system when the monocular camera shoots for the ith time respectively, and the rotation matrix and the translation vector are obtained through coordinate transformation;、 The camera coordinate system is relative to the rotation matrix and the translation vector of the mechanical arm base coordinate system when the monocular camera shoots for the ith-1 time respectively, and the rotation matrix and the translation vector are obtained through coordinate transformation; indicating that the monocular camera is at the first Acquisition point in secondary photographingTo the point ofDepth values of (2); indicating that the monocular camera is at the first Acquisition point in secondary photographingTo the point ofDepth values of (2);
In the present embodiment, the rotation matrix of the camera coordinate system relative to the robot base coordinate system is calculated by using (5) Translation vector:
(5)
In the formula (5), the amino acid sequence of the compound,Representing a transformation matrix of the camera coordinate system relative to the robot base coordinate system at the ith photograph.
S5: performing iterative optimization on the objective function shown in the formula (6) by using the LM algorithm, taking the calculation result of S4 as the initial value of the LM algorithm, and solving the jth 5G antenna characteristic pointOptimal coordinates in the robot arm base coordinate system;
(6)
In the formula (6), the amino acid sequence of the compound,Representation ofAndThe repositioning error between the two is calculated by the formula (7):
(7)
In this embodiment, the maximum iteration number of the LM optimization algorithm is set to 500, and the step size is set to . When the algorithm is executed until the maximum iteration number or step length is smaller than the given precision, the optimization process is considered to reach an optimal state, iteration is stopped, and the optimal result is used as the optimal coordinate of the jth 5G antenna characteristic point under the mechanical arm base coordinate system.
S6: fitting an optimal coordinate set using SVD decompositionObtaining the normal vector of the antenna plane; Wherein T represents a transpose;
s7: in this embodiment, the 5G antenna to be tested is a rectangular PCB board antenna, and when an antenna coordinate system is constructed, the direction of the normal vector of the antenna plane is used as the antenna coordinate system The axial direction vector is expressed as; Selecting optimal coordinates of upper left corner point on antenna planeOptimal coordinates pointing to the lower left corner pointIs the direction of the antenna coordinate systemThe axial direction vector is expressed as; By calculation ofAxial direction vectorCross-product of axial direction vectorsThe axial direction vector is expressed as;
S8: calculating a rotation matrix of the antenna coordinate system relative to the robot base coordinate system using (8):
(8)
Selecting the optimal coordinates of the upper left corner point on the 5G antenna to be testedThe origin of the antenna coordinate system is marked as the translation vector of the antenna coordinate system relative to the mechanical arm base coordinate system by the coordinates of the origin under the mechanical arm base coordinate system. Obtaining a transformation matrix of the antenna coordinate system relative to the mechanical arm base coordinate system by using the method (9)NamelyAndPose of the middle antenna:
(9)
In this embodiment, an electronic device includes: a memory for storing a computer program for executing the above method; and a processor for executing the program stored in the memory.
In this embodiment, a computer readable storage medium stores a computer program that when executed by a processor implements the above method.