Summary of the invention
To solve the above problems, the disclosure provides the technical solution of a kind of Pupil diameter calibration method and system, pass through needle
Pre-treatment steps, the images made such as shelter removal, normalization, gray scale linear interpolation to the image of acquisition pupil have
The effect of low-pass filtering eliminates the influence that pupil region in image zooms in or out to which the pupil region of centering is positioned
Calibration, effectively improves location efficiency and positioning accuracy.
To achieve the goals above, according to the one side of the disclosure, a kind of Pupil diameter calibration method, the method are provided
The following steps are included:
S100, the image for acquiring pupil obtain the first image;
S200 obtains the second image to the first image preprocessing;
S300 carries out positioning calibration to the pupil region in the second image.
Further, in S100, the method that acquires the image of pupil are as follows: can be adopted by images such as camera, cameras
Collection equipment to human eye portion carry out shooting, collecting obtain include pupil image.
Further, in s 200, the method that the second image is obtained to the first image preprocessing are as follows:
The problems such as shelter, image background are complicated, and human face posture is various affects the positioning of pupil, if without place
Reason will cause Pupil diameter recognition accuracy decline.
S210: shelter removal:
Shelter is lower compared to the other parts gray value of pupil region, and shelter is more and disperses, spy in irregular shape
Point, therefore from judging that the angle of gray value sets about removing.
If the threshold value for separating shelter is T, in the pupil region there may be shelter (or entire first
In image), if the gray value of the pixel of pixel is lower than T in the first image, judge that the pixel is shelter pixel,
Marking the pixel is noise spot, and the gray value of the pixel is updated to 255 (rgb value is white, i.e. rgb value
255):
Wherein, I (x, y) is the gray value for the pixel that coordinate is (x, y), and N (x, y) is the gray scale of updated pixel
Value;T=200;
S220: the inside and outside boundary of pupil region in the first image is obtained:
If P is the pupil center of circle, coordinate is (xp,yp);I is the center of circle of pupil outer boundary, and coordinate is (xi,yi);
Distance between the inside and outside center of circle are as follows:
The angle of circle center line connecting and horizontal direction are as follows:
The radius of pupil outer boundary are as follows: Ri, radius is R when being indicated with pupil center, then have:
Ri=(R cos θ+Δ r cos φ)2+(R sinθ+Δr sinφ)2; (4)
Then pupil radium R are as follows:
Wherein, for the first image, circle center line connecting distance, delta r and itself and two boundary of included angle and pupil of horizontal direction
Radius is constant, the expression-form of pupil outer boundary is indicated with pupil center, the inside and outside boundary of pupil can be in pupil
The heart is indicated for pole;
By any point R in pupil region in the first imagepLine of the position of (θ, α) as the inside and outside boundary point position of pupil
Property combination, it is as follows:
Rp(θ, α)=(1- α) r (θ)+α R (θ); (6)
Wherein r (θ) is pupil inner boundary radius, and R (θ) is pupil outer boundary radius, and α ∈ [0,1] is weighting coefficient, with this
By entire pupil region with polar coordinate representation;Wherein, the identical point R of all weighting coefficient αp(θ) corresponds to same on circumference
A circumference, the identical point R of all angle, θsp(α) corresponds to the same radial upper point, and α=1 corresponds to pupil outer boundary, α
=0 corresponds to pupil boundary.
S230: pupil region is normalized to the identical rectangular area of dimension:
It is sampled in polar form pupil region with identical angular resolution and radial resolving power, and by pupil
Regional implementation is at the identical rectangular area of dimension;In the disclosure, the column of rectangular area indicate that angular samples, row indicate radial and adopt
Sample;
It is N in the hits of radial direction, then pupil region if pupil region is M in the hits of angle direction
It is converted to the rectangular area of N × M, specific steps are as follows:
S231: the coordinate parameters (x on the inside and outside boundary of pupil is obtained in the first imagep,yp,rp), (xi,yi,Ri)
S232: the center of circle of pupil outer circle and the line distance in the pupil center of circle and its angle with horizontal direction are calculated:
S233: all angle directions all phases when by the inner boundary radius of the pupil polar coordinate representation that the pupil center of circle is pole
Together, i.e. r (θ)=rp;When the pupil outer boundary polar coordinate representation that the pupil center of circle is pole, outer boundary point to pupil center away from
Change, specific formula from according to angle are as follows:
Wherein: j=1,2 ..., M;
S240: the first image progress gray-level interpolation is obtained into the second image:
When the polar coordinates point of the first image is mapped as rectangular co-ordinate point, if rectangular co-ordinate point (x, y) is not integer,
The gray value of image can not be then acquired, so to carry out gray-level interpolation processing;
The gray value of output pixel point is the average value of 2 × 2 neighborhood sampled points in image, utilizes four phases around sampled point
The gray value of adjacent pixel makees linear interpolation in both the horizontal and vertical directions;Enabling f (x, y) is the function of two variables, and its
Around sampled point four adjacent pixels formed square vertices value oneself know;It can be obtained by following bilinear interpolation equation
The functional value at any point in square:
F (x, y)=ax+by+cxy+d, in formula, a, b, tetra- parameters of c, d are determined by the functional value on known four vertex;
First image is carried out to the specific steps of gray-level interpolation are as follows:
S241: interpolation is carried out to two vertex of upper end first, is had:
F (x, 0)=f (0,0)+x (f (1,0)-f (0,0)); (9)
S242: interpolation is carried out to the bottom end vertex Liang Ge, is had:
F (x, 1)=f (0,1)+x (f (1,1)-f (0,1)); (10)
S243: in vertical direction:
F (x, y)=f (x, 0)+x (f (x, 1)-f (x, 0)); (11)
S244: it can be obtained according to the formula integration in S241 to S243:
By pre-treatment step, the second image made has the effect of low-pass filtering, eliminates pupil in the first image
The influence that bore region zooms in or out, but keep high fdrequency component impaired, it is thus possible to the profile that will lead to pupil has lesser degree
It is fuzzy.
Further, in S300, the method for carrying out positioning calibration to the pupil region in the second image is following steps:
S310 is neither destroyed the edge of pupil in the second image, also can by smooth second image of gauss low frequency filter
Eliminate the high-frequency noise of the second image;
S320 carries out smoothly, if two-dimensional Gaussian function the second image with the first derivative of two-dimensional Gaussian function are as follows:
The gradient vector of two-dimensional Gaussian function are as follows:
2 filtering convolution masks of two-dimensional Gaussian function G are decomposed into 2 one-dimensional ranks filters:
Wherein, k is constant, and σ is the parameter of Gaussian filter, indicates the smoothness of image;
S330 calculates amplitude and the direction of gradient:
Using 2 × 2 neighborhoods calculate the second image horizontal direction on gradient, to avoid detect in eyes except pupil it
Outer other parts;Wherein, 2 array P of x and y Directional partial derivativex[i, j] and Py[i, j] is respectively as follows:
X Directional partial derivative:
Px[i, j]=(I [i, j+1]-I [i, j]+I [i+1, j+1]-I [i+1, j])/2; (17)
Y Directional partial derivative:
Py[i, j]=0; (18)
With the amplitude of second order norm calculation gradient and direction, it is respectively as follows:
Amplitude is
Direction is θ [i, j]=arctan (Py[i,j]/Px[i,j]); (20)
S340 carries out non-maxima suppression to gradient magnitude:
It in order to accurately position pupil edge, then needs to calibrate gradient magnitude image M [i, j], retains amplitude part
Change maximum point, this process is exactly non-maxima suppression;
During non-maxima suppression, select to compare neighborhood within 1.5 pixel coverage of radius 3 × 3 sizes, include
The neighborhood in 8 directions carries out the interpolation of gradient magnitude to all pixels of gradient magnitude array M [i, j] along gradient direction, every
On one point, the center pixel m [i, j] of neighborhood is compared with the interpolation result of 2 gradient magnitudes along gradient direction, F [i,
J] it is fan-shaped region at neighborhood of pixels center along gradient direction, non-maxima suppression carries out in this region, if in neighborhood
The amplitude m [i, j] of heart point is big unlike 2 interpolation results on gradient direction, then by the corresponding pupil edge flag bit of m [i, j]
It is assigned a value of 0, obtains non-maxima suppression N [i, j];
Relative to traditional non-maxima suppression, the pupil edge image that this programme obtains is relatively preferable, and pupil edge is big
In be equal to a pixel, be less than or equal to two pixels, than selecting error caused by contiguous range of the radius for 1 small, and with selection
The neighborhood pupil edge figure of radius 2 is compared, and pupil edge has obtained preferable refinement;
S350 detects by dual-threshold voltage and connects pupil edge;
S360 carries out pupil loop truss by Hough transform;
By the analytic curve f of Hough transform the second image of detection, (x, a)=0, wherein x is the point on analytic curve, a
For the point on parameter space;For pupil circle, if its radius is r, the center of circle of pupil is (a, b), then equation of a circle:
(xi-a)2+(yi-b)2=r2; (21)
The circle of pupil corresponds to a point in parameter space (a, b, r) in the image space of second image, each given
Point (xi,yi) constrain cluster Circle Parameters (a, b, r) by the point;
S370 calibrates the Pupil diameter in the second image:
The parametric equation of pupil circle is rewritten are as follows:
A=x-r cos θ, b=y-r sin θ; (22)
Pupil edge point in image space is substituted into above formula one by one, finds out parameter (a, b) value;If (a, b) is located at figure
As intermediate region 1.5 pixel coverage of radius in, then otherwise plus 0 the element in the battle array H (a, b) that adds up accordingly is added 1,;Find out H
It is r that the maximum value of element in (a, b), which is respective radius, and the center of circle is (a, b), and the most circle of edge point, as pupil on circumference
Border circle.
The present invention also provides a kind of Pupil diameter calibration system, the system comprises: memory, processor and storage
In the memory and the computer program that can run on the processor, the processor execute the computer program
It operates in the unit of following system:
Image acquisition units, the image for acquiring pupil obtain the first image;
Pretreatment unit, for obtaining the second image to the first image preprocessing;
Calibration unit is positioned, for carrying out positioning calibration to the pupil region in the second image.
The disclosure has the beneficial effect that the present invention provides a kind of Pupil diameter calibration method and system, makes pupil outer boundary
The part of the left and right sides is disturbed less, and borderline quality is higher, eliminates the influence that pupil region in image zooms in or out,
The high-frequency noise of image can be effectively eliminated, quickly accurate positioning pupil edge, improves the efficiency and precision of Pupil diameter.
Specific embodiment
It is carried out below with reference to technical effect of the embodiment and attached drawing to the design of the disclosure, specific structure and generation clear
Chu, complete description, to be completely understood by the purpose, scheme and effect of the disclosure.It should be noted that the case where not conflicting
Under, the features in the embodiments and the embodiments of the present application can be combined with each other.
It is as shown in Figure 1 to be illustrated according to a kind of flow chart of Pupil diameter calibration method of the disclosure below with reference to Fig. 1
According to a kind of Pupil diameter calibration method of embodiment of the present disclosure.
The disclosure proposes a kind of Pupil diameter calibration method, specifically includes the following steps:
S100, the image for acquiring pupil obtain the first image;
S200 obtains the second image to the first image preprocessing;
S300 carries out positioning calibration to the pupil region in the second image.
Further, in S100, the method that acquires the image of pupil are as follows: can be adopted by images such as camera, cameras
Collection equipment to human eye portion carry out shooting, collecting obtain include pupil image.
Further, in s 200, the method that the second image is obtained to the first image preprocessing are as follows:
The problems such as shelter, image background are complicated, and human face posture is various affects the positioning of pupil, if without place
Reason will cause Pupil diameter recognition accuracy decline.
S210: shelter removal:
Shelter is lower compared to the other parts gray value of pupil region, and shelter is more and disperses, spy in irregular shape
Point, therefore from judging that the angle of gray value sets about removing.
If the threshold value for separating shelter is T, in the pupil region there may be shelter (or entire first
In image), if the gray value of the pixel of pixel is lower than T in the first image, judge that the pixel is shelter pixel,
Marking the pixel is noise spot, and the gray value of the pixel is updated to 255 (rgb value is white, i.e. rgb value
255):
Wherein, I (x, y) is the gray value for the pixel that coordinate is (x, y), and N (x, y) is the gray scale of updated pixel
Value;T=200;
S220: the inside and outside boundary of pupil region in the first image is obtained:
If P is the pupil center of circle, coordinate is (xp,yp);I is the center of circle of pupil outer boundary, and coordinate is (xi,yi);
Distance between the inside and outside center of circle are as follows:
The angle of circle center line connecting and horizontal direction are as follows:
The radius of pupil outer boundary are as follows: Ri, radius is R when being indicated with pupil center, then have:
Ri=(R cos θ+Δ r cos φ)2+(R sinθ+Δr sinφ)2; (4)
Then pupil radium R are as follows:
Wherein, for the first image, circle center line connecting distance, delta r and itself and two boundary of included angle and pupil of horizontal direction
Radius is constant, the expression-form of pupil outer boundary is indicated with pupil center, the inside and outside boundary of pupil can be in pupil
The heart is indicated for pole;
By any point R in pupil region in the first imagepLine of the position of (θ, α) as the inside and outside boundary point position of pupil
Property combination, it is as follows:
Rp(θ, α)=(1- α) r (θ)+α R (θ); (6)
Wherein r (θ) is pupil inner boundary radius, and R (θ) is pupil outer boundary radius, and α ∈ [0,1] is weighting coefficient, with this
By entire pupil region with polar coordinate representation;Wherein, the identical point R of all weighting coefficient αp(θ) corresponds to same on circumference
A circumference, the identical point R of all angle, θsp(α) corresponds to the same radial upper point, and α=1 corresponds to pupil outer boundary, α
=0 corresponds to pupil boundary.
S230: pupil region is normalized to the identical rectangular area of dimension:
It is sampled in polar form pupil region with identical angular resolution and radial resolving power, and by pupil
Regional implementation is at the identical rectangular area of dimension;In the disclosure, the column of rectangular area indicate that angular samples, row indicate radial and adopt
Sample;
It is N in the hits of radial direction, then pupil region if pupil region is M in the hits of angle direction
It is converted to the rectangular area of N × M, specific steps are as follows:
S231: the coordinate parameters (x on the inside and outside boundary of pupil is obtained in the first imagep,yp,rp), (xi,yi,Ri)
S232: the center of circle of pupil outer circle and the line distance in the pupil center of circle and its angle with horizontal direction are calculated:
S233: all angle directions all phases when by the inner boundary radius of the pupil polar coordinate representation that the pupil center of circle is pole
Together, i.e. r (θ)=rp;When the pupil outer boundary polar coordinate representation that the pupil center of circle is pole, outer boundary point to pupil center away from
Change, specific formula from according to angle are as follows:
Wherein: j=1,2 ..., M;
S240: the first image progress gray-level interpolation is obtained into the second image:
When the polar coordinates point of the first image is mapped as rectangular co-ordinate point, if rectangular co-ordinate point (x, y) is not integer,
The gray value of image can not be then acquired, so to carry out gray-level interpolation processing;
The gray value of output pixel point is the average value of 2 × 2 neighborhood sampled points in image, utilizes four phases around sampled point
The gray value of adjacent pixel makees linear interpolation in both the horizontal and vertical directions;Enabling f (x, y) is the function of two variables, and its
Around sampled point four adjacent pixels formed square vertices value oneself know;It can be obtained by following bilinear interpolation equation
The functional value at any point in square:
F (x, y)=ax+by+cxy+d, in formula, a, b, tetra- parameters of c, d are determined by the functional value on known four vertex;
First image is carried out to the specific steps of gray-level interpolation are as follows:
S241: interpolation is carried out to two vertex of upper end first, is had:
F (x, 0)=f (0,0)+x (f (1,0)-f (0,0)); (9)
S242: interpolation is carried out to the bottom end vertex Liang Ge, is had:
F (x, 1)=f (0,1)+x (f (1,1)-f (0,1)); (10)
S243: in vertical direction:
F (x, y)=f (x, 0)+x (f (x, 1)-f (x, 0)); (11)
S244: it can be obtained according to the formula integration in S241 to S243:
By pre-treatment step, the second image made has the effect of low-pass filtering, eliminates pupil in the first image
The influence that bore region zooms in or out, but keep high fdrequency component impaired, it is thus possible to the profile that will lead to pupil has lesser degree
It is fuzzy.
Further, in S300, the method for carrying out positioning calibration to the pupil region in the second image is following steps:
S310 is neither destroyed the edge of pupil in the second image, also can by smooth second image of gauss low frequency filter
Eliminate the high-frequency noise of the second image;
S320 carries out smoothly, if two-dimensional Gaussian function the second image with the first derivative of two-dimensional Gaussian function are as follows:
The gradient vector of two-dimensional Gaussian function are as follows:
2 filtering convolution masks of two-dimensional Gaussian function G are decomposed into 2 one-dimensional ranks filters:
Wherein, k is constant, and σ is the parameter of Gaussian filter, indicates the smoothness of image;
S330 calculates amplitude and the direction of gradient:
Using 2 × 2 neighborhoods calculate the second image horizontal direction on gradient, to avoid detect in eyes except pupil it
Outer other parts;Wherein, 2 array P of x and y Directional partial derivativex[i, j] and Py[i, j] is respectively as follows:
X Directional partial derivative:
Px[i, j]=(I [i, j+1]-I [i, j]+I [i+1, j+1]-I [i+1, j])/2; (17)
Y Directional partial derivative:
Py[i, j]=0; (18)
With the amplitude of second order norm calculation gradient and direction, it is respectively as follows:
Amplitude is
Direction is θ [i, j]=arctan (Py[i,j]/Px[i,j]); (20)
S340 carries out non-maxima suppression to gradient magnitude:
It in order to accurately position pupil edge, then needs to calibrate gradient magnitude image M [i, j], retains amplitude part
Change maximum point, this process is exactly non-maxima suppression;
During non-maxima suppression, select to compare neighborhood within 1.5 pixel coverage of radius 3 × 3 sizes, include
The neighborhood in 8 directions carries out the interpolation of gradient magnitude to all pixels of gradient magnitude array M [i, j] along gradient direction, every
On one point, the center pixel m [i, j] of neighborhood is compared with the interpolation result of 2 gradient magnitudes along gradient direction, F [i,
J] it is fan-shaped region at neighborhood of pixels center along gradient direction, non-maxima suppression carries out in this region, if in neighborhood
The amplitude m [i, j] of heart point is big unlike 2 interpolation results on gradient direction, then by the corresponding pupil edge flag bit of m [i, j]
It is assigned a value of 0, obtains non-maxima suppression N [i, j];
Relative to traditional non-maxima suppression, the pupil edge image that this programme obtains is relatively preferable, and pupil edge is big
In be equal to a pixel, be less than or equal to two pixels, than selecting error caused by contiguous range of the radius for 1 small, and with selection
The neighborhood pupil edge figure of radius 2 is compared, and pupil edge has obtained preferable refinement;
S350 detects by dual-threshold voltage and connects pupil edge;
S360 carries out pupil loop truss by Hough transform;
By the analytic curve f of Hough transform the second image of detection, (x, a)=0, wherein x is the point on analytic curve, a
For the point on parameter space;For pupil circle, if its radius is r, the center of circle of pupil is (a, b), then equation of a circle:
(xi-a)2+(yi-b)2=r2; (21)
The circle of pupil corresponds to a point in parameter space (a, b, r) in the image space of second image, each given
Point (xi,yi) constrain cluster Circle Parameters (a, b, r) by the point;
S370 calibrates the Pupil diameter in the second image:
The parametric equation of pupil circle is rewritten are as follows:
A=x-r cos θ, b=y-r sin θ; (22)
Pupil edge point in image space is substituted into above formula one by one, finds out parameter (a, b) value;If (a, b) is located at figure
As intermediate region 1.5 pixel coverage of radius in, then otherwise plus 0 the element in the battle array H (a, b) that adds up accordingly is added 1,;Find out H
It is r that the maximum value of element in (a, b), which is respective radius, and the center of circle is (a, b), and the most circle of edge point, as pupil on circumference
Border circle.
A kind of embodiment of the disclosure:
(1) the pupil picture of the preparation of sample positive sample selection different people first, negative sample select non-pupil picture.Sample
Number is 1000, positive sample 700, and negative sample 300 is placed on positive negative sample under different files respectively, while training letter
Several and positive negative sample is put into together under a file;
(2) a kind of Pupil diameter calibration method of the disclosure such as is carried out to positive negative sample to handle;
(3) after generation pattern representation file pre-processes positive negative sample, positive sample vec file is created;
(4) training classifier is inputted in cmd order line: opencv_traincascade.exe-data xml-vec
pos.vec-bg neg\neg.txt-numpos 700-numneg 300-numstages 20-featureType LBP-
w24-h24;
In order to reduce the data volume of processing, when positioning pupil inner and outer boundary, pupil image is scaled first, and
And the circle of original image is converted into after scaling positioning again, original image size is 80 × 80 pixels.It is fixed since inner circle is relatively small
The outer bowlder scaling 0.3 in position, positioning interior bowlder scaling is 0.5;The result of positioning is as shown in Fig. 2, Fig. 2 show pupil
Positioning result.
A kind of Pupil diameter calibration system that embodiment of the disclosure provides, is illustrated in figure 3 a kind of pupil of the disclosure
A kind of Pupil diameter calibration system of locating calibration system structure chart, the embodiment includes: processor, memory and is stored in
In the memory and the computer program that can run on the processor, when the processor executes the computer program
Realize the step in a kind of above-mentioned Pupil diameter calibration system embodiment.
It can be transported in the memory and on the processor the system comprises: memory, processor and storage
Capable computer program, the processor execute the computer program and operate in the unit of following system:
Image acquisition units, the image for acquiring pupil obtain the first image;
Pretreatment unit, for obtaining the second image to the first image preprocessing;
Calibration unit is positioned, for carrying out positioning calibration to the pupil region in the second image.
A kind of Pupil diameter calibration system can run on desktop PC, notebook, palm PC and cloud
Server etc. calculates in equipment.A kind of Pupil diameter calibration system, the system that can be run may include, but be not limited only to, place
Manage device, memory.It will be understood by those skilled in the art that the example is only a kind of example of Pupil diameter calibration system,
The restriction to a kind of Pupil diameter calibration system is not constituted, may include component more more or fewer than example, or combination
Certain components or different components, such as a kind of Pupil diameter calibration system can also include input-output equipment, net
Network access device, bus etc..
Alleged processor can be central processing unit (Central Processing Unit, CPU), can also be it
His general processor, digital signal processor (Digital Signal Processor, DSP), specific integrated circuit
(Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field-
Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic,
Discrete hardware components etc..General processor can be microprocessor or the processor is also possible to any conventional processor
Deng the processor is a kind of control centre of Pupil diameter calibration system operating system, utilizes various interfaces and route
A kind of entire Pupil diameter calibration system of connection can operating system various pieces.
The memory can be used for storing the computer program and/or module, and the processor is by operation or executes
Computer program in the memory and/or module are stored, and calls the data being stored in memory, described in realization
A kind of various functions of Pupil diameter calibration system.The memory can mainly include storing program area and storage data area,
In, storing program area can application program needed for storage program area, at least one function (such as sound-playing function, image
Playing function etc.) etc.;Storage data area, which can be stored, uses created data (such as audio data, phone directory according to mobile phone
Deng) etc..In addition, memory may include high-speed random access memory, it can also include nonvolatile memory, such as firmly
Disk, memory, plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital,
SD) block, flash card (Flash Card), at least one disk memory, flush memory device or other volatile solid-states
Part.
Although the description of the disclosure is quite detailed and especially several embodiments are described, it is not
Any of these details or embodiment or any specific embodiments are intended to be limited to, but should be considered as is by reference to appended
A possibility that claim provides broad sense in view of the prior art for these claims explanation, to effectively cover the disclosure
Preset range.In addition, the disclosure is described with inventor's foreseeable embodiment above, its purpose is to be provided with
Description, and those equivalent modifications that the disclosure can be still represented to the unsubstantiality change of the disclosure still unforeseen at present.