Disclosure of Invention
The purpose of the invention is realized by the following technical scheme.
The invention realizes real-time positioning of multiple instruments by using different geometric shapes formed by optical markers on each instrument and a motion vector tracking method, provides that the side length ratio is used for identifying the instruments in different shapes, and if the shapes of the instruments are similar, the actual circumferences of the instruments are used for distinguishing; tracking a plurality of moving instruments by using a motion vector tracking method; the change of the number of the instruments is monitored by using the increase and decrease of the markers of the front and the back frames.
Specifically, according to one aspect of the present invention, there is provided a multi-instrument optical positioning method, comprising:
a multi-instrument judging step, namely judging whether an instrument enters or exits through increase and decrease of the markers between the front frame and the rear frame;
a multi-instrument identification step, wherein each instrument is identified based on the geometric shape of a marker on the instrument, and when a new instrument enters, the new instrument is identified;
a multi-instrument tracking step of tracking the motion of a plurality of said instruments using a motion vector tracking algorithm.
Preferably, the label is actively and/or passively luminescent.
Preferably, the geometric shape comprises a side length ratio and/or a perimeter between the markers.
Preferably, the multi-instrument recognition step specifically includes: firstly, identifying instruments in different shapes by using the side length ratio between the markers, and if the instruments are similar in shape, distinguishing the different instruments by using the circumferences between the markers.
Preferably, the multi-instrument recognition step specifically includes:
acquiring left and right views of one or more instruments newly entering the system, identifying each instrument by utilizing different side length ratios and/or circumferences of marker pairs to obtain central pixel coordinates of each instrument marker in the left and right views, and calculating the spatial position and direction of an instrument tip point according to the identified pixel coordinates of each instrument;
preferably, the central pixel coordinate of the marker is determined based on a region growing method and a gray scale centroid method.
Preferably, the multi-instrument tracking step specifically includes:
in the t-th frame (t >1), the central pixel coordinates of each marker are calculated, and the marker pixel coordinates with the minimum motion change of each marker of the instrument identified in the t-th frame and the t-1 frame are searched by using a motion vector tracking method, so that the spatial position and the direction of the tip point of each instrument in the t-th frame are calculated.
According to another aspect of the present invention, there is also provided a multi-instrument optical positioning system, comprising:
the multi-instrument judging module judges whether an instrument enters or exits through increase and decrease of the markers between the front frame and the rear frame;
the multi-instrument recognition module is used for recognizing each instrument based on the geometric shape of the marker on the instrument, and recognizing a new instrument when the new instrument enters;
a multi-instrument tracking module that tracks the motion of a plurality of said instruments using a motion vector tracking algorithm.
The invention has the advantages that: the invention tracks the apparatus by using the method of motion vector tracking, can track a plurality of apparatuses in real time, can reduce the frame loss and the condition that individual apparatus is not tracked, and solves the real-time property of multi-apparatus tracking; it is proposed to identify instruments using side length ratios and/or perimeter lengths, reducing the restrictions on the shape of the instruments, even if there are similarly shaped instruments that can still be distinguished. The invention can judge the increase and decrease of the instruments by using the increase and decrease of the number of the markers between the front frame and the back frame, and can still correctly position the positions and the directions of all the instruments when the number of the instruments changes.
Example 1
Step S1: judging increase or decrease of number of instruments based on increase or decrease of number of markers
In practical applications, there are often situations where a new instrument is added or removed while tracking the instrument. In order to prevent the system from influencing the tracking of other instruments when the number of the instruments changes, the invention judges whether the instruments enter or exit by detecting the increase and decrease conditions of the markers of the frames before and after detection. Firstly, initializing the system, and clearing the marker coordinate tables of all instruments, wherein the number of the markers is 0.
Step S2: marker geometry based instrument recognition
For the convenience of tracking and identification, markers can be added at different positions on the instrument to form different geometric shapes, so that the aim of distinguishing a plurality of instruments is fulfilled. Although using the principle of binocular vision, the distance between the markers is fixed after the instrument is calibrated. However, when the binocular camera captures a plurality of infrared markers of a plurality of instruments through the filter, the poses of the respective instruments are different, and thus the instruments cannot be distinguished simply by tracking the distances between the markers in real time. The invention adopts a method that the instrument is just aligned to the camera for the first time, and based on the fixed geometric shape of the marker, different instruments are distinguished by utilizing the side length ratio and/or the perimeter.
Taking the example of tracking two instruments, as shown in FIG. 3, the left small instrument in the figure is denoted as MSI; on the right is a large machine, denoted as TSI. The instrument is provided with a marker which is an actively luminous near-infrared light-emitting diode. Line segments are formed between the luminous markers, and it can be seen that the geometrical structures of the two instruments are different, the three markers of the small instrument are approximately in the shape of a right triangle, and the three markers of the large instrument are approximately in the shape of an isosceles triangle.
If there are L instruments, at least three markers { A, B, C } are set for each instrument, and are respectively marked as { A1,B1,C1},…,{Al,Bl,Cl},,{AL,BL,CLL ═ 1,2, …, L, the instrument number involved in optical localization is indicated, and L is the total number of instruments involved in optical localization.
Labeling the A
lAnd B
l、A
lAnd C
lThe Euclidean distances therebetween are respectively denoted as
Of each instrument
Is different, thereby enabling the registration of the identification of multiple instruments.
Is represented as follows:
wherein
Respectively A on the first instrument
l、B
l、C
lThe center pixel coordinates of the three markers. The method is based on a region growing method and a gray scale centroid method to calculate the central pixel coordinate of the marker.
FIG. 4 is a multi-instrument recognition algorithm process of the present invention. Firstly, placing a plurality of instruments over against a camera, acquiring a 1 st frame of left and right views, and respectively solving the coordinates of central pixel points of left and right view markers. By finding the leftmost point a in the left view
l(l∈[1,L]) Separately calculate A
lEuclidean distance from the rest of the points, and is recorded as
The calculation is not carried out with the self point, and the calculation is shown as a formula (2):
computing
The ratio between two is recorded as η when η epsilon [ delta ]
l-ε,δ
l+ε]Then, the three markers belong to the first instrument, wherein [ delta ]
l-ε,δ
l+ε]For a set range of ratios for the first instrument, δ
lWhen the first instrument is opposite to the camera
The value of epsilon is an empirical error to solve the problem of deviation caused by the fact that the camera cannot be exactly aligned when instruments are manually placed. And for the marker in the right view, the same operation as that in the left view is carried out, so that the registration or pairing of each instrument is realized, and then the position of the tip point of each instrument is calculated by utilizing the stereo matching principle.
Step S3: motion vector tracking
In an actual process, the pose of the instrument is often required to be adjusted in real time according to a specific tracking position, the instrument is difficult to be completely opposite to the camera for acquisition, when the instrument rotates, the shape of the markers acquired by the camera changes, and when the rotation angle is too large, the markers exceed a set side length ratio range. In order to achieve more accurate positioning, the present invention proposes to track the instrument in real time by using a motion vector tracking method on a time series, as shown in fig. 5.
In order to calculate the position of the tip of the instrument in the current t (t is more than or equal to 2) th frame, the positions of markers of the left and right views in the t frame are tracked firstly, and the central pixel coordinates of the markers in the left and right views in the (t-1) th frame and the t frame are calculated. Since the relative motion of the adjacent frames is small, i.e. the motion vectors of the adjacent frames are small, the magnitude of the motion vector can be defined, i.e. the magnitude of the motion vector of the center point of the marker in different frames is:
i in formula (3)
v,w(t) represents a motion vector from a V point of a (t-1) th frame to a W point of a t frame
Of which wherein
Respectively represent the position vectors of V point at the (t-1) th frame and W point at the t-1 th frame, and
then, according to step S2, the recognition result of each instrument is obtained, if A is
l,B
l,C
l(L is more than or equal to 1 and less than or equal to L) are three mark points for identifying the registered first instrument, and the mark objects belong to the first instrument of the t frame according to the minimum motion vector amplitude of each mark object in the left view of the t frame in the following formula by the central pixel coordinate of the left view of the (t-1) th frame of each instrument.
In the formula (4)
Respectively representing a marker of the left view of the t-th frame and a marker A of the left view of the (t-1) th frame
l、B
l、C
lThe marker corresponding to the minimum value of the motion vector magnitude of (a) belongs to the i-th instrument at the t-th frame. At the same time, the right view does the same algorithm tracking.
Therefore, the method realizes the registration of the multi-instrument markers of front and back frames and left and right views based on the motion vector, calculates the coordinates of the tip point of each instrument by using the binocular vision principle, and realizes the real-time tracking of each instrument.
According to another aspect of the present invention, there is also provided a multi-instrument tracking optical localization system, comprising: the multi-instrument judging module judges whether an instrument enters or exits through increase and decrease of the markers between the front frame and the rear frame; the multi-instrument recognition module is used for recognizing each instrument based on the geometric shape of the marker on the instrument, and recognizing a new instrument when the new instrument enters; a multi-instrument tracking module that tracks the motion of a plurality of said instruments using a motion vector tracking algorithm. Fig. 6 is a schematic diagram illustrating the operation of the multi-instrument tracking optical positioning system of the present invention. Firstly, initializing the system, and clearing the marker coordinate tables of all instruments, wherein the number of the markers is 0. The camera captures left and right images of all markers to be tracked and then calculates the center pixel coordinates of each marker. Judging whether an instrument enters or exits by using a multi-instrument judging module, and if so, identifying a new instrument by using a multi-instrument identifying module; if not, tracking each instrument by using the motion vector to obtain the central pixel coordinates of each instrument marker in the left and right images. And finally, performing stereo matching three-dimensional reconstruction on each instrument, and calculating the spatial position coordinates and the directions of the tip points of each instrument.
In order to verify the technical effect of the invention, a large number of experiments were also performed, and the following are experimental results.
Results of the experiment
1 marker matching assay
In the experiment, a multi-instrument multi-marker image is obtained by using Bumblebe 2 of PointGrey company, the image resolution is 640 multiplied by 480, a near infrared LED lamp is used as a marker, the peak wavelength is 850nm, and two near infrared filters (the wavelength range is 850-1000nm) are added in front of a camera to filter the interference of natural light. The MSI and TSI instruments are adopted as the instruments.
A large number of experiments prove that the error epsilon of experience is set to be 0.05, so that the problem of deviation caused by manually placing instruments over the camera can be well solved.
Respectively acquiring 100 images when MSI and TSI are right facing to the camera, and calculating
Table 1 and table 2 show the first 10 ratios and 100 averages of MSI and TSI, respectively.
TABLE 1 of MSI and TSI
Value of (A)
From the data in Table 1, the MSI can be expressed
The range is set to [1.332,1.432 ]]Of TSI
The range is set to [1.212,1.312 ]]From step S1, if there is a ratio η
1∈[1.332,1.432],η
2∈[1.212,1.312]Then the registered identification of MSI and TSI is completed.
To verify the real-time validity of the algorithm, two instruments are placed approximately 620mm from the camera, and then both instruments are moved simultaneously, with the MSI rounding away from the camera and the TSI rounding closer to the camera. The algorithm can display the positions and the motion tracks of the two instrument tip points in real time. FIG. 7, below, is a schematic diagram of trajectory tracking after movement of two instruments, where the solid line is the trajectory of the MSI tip point and the dashed line is the trajectory of the TSI tip point.
2 experiment of positioning accuracy
In order to measure the tracking precision of the algorithm, the invention designs an experiment to measure the precision of two instruments on the distance, and fixes the large instrument and the small instrument on the grating ruler and carries out positioning and tracking. The resolution of the grating ruler is 0.005mm, the moving distance is measured and displayed digitally through the movement of the slider of the grating ruler, the value is used as a true value, then the moving distance calculated by the algorithm is compared with the true value, and the precision of the algorithm on the distance is calculated.
Firstly, clearing the numerical value of the display of the grating ruler, recording the numerical value as a zero point, acquiring 100 images, and calculating the average value of the coordinates of the tip point of the instrument. And then, moving the slide block to a certain position, recording the distance value displayed by the grating ruler, and recording as an end point. At this time, 100 images are again acquired at the end point, and the average value of the coordinates of the tip point is obtained. And finally, calculating the distance between the zero point and the terminal point, and comparing the distance with the true value.
Simulated instrument measurements are shown in tables 2 and 3, with table 2 being the MSI distance measurements and table 3 being the TSI measurements.
TABLE 2 MSI measurement accuracy
TABLE 3 TSI measurement accuracy
As can be seen from tables 2 and 3, the average absolute errors between the distances measured by the grating scales of the MSI and the TSI and the distance calculated by the algorithm are respectively 0.065mm and 0.031mm, and the average RMSE between the distances measured by the grating scales of the MSI and the TSI is respectively 0.041mm and 0.102mm, so that the algorithm has higher precision. Meanwhile, in order to prove that the distance between the two instruments is basically unchanged, the Euclidean distance between the tip points of the two instruments is calculated through an algorithm, and the algorithm verification is carried out, as shown in Table 4.
TABLE 4 Euclidean distance between MSI and TSI instruments
The average of the European standard deviation of the distance in Table 4 is 0.053mm, and the distance between the two instrument tips is stable.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.