Acupuncture point positioning system and method based on combination of binocular vision and coded structured light
Technical Field
The invention belongs to the field of medical technology application, and particularly relates to an acupuncture point positioning method based on combination of binocular vision and coded structured light.
Background
In traditional Chinese medicine, acupuncture therapy has a long history and a unique curative effect. However, the treatment method has high requirements on the experience and technique of the practitioner, which is particularly shown in the accuracy of the acupuncture point positioning. The acupoint location method based on body, which is given in medical books, mainly uses a certain organ or a certain characteristic part of body as a reference to find the relative position of the acupoint. At present, the related technology of automatic acupoint selection at home and abroad is not mature, most of the technologies are in the research stage, and the examples of clinical application are almost not available. To accurately determine the positions of the acupuncture points, years of clinical practice are required, and doctors with little clinical experience have great difficulty in accurately positioning the acupuncture points. Therefore, there is an urgent need to develop a positioning apparatus for automatically positioning the acupuncture points.
In order to solve the problem, an acupuncture point positioning method combining binocular vision and structured light is developed, a human back model is subjected to three-dimensional reconstruction, two-dimensional coordinates shot by a camera are restored to three-dimensional coordinates in a world coordinate system, the human back model is segmented from images, and corresponding acupuncture point information of the human back is found by combining traditional Chinese medicine.
Disclosure of Invention
The invention aims to provide a binocular vision and structured light combined acupuncture point positioning system and method, aiming at the defects of the prior art, the binocular vision and structured light combined acupuncture point positioning system and method are used for carrying out three-dimensional reconstruction on a human back model, restoring two-dimensional coordinates shot by a camera into three-dimensional coordinates under a world coordinate system, segmenting the human back model from images, and finding corresponding acupuncture point information of the human back by combining traditional Chinese medicine.
In order to achieve the purpose, the technical scheme of the invention is as follows:
the acupuncture point positioning system based on combination of binocular vision and coded structured light comprises two identical cameras, a structured light generator, a support frame, a calibration board and a main controller; the two cameras and the structural light generator are positioned above the support frame, and the structural light generator is positioned in front of the two cameras;
the structured light generator is used for projecting structured light on the back of a human body; wherein the pattern of structured light is a stripe pattern encoded with gray codes;
the camera is used for capturing an image of the back of the human body projected with the structured light pattern;
the calibration plate is used for calibrating the camera;
the main controller is used for controlling the starting of the structured light generator, setting a structured light pattern by the code of the structured light generator, receiving the pattern information transmitted by the camera and transmitting the pattern information to the computer for data analysis.
An acupuncture point positioning method based on combination of binocular vision and coded structured light comprises the following steps:
step (1), camera calibration:
and calibrating by adjusting the direction of the calibration board or the camera by adopting a Zhang Zhengyou calibration method.
In the calibration process, the camera extracts angular points as characteristic points, a least square method is applied to estimate distortion parameters under the condition of actual radial distortion, and finally a maximum likelihood method is applied to optimize and improve the precision, so that rotation and translation parameters and camera distortion parameters are obtained.
Step (2), starting the structured light generator, and enabling the structured light pattern to fall on the back of the human body;
step (3), two cameras acquire a left image and a right image of the back of the human body, which are projected with structured light patterns;
step (4) image stereo correction
The left image and the right image are corrected in a three-dimensional way by the prior art; the stereo correction is to align two images which are not strictly coplanar and aligned into a coplanar and line alignment.
Step (5) obtaining matching points
5-1 Gray code values
And projecting Gray code pattern structured light to the back of the human body for coding and decoding, so that each pixel point acquired by the two cameras obtains a Gray code value.
The decoding adopts the structured light of the coded original gray code pattern projected to the back of the human body, then the structured light of the gray code anti-code pattern is projected to the back of the human body again, and finally the decoding is carried out through the two patterns.
The Gray code decoding pattern is obtained by inverting the original Gray code pattern.
In the decoding stage, a simple dual-threshold segmentation method is adopted: let I (x, y) be the gray value of the image at point (x, y), I+And (x, y) is the corresponding gray value when the original Gray code pattern is projected, and I- (x, y) is the corresponding gray value when the gray code anti-code pattern is projected. If I+(x,y)<I- (x, y), the gray code value at the coordinate is considered to be 0, otherwise, the gray code value is 1.
5-2 phase value
The structured light with N patterns is projected on the back of a human body, each pattern corresponds to a phase value, and the phase period is N. And extracting the boundary of the black and white stripe from each phase diagram, wherein if the pixel point (x, y) in the nth phase diagram is extracted to the boundary, the phase value corresponding to the pixel point (x, y) is N, and N is less than or equal to N.
5-3 search for matching points
And traversing pixel points on the same line of the right image by a traversal search method, and searching a point of the left image P (x, y) corresponding to the right image and having the same gray code value and phase value, wherein the point is a matching point.
Difference in structured light and general binocular vision: for scenes with few texture features, the effect of binocular vision reconstruction is not good. The structured light is projected, the texture of the image is improved, the environment interference resistance is enhanced, the reliability is higher, and the quality of the depth map is improved greatly.
Step (6), acquiring a disparity map and a depth map:
6-1 assume left plot point PL(xl,yl) The matching point in the right diagram is Pr(xr,yr) Point PLCorresponding to a disparity value of xl-xr(ii) a And solving a parallax value of each effective pixel point in the left image to obtain a parallax image.
The effective pixel points are pixel points with right image matching points.
6-2, eliminating invalid pixel points in the disparity map by adopting a median filtering mode.
The invalid pixel points are pixel points without matching points.
6-3, converting the disparity map into a depth map by a triangulation formula, specifically:
a) establishing a pixel coordinate system O on the left image0-uv。
b) And establishing an image coordinate system O-XY by taking the intersection point of the optical axis of the camera and the plane as an origin.
c) And establishing a camera coordinate system by taking the optical center of the camera as an origin, taking the optical axis of the camera as a Z axis, and setting the X axis and the Y axis to be the same as the X axis and the Y axis of the image coordinate system.
d) Constructing a relation between a pixel coordinate system and an image coordinate system as follows:
wherein u and v respectively represent the u axis and the v axis of the pixel coordinate system; (u)0,v0) Representing pixel points in a pixel coordinate system, (X, y) representing coordinate points in an image coordinate system, (X)c,Yc,Zc) And d, dy are physical sizes of the coordinate points in the image coordinate system on an x axis and a y axis.
e) The relationship between the camera coordinate system and the image coordinate system is constructed through projection perspective relationship transformation as follows:
where f represents the focal length of the left camera.
f) The relationship of the camera coordinate system and the world coordinate system can be described by the rotation parameter R and the translation parameter T determined by the camera external parameters, and the relationship is as follows:
wherein (X)w,Yw,Zw) Coordinate points representing a world coordinate system.
g) The conversion relation between the world coordinate system and the pixel coordinate system of a certain point in the single-camera imaging can be obtained through the conversion of the four coordinate systems as follows:
wherein f isx,fyAnd calibrating the internal parameter focal length of the left camera.
h) And (4) obtaining the three-dimensional coordinate values of all effective pixel points of the left image in the world coordinate system by combining the formula (4) according to the matching point information obtained in the step (5).
i) Three-dimensional measurement of the back of the human body is carried out according to the parallax principle, and the three-dimensional coordinates of the space points are as follows:
wherein, B is the base line distance of the binocular camera, f is the focal length of the camera, (x)i,yi) Is the coordinate of the effective pixel point of the left camera under the image coordinate system, (x)r,yr) Is the image coordinate system and (x)i,yi) The corresponding right camera matches the point coordinates.
Step (7) of obtaining the position information of the acupuncture points
7-1 obtaining a Back image Profile
And preprocessing the left image, and then carrying out edge detection by using a canny operator to obtain a back image contour map.
The preprocessing is to divide the left image by using a watershed algorithm, the watershed algorithm divides the regions which are close in space and have similar gray values into one region, and the gray values are the same, so that the contour segmentation and extraction are performed.
7-2, searching two obvious characteristic points on the back based on the back image contour map to obtain two-dimensional pixel coordinates of the two characteristic points; the distinct feature points are at the widest and narrowest two-point locations on the median ridge.
And 7-3, further obtaining the three-dimensional coordinates of the characteristic points by combining the formula (4) based on the pixel coordinates of the two characteristic points.
7-4, according to the three-dimensional coordinates of the characteristic points, combining the traditional Chinese medicine bone degree cunning method to obtain the position information of the acupuncture points.
The invention has the beneficial effects that:
1) according to the invention, the three-dimensional information of the back is reconstructed by adopting the two cameras and the structured light, so that the positioning accuracy is further improved.
2) The medical instrument for automatically detecting and positioning the specific acupuncture points of the body, such as the acupuncture points of the head and the back, is adopted to assist a clinician in accurately positioning the acupuncture points and reduce the subjective misjudgment probability of the clinician.
3) The invention combines the coding structure light and the binocular vision, effectively solves the difficult problems of indoor white walls and non-texture objects, enhances the environmental interference resistance, has stronger reliability and greatly improves the quality of the depth map.
Drawings
FIG. 1 is a schematic structural view of the present invention;
the labels in the figure are: 1. the system comprises a left camera, a 2-structure light generator, a 3-right camera and a 4-support frame;
FIG. 2 is a stripe pattern with Gray code encoding;
fig. 3(a) is a left image, and fig. 3(b) is a back image contour diagram.
Detailed Description
The present invention is further analyzed with reference to the following specific examples.
As shown in fig. 1, the acupuncture point positioning system based on binocular vision and coded structured light combination comprises a left camera 1, a right camera 3 with the same parameters, a structured light generator 2, a support frame 4, a calibration board and a main controller; the two cameras and the structural light generator are positioned above the support frame, and the structural light generator is positioned in front of the two cameras;
the structured light generator is used for projecting structured light on the back of a human body; wherein the pattern of structured light is a stripe pattern encoded with gray codes as in fig. 2;
the camera is used for capturing an image of the back of the human body projected with the structured light pattern;
the calibration plate is used for calibrating the camera;
the main controller is used for controlling the starting of the structured light generator, setting a structured light pattern by the code of the structured light generator, receiving the pattern information transmitted by the camera and transmitting the pattern information to the computer for data analysis.
An acupuncture point positioning method based on combination of binocular vision and coded structured light comprises the following steps:
step (1), camera calibration:
and calibrating by adjusting the direction of the calibration board or the camera by adopting a Zhang Zhengyou calibration method.
In the calibration process, the camera extracts angular points as characteristic points, a least square method is applied to estimate distortion parameters under the condition of actual radial distortion, and finally a maximum likelihood method is applied to optimize and improve the precision, so that rotation and translation parameters and camera distortion parameters are obtained.
Step (2), starting the structured light generator, and enabling the structured light pattern to fall on the back of the human body;
step (3), two cameras acquire a left image and a right image of the back of the human body, which are projected with structured light patterns;
step (4) image stereo correction
The left image and the right image are corrected in a three-dimensional way by the prior art; the stereo correction is to align two images which are not strictly coplanar and aligned into a coplanar and line alignment.
Step (5) obtaining matching points
5-1 Gray code values
And projecting Gray code pattern structured light to the back of the human body for coding and decoding, so that each pixel point acquired by the two cameras obtains a Gray code value.
The decoding is to project the structured light of the coded original gray code pattern to the back of the human body, then to invert the original gray code pattern to be the gray code inverted pattern, to project the structured light of the gray code inverted pattern to the back of the human body again, and finally to decode through the two patterns.
In the decoding stage, a simple dual-threshold segmentation method is adopted: let I (x, y) be the gray value of the image at point (x, y), I+(x, y) is the corresponding gray value when projecting the original Gray code pattern, I-And (x, y) is the corresponding gray value when the gray code anti-code pattern is projected. If I+(x,y)<I-(x, y), the gray code value at the coordinate is considered to be 0, otherwise, the gray code value is 1.
5-2 phase value
The structured light with N patterns is projected on the back of a human body, each pattern corresponds to a phase value, and the phase period is N. And extracting the boundary of the black and white stripe from each phase diagram, wherein if the pixel point (x, y) in the nth phase diagram is extracted to the boundary, the phase value corresponding to the pixel point (x, y) is N, and N is less than or equal to N.
5-3 search for matching points
And traversing pixel points on the same line of the right image by a traversal search method, and searching a point of the left image P (x, y) corresponding to the right image and having the same gray code value and phase value, wherein the point is a matching point.
Difference in structured light and general binocular vision: for scenes with few texture features, the effect of binocular vision reconstruction is not good. The structured light is projected, the texture of the image is improved, the environment interference resistance is enhanced, the reliability is higher, and the quality of the depth map is improved greatly.
Step (6), acquiring a disparity map and a depth map:
6-1 assume left plot point PL(xl,yl) The matching point in the right diagram is Pr(xr,yr) Point PLCorresponding to a disparity value of xl-xr(ii) a And solving a parallax value of each effective pixel point in the left image to obtain a parallax image.
The effective pixel points are pixel points with right image matching points.
6-2, eliminating invalid pixel points in the disparity map by adopting a median filtering mode.
The invalid pixel points are pixel points without matching points.
6-3, converting the disparity map into a depth map by a triangulation formula, specifically:
a) establishing a pixel coordinate system O on the left image0-uv。
b) And establishing an image coordinate system O-XY by taking the intersection point of the optical axis of the camera and the plane as an origin.
c) And establishing a camera coordinate system by taking the optical center of the camera as an origin, taking the optical axis of the camera as a Z axis, and setting the X axis and the Y axis to be the same as the X axis and the Y axis of the image coordinate system.
d) Constructing a relation between a pixel coordinate system and an image coordinate system as follows:
wherein the ratio of u,v represents the u-axis and the v-axis of the pixel coordinate system respectively; (u)0,v0) Representing pixel points in a pixel coordinate system, (X, y) representing coordinate points in an image coordinate system, (X)c,Yc,Zc) And d, dy are physical sizes of the coordinate points in the image coordinate system on an x axis and a y axis.
e) The relationship between the camera coordinate system and the image coordinate system is constructed through projection perspective relationship transformation as follows:
where f represents the focal length of the left camera.
f) The relationship of the camera coordinate system and the world coordinate system can be described by the rotation parameter R and the translation parameter T determined by the camera external parameters, and the relationship is as follows:
wherein (X)w,Yw,Zw) Coordinate points representing a world coordinate system.
g) The conversion relation between the world coordinate system and the pixel coordinate system of a certain point in the single-camera imaging can be obtained through the conversion of the four coordinate systems as follows:
wherein f isx,fyAnd calibrating the internal parameter focal length of the left camera.
h) And (4) obtaining the three-dimensional coordinate values of all effective pixel points of the left image in the world coordinate system by combining the formula (4) according to the matching point information obtained in the step (5).
i) Three-dimensional measurement of the back of the human body is carried out according to the parallax principle, and the three-dimensional coordinates of the space points are as follows:
wherein, B is the base line distance of the binocular camera, f is the focal length of the camera, (x)i,yi) Is the coordinate of the effective pixel point of the left camera under the image coordinate system, (x)r,yr) Is the image coordinate system and (x)i,yi) The corresponding right camera matches the point coordinates.
Step (7) of obtaining the position information of the acupuncture points
7-1 obtaining a Back image Profile
The left image in fig. 3(a) is preprocessed, and then edge detection is performed by using a canny operator, so as to obtain a back image contour map fig. 3 (b).
The preprocessing is to divide the left image by using a watershed algorithm, the watershed algorithm divides the regions which are close in space and have similar gray values into one region, and the gray values are the same, so that the contour segmentation and extraction are performed.
7-2, searching two obvious characteristic points on the back based on the back image contour map to obtain two-dimensional pixel coordinates of the two characteristic points; the distinct feature points are at the widest and narrowest two-point locations on the median ridge.
And 7-3, further obtaining the three-dimensional coordinates of the characteristic points by combining the formula (4) based on the pixel coordinates of the two characteristic points. 7-4, according to the three-dimensional coordinates of the characteristic points, combining the traditional Chinese medicine bone degree cunning method to obtain the position information of the acupuncture points.
The above embodiments are not intended to limit the present invention, and the present invention is not limited to the above embodiments, and all embodiments are within the scope of the present invention as long as the requirements of the present invention are met.